The following issues were found
numpy/core/code_generators/genapi.py
91 issues
Line: 79
Column: 11
def remove_whitespace(s):
return ''.join(s.split())
def _repl(str):
return str.replace('Bool', 'npy_bool')
class StealRef:
def __init__(self, arg):
Reported by Pylint.
Line: 142
Suggestion:
https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b303-md5
return '\n'.join(lines)
def api_hash(self):
m = hashlib.md5()
m.update(remove_whitespace(self.return_type))
m.update('\000')
m.update(self.name)
m.update('\000')
for typename, name in self.args:
Reported by Bandit.
Line: 147
Column: 23
m.update('\000')
m.update(self.name)
m.update('\000')
for typename, name in self.args:
m.update(remove_whitespace(typename))
m.update('\000')
return m.hexdigest()[:8]
class ParseError(Exception):
Reported by Pylint.
Line: 153
Column: 5
return m.hexdigest()[:8]
class ParseError(Exception):
def __init__(self, filename, lineno, msg):
self.filename = filename
self.lineno = lineno
self.msg = msg
def __str__(self):
Reported by Pylint.
Line: 353
Column: 37
return astr
class GlobalVarApi:
def __init__(self, name, index, type, api_name):
self.name = name
self.index = index
self.type = type
self.api_name = api_name
Reported by Pylint.
Line: 501
Suggestion:
https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b303-md5
a.extend(name)
a.extend(','.join(map(str, data)))
return hashlib.md5(''.join(a).encode('ascii')).hexdigest()
# To parse strings like 'hex = checksum' where hex is e.g. 0x1234567F and
# checksum a 128 bits md5 checksum (hex format as well)
VERRE = re.compile(r'(^0x[\da-f]{8})\s*=\s*([\da-f]{32})')
Reported by Bandit.
Line: 523
Suggestion:
https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b303-md5
tagname = sys.argv[1]
order_file = sys.argv[2]
functions = get_api_functions(tagname, order_file)
m = hashlib.md5(tagname)
for func in functions:
print(func)
ah = func.api_hash()
m.update(ah)
print(hex(int(ah, 16)))
Reported by Bandit.
Line: 11
Column: 1
"""
from numpy.distutils.conv_template import process_file as process_c_file
import hashlib
import io
import os
import re
import sys
import textwrap
Reported by Pylint.
Line: 12
Column: 1
from numpy.distutils.conv_template import process_file as process_c_file
import hashlib
import io
import os
import re
import sys
import textwrap
Reported by Pylint.
Line: 13
Column: 1
import hashlib
import io
import os
import re
import sys
import textwrap
from os.path import join
Reported by Pylint.
tools/refguide_check.py
90 issues
Line: 39
Column: 1
import sys
import tempfile
import warnings
import docutils.core
from argparse import ArgumentParser
from contextlib import contextmanager, redirect_stderr
from doctest import NORMALIZE_WHITESPACE, ELLIPSIS, IGNORE_EXCEPTION_DETAIL
from docutils.parsers.rst import directives
Reported by Pylint.
Line: 44
Column: 1
from contextlib import contextmanager, redirect_stderr
from doctest import NORMALIZE_WHITESPACE, ELLIPSIS, IGNORE_EXCEPTION_DETAIL
from docutils.parsers.rst import directives
from pkg_resources import parse_version
import sphinx
import numpy as np
Reported by Pylint.
Line: 47
Column: 1
from docutils.parsers.rst import directives
from pkg_resources import parse_version
import sphinx
import numpy as np
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', 'doc', 'sphinxext'))
from numpydoc.docscrape_sphinx import get_doc_object
Reported by Pylint.
Line: 51
Column: 1
import numpy as np
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', 'doc', 'sphinxext'))
from numpydoc.docscrape_sphinx import get_doc_object
SKIPBLOCK = doctest.register_optionflag('SKIPBLOCK')
if parse_version(sphinx.__version__) >= parse_version('1.5'):
# Enable specific Sphinx directives
Reported by Pylint.
Line: 57
Column: 5
if parse_version(sphinx.__version__) >= parse_version('1.5'):
# Enable specific Sphinx directives
from sphinx.directives.other import SeeAlso, Only
directives.register_directive('seealso', SeeAlso)
directives.register_directive('only', Only)
else:
# Remove sphinx directives that don't run without Sphinx environment.
# Sphinx < 1.5 installs all directives on import...
Reported by Pylint.
Line: 42
Column: 1
import docutils.core
from argparse import ArgumentParser
from contextlib import contextmanager, redirect_stderr
from doctest import NORMALIZE_WHITESPACE, ELLIPSIS, IGNORE_EXCEPTION_DETAIL
from docutils.parsers.rst import directives
from pkg_resources import parse_version
import sphinx
Reported by Pylint.
Line: 63
Column: 5
else:
# Remove sphinx directives that don't run without Sphinx environment.
# Sphinx < 1.5 installs all directives on import...
directives._directives.pop('versionadded', None)
directives._directives.pop('versionchanged', None)
directives._directives.pop('moduleauthor', None)
directives._directives.pop('sectionauthor', None)
directives._directives.pop('codeauthor', None)
directives._directives.pop('toctree', None)
Reported by Pylint.
Line: 64
Column: 5
# Remove sphinx directives that don't run without Sphinx environment.
# Sphinx < 1.5 installs all directives on import...
directives._directives.pop('versionadded', None)
directives._directives.pop('versionchanged', None)
directives._directives.pop('moduleauthor', None)
directives._directives.pop('sectionauthor', None)
directives._directives.pop('codeauthor', None)
directives._directives.pop('toctree', None)
Reported by Pylint.
Line: 65
Column: 5
# Sphinx < 1.5 installs all directives on import...
directives._directives.pop('versionadded', None)
directives._directives.pop('versionchanged', None)
directives._directives.pop('moduleauthor', None)
directives._directives.pop('sectionauthor', None)
directives._directives.pop('codeauthor', None)
directives._directives.pop('toctree', None)
Reported by Pylint.
Line: 66
Column: 5
directives._directives.pop('versionadded', None)
directives._directives.pop('versionchanged', None)
directives._directives.pop('moduleauthor', None)
directives._directives.pop('sectionauthor', None)
directives._directives.pop('codeauthor', None)
directives._directives.pop('toctree', None)
BASE_MODULE = "numpy"
Reported by Pylint.
numpy/core/tests/test_extint128.py
90 issues
Line: 4
Column: 1
import itertools
import contextlib
import operator
import pytest
import numpy as np
import numpy.core._multiarray_tests as mt
from numpy.testing import assert_raises, assert_equal
Reported by Pylint.
Line: 7
Column: 1
import pytest
import numpy as np
import numpy.core._multiarray_tests as mt
from numpy.testing import assert_raises, assert_equal
INT64_MAX = np.iinfo(np.int64).max
Reported by Pylint.
Line: 63
Column: 9
import traceback
msg = "At: %r\n%s" % (repr(value[0]),
traceback.format_exc())
raise AssertionError(msg)
def test_safe_binop():
# Test checked arithmetic routines
Reported by Pylint.
Line: 1
Column: 1
import itertools
import contextlib
import operator
import pytest
import numpy as np
import numpy.core._multiarray_tests as mt
from numpy.testing import assert_raises, assert_equal
Reported by Pylint.
Line: 53
Column: 13
value = [None]
def iterate():
for v in itertools.product(*args):
value[0] = v
yield v
try:
yield iterate()
Reported by Pylint.
Line: 60
Column: 9
try:
yield iterate()
except Exception:
import traceback
msg = "At: %r\n%s" % (repr(value[0]),
traceback.format_exc())
raise AssertionError(msg)
Reported by Pylint.
Line: 66
Column: 1
raise AssertionError(msg)
def test_safe_binop():
# Test checked arithmetic routines
ops = [
(operator.add, 1),
(operator.sub, 2),
Reported by Pylint.
Line: 75
Column: 55
(operator.mul, 3)
]
with exc_iter(ops, INT64_VALUES, INT64_VALUES) as it:
for xop, a, b in it:
pyop, op = xop
c = pyop(a, b)
if not (INT64_MIN <= c <= INT64_MAX):
Reported by Pylint.
Line: 76
Column: 21
]
with exc_iter(ops, INT64_VALUES, INT64_VALUES) as it:
for xop, a, b in it:
pyop, op = xop
c = pyop(a, b)
if not (INT64_MIN <= c <= INT64_MAX):
assert_raises(OverflowError, mt.extint_safe_binop, a, b, op)
Reported by Pylint.
Line: 76
Column: 18
]
with exc_iter(ops, INT64_VALUES, INT64_VALUES) as it:
for xop, a, b in it:
pyop, op = xop
c = pyop(a, b)
if not (INT64_MIN <= c <= INT64_MAX):
assert_raises(OverflowError, mt.extint_safe_binop, a, b, op)
Reported by Pylint.
numpy/core/tests/test_longdouble.py
88 issues
Line: 2
Column: 1
import warnings
import pytest
import numpy as np
from numpy.testing import (
assert_, assert_equal, assert_raises, assert_warns, assert_array_equal,
temppath,
)
from numpy.core.tests._locales import CommaDecimalPointLocale
Reported by Pylint.
Line: 275
Column: 5
def test_repr_exact():
o = 1 + LD_INFO.eps
assert_(repr(o) != '1')
@pytest.mark.skipif(longdouble_longer_than_double, reason="BUG #2376")
@pytest.mark.skipif(string_to_longdouble_inaccurate,
reason="Need strtold_l")
Reported by Pylint.
Line: 283
Column: 5
reason="Need strtold_l")
def test_format():
o = 1 + LD_INFO.eps
assert_("{0:.40g}".format(o) != '1')
@pytest.mark.skipif(longdouble_longer_than_double, reason="BUG #2376")
@pytest.mark.skipif(string_to_longdouble_inaccurate,
reason="Need strtold_l")
Reported by Pylint.
Line: 291
Column: 5
reason="Need strtold_l")
def test_percent():
o = 1 + LD_INFO.eps
assert_("%.40g" % o != '1')
@pytest.mark.skipif(longdouble_longer_than_double,
reason="array repr problem")
@pytest.mark.skipif(string_to_longdouble_inaccurate,
Reported by Pylint.
Line: 304
Column: 5
b = np.array([1], dtype=np.longdouble)
if not np.all(a != b):
raise ValueError("precision loss creating arrays")
assert_(repr(a) != repr(b))
#
# Locale tests: scalar types formatting should be independent of the locale
#
Reported by Pylint.
Line: 1
Column: 1
import warnings
import pytest
import numpy as np
from numpy.testing import (
assert_, assert_equal, assert_raises, assert_warns, assert_array_equal,
temppath,
)
from numpy.core.tests._locales import CommaDecimalPointLocale
Reported by Pylint.
Line: 23
Column: 5
def test_scalar_extraction():
"""Confirm that extracting a value doesn't convert to python float"""
o = 1 + LD_INFO.eps
a = np.array([o, o, o])
assert_equal(a[1], o)
# Conversions string -> long double
Reported by Pylint.
Line: 24
Column: 5
def test_scalar_extraction():
"""Confirm that extracting a value doesn't convert to python float"""
o = 1 + LD_INFO.eps
a = np.array([o, o, o])
assert_equal(a[1], o)
# Conversions string -> long double
Reported by Pylint.
Line: 35
Column: 1
# +2 from macro block starting around line 842 in scalartypes.c.src.
@pytest.mark.skipif(LD_INFO.precision + 2 >= repr_precision,
reason="repr precision not enough to show eps")
def test_repr_roundtrip():
# We will only see eps in repr if within printing precision.
o = 1 + LD_INFO.eps
assert_equal(np.longdouble(repr(o)), o, "repr was %s" % repr(o))
Reported by Pylint.
Line: 37
Column: 5
reason="repr precision not enough to show eps")
def test_repr_roundtrip():
# We will only see eps in repr if within printing precision.
o = 1 + LD_INFO.eps
assert_equal(np.longdouble(repr(o)), o, "repr was %s" % repr(o))
@pytest.mark.skipif(string_to_longdouble_inaccurate, reason="Need strtold_l")
def test_repr_roundtrip_bytes():
Reported by Pylint.
numpy/core/tests/test_memmap.py
87 issues
Line: 4
Column: 1
import sys
import os
import mmap
import pytest
from pathlib import Path
from tempfile import NamedTemporaryFile, TemporaryFile
from numpy import (
memmap, sum, average, product, ndarray, isscalar, add, subtract, multiply)
Reported by Pylint.
Line: 8
Column: 1
from pathlib import Path
from tempfile import NamedTemporaryFile, TemporaryFile
from numpy import (
memmap, sum, average, product, ndarray, isscalar, add, subtract, multiply)
from numpy import arange, allclose, asarray
from numpy.testing import (
assert_, assert_equal, assert_array_equal, suppress_warnings, IS_PYPY,
Reported by Pylint.
Line: 19
Column: 9
class TestMemmap:
def setup(self):
self.tmpfp = NamedTemporaryFile(prefix='mmap')
self.shape = (3, 4)
self.dtype = 'float32'
self.data = arange(12, dtype=self.dtype)
self.data.resize(self.shape)
Reported by Pylint.
Line: 20
Column: 9
class TestMemmap:
def setup(self):
self.tmpfp = NamedTemporaryFile(prefix='mmap')
self.shape = (3, 4)
self.dtype = 'float32'
self.data = arange(12, dtype=self.dtype)
self.data.resize(self.shape)
def teardown(self):
Reported by Pylint.
Line: 21
Column: 9
def setup(self):
self.tmpfp = NamedTemporaryFile(prefix='mmap')
self.shape = (3, 4)
self.dtype = 'float32'
self.data = arange(12, dtype=self.dtype)
self.data.resize(self.shape)
def teardown(self):
self.tmpfp.close()
Reported by Pylint.
Line: 22
Column: 9
self.tmpfp = NamedTemporaryFile(prefix='mmap')
self.shape = (3, 4)
self.dtype = 'float32'
self.data = arange(12, dtype=self.dtype)
self.data.resize(self.shape)
def teardown(self):
self.tmpfp.close()
self.data = None
Reported by Pylint.
Line: 27
Column: 9
def teardown(self):
self.tmpfp.close()
self.data = None
if IS_PYPY:
break_cycles()
break_cycles()
def test_roundtrip(self):
Reported by Pylint.
Line: 42
Column: 9
# Read data back from file
newfp = memmap(self.tmpfp, dtype=self.dtype, mode='r',
shape=self.shape)
assert_(allclose(self.data, newfp))
assert_array_equal(self.data, newfp)
assert_equal(newfp.flags.writeable, False)
def test_open_with_filename(self, tmp_path):
tmpname = tmp_path / 'mmap'
Reported by Pylint.
Line: 127
Column: 38
shape=self.shape)
tmp = (fp + 10)
if isinstance(tmp, memmap):
assert_(tmp._mmap is not fp._mmap)
def test_indexing_drops_references(self):
fp = memmap(self.tmpfp, dtype=self.dtype, mode='w+',
shape=self.shape)
tmp = fp[(1, 2), (2, 3)]
Reported by Pylint.
Line: 127
Column: 21
shape=self.shape)
tmp = (fp + 10)
if isinstance(tmp, memmap):
assert_(tmp._mmap is not fp._mmap)
def test_indexing_drops_references(self):
fp = memmap(self.tmpfp, dtype=self.dtype, mode='w+',
shape=self.shape)
tmp = fp[(1, 2), (2, 3)]
Reported by Pylint.
numpy/typing/tests/data/reveal/multiarray.py
87 issues
Line: 9
Column: 16
_SCT = TypeVar("_SCT", bound=np.generic, covariant=True)
class SubClass(np.ndarray[Any, np.dtype[_SCT]]): ...
subclass: SubClass[np.float64]
AR_f8: npt.NDArray[np.float64]
AR_i8: npt.NDArray[np.int64]
Reported by Pylint.
Line: 13
Column: 8
subclass: SubClass[np.float64]
AR_f8: npt.NDArray[np.float64]
AR_i8: npt.NDArray[np.int64]
AR_u1: npt.NDArray[np.uint8]
AR_m: npt.NDArray[np.timedelta64]
AR_M: npt.NDArray[np.datetime64]
Reported by Pylint.
Line: 14
Column: 8
subclass: SubClass[np.float64]
AR_f8: npt.NDArray[np.float64]
AR_i8: npt.NDArray[np.int64]
AR_u1: npt.NDArray[np.uint8]
AR_m: npt.NDArray[np.timedelta64]
AR_M: npt.NDArray[np.datetime64]
AR_LIKE_f: List[float]
Reported by Pylint.
Line: 15
Column: 8
AR_f8: npt.NDArray[np.float64]
AR_i8: npt.NDArray[np.int64]
AR_u1: npt.NDArray[np.uint8]
AR_m: npt.NDArray[np.timedelta64]
AR_M: npt.NDArray[np.datetime64]
AR_LIKE_f: List[float]
AR_LIKE_i: List[int]
Reported by Pylint.
Line: 16
Column: 7
AR_f8: npt.NDArray[np.float64]
AR_i8: npt.NDArray[np.int64]
AR_u1: npt.NDArray[np.uint8]
AR_m: npt.NDArray[np.timedelta64]
AR_M: npt.NDArray[np.datetime64]
AR_LIKE_f: List[float]
AR_LIKE_i: List[int]
Reported by Pylint.
Line: 17
Column: 7
AR_i8: npt.NDArray[np.int64]
AR_u1: npt.NDArray[np.uint8]
AR_m: npt.NDArray[np.timedelta64]
AR_M: npt.NDArray[np.datetime64]
AR_LIKE_f: List[float]
AR_LIKE_i: List[int]
m: np.timedelta64
Reported by Pylint.
Line: 30
Column: 1
def func(a: int) -> bool: ...
reveal_type(next(b_f8)) # E: tuple[Any]
reveal_type(b_f8.reset()) # E: None
reveal_type(b_f8.index) # E: int
reveal_type(b_f8.iters) # E: tuple[numpy.flatiter[Any]]
reveal_type(b_f8.nd) # E: int
reveal_type(b_f8.ndim) # E: int
Reported by Pylint.
Line: 31
Column: 1
def func(a: int) -> bool: ...
reveal_type(next(b_f8)) # E: tuple[Any]
reveal_type(b_f8.reset()) # E: None
reveal_type(b_f8.index) # E: int
reveal_type(b_f8.iters) # E: tuple[numpy.flatiter[Any]]
reveal_type(b_f8.nd) # E: int
reveal_type(b_f8.ndim) # E: int
reveal_type(b_f8.numiter) # E: int
Reported by Pylint.
Line: 32
Column: 1
reveal_type(next(b_f8)) # E: tuple[Any]
reveal_type(b_f8.reset()) # E: None
reveal_type(b_f8.index) # E: int
reveal_type(b_f8.iters) # E: tuple[numpy.flatiter[Any]]
reveal_type(b_f8.nd) # E: int
reveal_type(b_f8.ndim) # E: int
reveal_type(b_f8.numiter) # E: int
reveal_type(b_f8.shape) # E: tuple[builtins.int]
Reported by Pylint.
Line: 33
Column: 1
reveal_type(next(b_f8)) # E: tuple[Any]
reveal_type(b_f8.reset()) # E: None
reveal_type(b_f8.index) # E: int
reveal_type(b_f8.iters) # E: tuple[numpy.flatiter[Any]]
reveal_type(b_f8.nd) # E: int
reveal_type(b_f8.ndim) # E: int
reveal_type(b_f8.numiter) # E: int
reveal_type(b_f8.shape) # E: tuple[builtins.int]
reveal_type(b_f8.size) # E: int
Reported by Pylint.
benchmarks/benchmarks/bench_io.py
85 issues
Line: 1
Column: 1
from .common import Benchmark, get_squares
import numpy as np
from io import StringIO
class Copy(Benchmark):
params = ["int8", "int16", "float32", "float64",
"complex64", "complex128"]
Reported by Pylint.
Line: 14
Column: 9
def setup(self, typename):
dtype = np.dtype(typename)
self.d = np.arange((50 * 500), dtype=dtype).reshape((500, 50))
self.e = np.arange((50 * 500), dtype=dtype).reshape((50, 500))
self.e_d = self.e.reshape(self.d.shape)
self.dflat = np.arange((50 * 500), dtype=dtype)
def time_memcpy(self, typename):
Reported by Pylint.
Line: 15
Column: 9
def setup(self, typename):
dtype = np.dtype(typename)
self.d = np.arange((50 * 500), dtype=dtype).reshape((500, 50))
self.e = np.arange((50 * 500), dtype=dtype).reshape((50, 500))
self.e_d = self.e.reshape(self.d.shape)
self.dflat = np.arange((50 * 500), dtype=dtype)
def time_memcpy(self, typename):
self.d[...] = self.e_d
Reported by Pylint.
Line: 16
Column: 9
dtype = np.dtype(typename)
self.d = np.arange((50 * 500), dtype=dtype).reshape((500, 50))
self.e = np.arange((50 * 500), dtype=dtype).reshape((50, 500))
self.e_d = self.e.reshape(self.d.shape)
self.dflat = np.arange((50 * 500), dtype=dtype)
def time_memcpy(self, typename):
self.d[...] = self.e_d
Reported by Pylint.
Line: 17
Column: 9
self.d = np.arange((50 * 500), dtype=dtype).reshape((500, 50))
self.e = np.arange((50 * 500), dtype=dtype).reshape((50, 500))
self.e_d = self.e.reshape(self.d.shape)
self.dflat = np.arange((50 * 500), dtype=dtype)
def time_memcpy(self, typename):
self.d[...] = self.e_d
def time_memcpy_large_out_of_place(self, typename):
Reported by Pylint.
Line: 19
Column: 27
self.e_d = self.e.reshape(self.d.shape)
self.dflat = np.arange((50 * 500), dtype=dtype)
def time_memcpy(self, typename):
self.d[...] = self.e_d
def time_memcpy_large_out_of_place(self, typename):
l = np.ones(1024**2, dtype=np.dtype(typename))
l.copy()
Reported by Pylint.
Line: 26
Column: 32
l = np.ones(1024**2, dtype=np.dtype(typename))
l.copy()
def time_cont_assign(self, typename):
self.d[...] = 1
def time_strided_copy(self, typename):
self.d[...] = self.e.T
Reported by Pylint.
Line: 29
Column: 33
def time_cont_assign(self, typename):
self.d[...] = 1
def time_strided_copy(self, typename):
self.d[...] = self.e.T
def time_strided_assign(self, typename):
self.dflat[::2] = 2
Reported by Pylint.
Line: 32
Column: 35
def time_strided_copy(self, typename):
self.d[...] = self.e.T
def time_strided_assign(self, typename):
self.dflat[::2] = 2
class CopyTo(Benchmark):
def setup(self):
Reported by Pylint.
Line: 38
Column: 9
class CopyTo(Benchmark):
def setup(self):
self.d = np.ones(50000)
self.e = self.d.copy()
self.m = (self.d == 1)
self.im = (~ self.m)
self.m8 = self.m.copy()
self.m8[::8] = (~ self.m[::8])
Reported by Pylint.
numpy/distutils/tests/test_ccompiler_opt.py
84 issues
Line: 9
Column: 5
if is_standalone:
import unittest, contextlib, tempfile, shutil
sys.path.append(path.abspath(path.join(path.dirname(__file__), "..")))
from ccompiler_opt import CCompilerOpt
# from numpy/testing/_private/utils.py
@contextlib.contextmanager
def tempdir(*args, **kwargs):
tmpdir = tempfile.mkdtemp(*args, **kwargs)
Reported by Pylint.
Line: 40
Column: 1
class FakeCCompilerOpt(CCompilerOpt):
fake_info = ""
def __init__(self, trap_files="", trap_flags="", *args, **kwargs):
self.fake_trap_files = trap_files
self.fake_trap_flags = trap_flags
CCompilerOpt.__init__(self, None, **kwargs)
def __repr__(self):
Reported by Pylint.
Line: 40
Column: 5
class FakeCCompilerOpt(CCompilerOpt):
fake_info = ""
def __init__(self, trap_files="", trap_flags="", *args, **kwargs):
self.fake_trap_files = trap_files
self.fake_trap_flags = trap_flags
CCompilerOpt.__init__(self, None, **kwargs)
def __repr__(self):
Reported by Pylint.
Line: 55
Column: 1
>>>>
""").format(self.cc_march, self.cc_name, self.report())
def dist_compile(self, sources, flags, **kwargs):
assert(isinstance(sources, list))
assert(isinstance(flags, list))
if self.fake_trap_files:
for src in sources:
if re.match(self.fake_trap_files, src):
Reported by Pylint.
Line: 82
Column: 9
def setup(self):
FakeCCompilerOpt.conf_nocache = True
self._opt = None
def nopt(self, *args, **kwargs):
FakeCCompilerOpt.fake_info = (self.arch, self.cc, "")
return FakeCCompilerOpt(*args, **kwargs)
Reported by Pylint.
Line: 90
Column: 13
def opt(self):
if not self._opt:
self._opt = self.nopt()
return self._opt
def march(self):
return self.opt().cc_march
Reported by Pylint.
Line: 237
Column: 5
'flags "%s" not match "%s"' % (flags, match)
)
def expect_targets(self, targets, groups={}, **kwargs):
match = self.arg_regex(**kwargs)
if match is None:
return
targets, _ = self.get_targets(targets=targets, groups=groups, **kwargs)
targets = ' '.join(targets)
Reported by Pylint.
Line: 254
Column: 5
'targets "%s" not match "%s"' % (targets, match)
)
def expect_target_flags(self, targets, groups={}, **kwargs):
match_dict = self.arg_regex(**kwargs)
if match_dict is None:
return
assert(isinstance(match_dict, dict))
_, tar_flags = self.get_targets(targets=targets, groups=groups)
Reported by Pylint.
Line: 281
Column: 9
wrong_arch = "ppc64" if self.arch != "ppc64" else "x86"
wrong_cc = "clang" if self.cc != "clang" else "icc"
opt = self.opt()
assert_(getattr(opt, "cc_on_" + self.arch))
assert_(not getattr(opt, "cc_on_" + wrong_arch))
assert_(getattr(opt, "cc_is_" + self.cc))
assert_(not getattr(opt, "cc_is_" + wrong_cc))
def test_args_empty(self):
Reported by Pylint.
Line: 281
Column: 9
wrong_arch = "ppc64" if self.arch != "ppc64" else "x86"
wrong_cc = "clang" if self.cc != "clang" else "icc"
opt = self.opt()
assert_(getattr(opt, "cc_on_" + self.arch))
assert_(not getattr(opt, "cc_on_" + wrong_arch))
assert_(getattr(opt, "cc_is_" + self.cc))
assert_(not getattr(opt, "cc_is_" + wrong_cc))
def test_args_empty(self):
Reported by Pylint.
runtests.py
83 issues
Line: 233
Column: 9
# Debugging issues with warnings is much easier if you can see them
print("Enabling display of all warnings and pre-importing numpy as np")
import warnings; warnings.filterwarnings("always")
import IPython
import numpy as np
IPython.embed(colors='neutral', user_ns={"np": np})
sys.exit(0)
if args.shell:
Reported by Pylint.
Line: 138
Column: 5
parser.add_argument("--warn-error", action="store_true",
help="Set -Werror to convert all compiler warnings to "
"errors")
parser.add_argument("--cpu-baseline", default=None,
help="Specify a list of enabled baseline CPU "
"optimizations"),
parser.add_argument("--cpu-dispatch", default=None,
help="Specify a list of dispatched CPU optimizations"),
parser.add_argument("--disable-optimization", action="store_true",
Reported by Pylint.
Line: 141
Column: 5
parser.add_argument("--cpu-baseline", default=None,
help="Specify a list of enabled baseline CPU "
"optimizations"),
parser.add_argument("--cpu-dispatch", default=None,
help="Specify a list of dispatched CPU optimizations"),
parser.add_argument("--disable-optimization", action="store_true",
help="Disable CPU optimized code (dispatch, simd, "
"fast, ...)"),
parser.add_argument("--simd-test", default=None,
Reported by Pylint.
Line: 143
Column: 5
"optimizations"),
parser.add_argument("--cpu-dispatch", default=None,
help="Specify a list of dispatched CPU optimizations"),
parser.add_argument("--disable-optimization", action="store_true",
help="Disable CPU optimized code (dispatch, simd, "
"fast, ...)"),
parser.add_argument("--simd-test", default=None,
help="Specify a list of CPU optimizations to be "
"tested against NumPy SIMD interface"),
Reported by Pylint.
Line: 146
Column: 5
parser.add_argument("--disable-optimization", action="store_true",
help="Disable CPU optimized code (dispatch, simd, "
"fast, ...)"),
parser.add_argument("--simd-test", default=None,
help="Specify a list of CPU optimizations to be "
"tested against NumPy SIMD interface"),
parser.add_argument("--show-build-log", action="store_true",
help="Show build output rather than using a log file")
parser.add_argument("--bench", action="store_true",
Reported by Pylint.
Line: 222
Column: 13
sys.modules['__main__'] = types.ModuleType('__main__')
ns = dict(__name__='__main__',
__file__=extra_argv[0])
exec(script, ns)
sys.exit(0)
else:
import code
code.interact()
sys.exit(0)
Reported by Pylint.
Line: 222
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b102_exec_used.html
sys.modules['__main__'] = types.ModuleType('__main__')
ns = dict(__name__='__main__',
__file__=extra_argv[0])
exec(script, ns)
sys.exit(0)
else:
import code
code.interact()
sys.exit(0)
Reported by Bandit.
Line: 248
Column: 13
try:
import mypy.api
except ImportError:
raise RuntimeError(
"Mypy not found. Please install it by running "
"pip install -r test_requirements.txt from the repo root"
)
os.environ['MYPYPATH'] = site_dir
Reported by Pylint.
Line: 321
Column: 17
elif len(commits) == 2:
commit_a, commit_b = commits
else:
p.error("Too many commits to compare benchmarks for")
# Check for uncommitted files
if commit_b == 'HEAD':
r1 = subprocess.call(['git', 'diff-index', '--quiet',
'--cached', 'HEAD'])
Reported by Pylint.
Line: 577
Column: 3
"""
Force ASV to clear the cache according to specified commit hashes.
"""
# FIXME: only clear the cache from the current environment dir
asv_build_pattern = os.path.join(bench_path, env_dir, "*", "asv-build-cache")
for asv_build_cache in glob.glob(asv_build_pattern, recursive=True):
for c in h_commits:
try: shutil.rmtree(os.path.join(asv_build_cache, c))
except OSError: pass
Reported by Pylint.
numpy/distutils/ccompiler.py
82 issues
Line: 723
Column: 1
_distutils_new_compiler = new_compiler
def new_compiler (plat=None,
compiler=None,
verbose=None,
dry_run=0,
force=0):
# Try first C compilers from numpy.distutils.
Reported by Pylint.
Line: 770
Column: 1
ccompiler.new_compiler = new_compiler
_distutils_gen_lib_options = gen_lib_options
def gen_lib_options(compiler, library_dirs, runtime_library_dirs, libraries):
# the version of this function provided by CPython allows the following
# to return lists, which are unpacked automatically:
# - compiler.runtime_library_dir_option
# our version extends the behavior to:
# - compiler.library_dir_option
Reported by Pylint.
Line: 88
Column: 9
def replace_method(klass, method_name, func):
# Py3k does not have unbound method anymore, MethodType does not work
m = lambda self, *args, **kw: func(self, *args, **kw)
setattr(klass, method_name, m)
######################################################################
## Method that subclasses may redefine. But don't call this method,
Reported by Pylint.
Line: 97
Column: 32
## it i private to CCompiler class and may return unexpected
## results if used elsewhere. So, you have been warned..
def CCompiler_find_executables(self):
"""
Does nothing here, but is called by the get_version method and can be
overridden by subclasses. In particular it is redefined in the `FCompiler`
class where more documentation can be found.
Reported by Pylint.
Line: 104
Column: 5
class where more documentation can be found.
"""
pass
replace_method(CCompiler, 'find_executables', CCompiler_find_executables)
Reported by Pylint.
Line: 264
Column: 5
# This method is effective only with Python >=2.3 distutils.
# Any changes here should be applied also to fcompiler.compile
# method to support pre Python 2.3 distutils.
global _job_semaphore
jobs = get_num_build_jobs()
# setup semaphore to not exceed number of compile jobs when parallelized at
# extension level (python >= 3.5)
Reported by Pylint.
Line: 291
Column: 13
display = "C compiler: %s\n" % (' '.join(ccomp),)
log.info(display)
macros, objects, extra_postargs, pp_opts, build = \
self._setup_compile(output_dir, macros, include_dirs, sources,
depends, extra_postargs)
cc_args = self._get_cc_args(pp_opts, debug, extra_preargs)
display = "compile options: '%s'" % (' '.join(cc_args))
if extra_postargs:
display += "\nextra options: '%s'" % (' '.join(extra_postargs))
Reported by Pylint.
Line: 293
Column: 15
macros, objects, extra_postargs, pp_opts, build = \
self._setup_compile(output_dir, macros, include_dirs, sources,
depends, extra_postargs)
cc_args = self._get_cc_args(pp_opts, debug, extra_preargs)
display = "compile options: '%s'" % (' '.join(cc_args))
if extra_postargs:
display += "\nextra options: '%s'" % (' '.join(extra_postargs))
log.info(display)
Reported by Pylint.
Line: 319
Column: 17
try:
# retrieve slot from our #job semaphore and build
with _job_semaphore:
self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
finally:
# register being done processing
with _global_lock:
_processing_files.remove(obj)
Reported by Pylint.
Line: 453
Column: 12
"""
try:
self.get_version()
except Exception:
pass
if log._global_log.threshold<2:
print('*'*80)
print(self.__class__)
print(_compiler_to_string(self))
Reported by Pylint.