The following issues were found

numpy/core/overrides.py
8 issues
Unable to import 'numpy.core._multiarray_umath'
Error

Line: 7 Column: 1

              import os
import textwrap

from numpy.core._multiarray_umath import (
    add_docstring, implement_array_function, _get_implementing_args)
from numpy.compat._inspect import getargspec


ARRAY_FUNCTION_ENABLED = bool(

            

Reported by Pylint.

function already defined line 175
Error

Line: 183 Column: 5

                          return implementation
        return decorator

    def decorator(implementation):
        if verify:
            verify_matching_signatures(implementation, dispatcher)

        if docs_from_dispatcher:
            add_docstring(implementation, dispatcher.__doc__)

            

Reported by Pylint.

Use of exec detected.
Security

Line: 205
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b102_exec_used.html

                          'functools': functools,
            'implement_array_function': implement_array_function,
        }
        exec(source_object, scope)

        public_api = scope[implementation.__name__]

        if module is not None:
            public_api.__module__ = module

            

Reported by Bandit.

Use of exec
Error

Line: 205 Column: 9

                          'functools': functools,
            'implement_array_function': implement_array_function,
        }
        exec(source_object, scope)

        public_api = scope[implementation.__name__]

        if module is not None:
            public_api.__module__ = module

            

Reported by Pylint.

Access to a protected member _implementation of a client class
Error

Line: 212 Column: 9

                      if module is not None:
            public_api.__module__ = module

        public_api._implementation = implementation

        return public_api

    return decorator


            

Reported by Pylint.

Constant name "array_function_like_doc" doesn't conform to UPPER_CASE naming style
Error

Line: 15 Column: 1

              ARRAY_FUNCTION_ENABLED = bool(
    int(os.environ.get('NUMPY_EXPERIMENTAL_ARRAY_FUNCTION', 1)))

array_function_like_doc = (
    """like : array_like
        Reference object to allow the creation of arrays which are not
        NumPy arrays. If an array-like passed in as ``like`` supports
        the ``__array_function__`` protocol, the result will be defined
        by it. In this case, it ensures the creation of an array object

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 24 Column: 1

                      compatible with that passed in via this argument."""
)

def set_array_function_like_doc(public_api):
    if public_api.__doc__ is not None:
        public_api.__doc__ = public_api.__doc__.replace(
            "${ARRAY_FUNCTION_LIKE}",
            array_function_like_doc,
        )

            

Reported by Pylint.

Too many boolean expressions in if statement (6/5)
Error

Line: 94 Column: 9

                  implementation_spec = ArgSpec(*getargspec(implementation))
    dispatcher_spec = ArgSpec(*getargspec(dispatcher))

    if (implementation_spec.args != dispatcher_spec.args or
            implementation_spec.varargs != dispatcher_spec.varargs or
            implementation_spec.keywords != dispatcher_spec.keywords or
            (bool(implementation_spec.defaults) !=
             bool(dispatcher_spec.defaults)) or
            (implementation_spec.defaults is not None and

            

Reported by Pylint.

numpy/typing/tests/data/reveal/nditer.py
8 issues
Undefined variable 'reveal_type'
Error

Line: 7 Column: 5

              nditer_obj: np.nditer

with nditer_obj as context:
    reveal_type(context)   # E: numpy.nditer

reveal_type(len(nditer_obj))  # E: builtins.int
reveal_type(copy.copy(nditer_obj))  # E: numpy.nditer
reveal_type(next(nditer_obj))  # E: Any
reveal_type(iter(nditer_obj))  # E: typing.Iterator[Any]

            

Reported by Pylint.

Undefined variable 'reveal_type'
Error

Line: 9 Column: 1

              with nditer_obj as context:
    reveal_type(context)   # E: numpy.nditer

reveal_type(len(nditer_obj))  # E: builtins.int
reveal_type(copy.copy(nditer_obj))  # E: numpy.nditer
reveal_type(next(nditer_obj))  # E: Any
reveal_type(iter(nditer_obj))  # E: typing.Iterator[Any]
reveal_type(nditer_obj[1])  # E: Any
reveal_type(nditer_obj[1:5])  # E: Any

            

Reported by Pylint.

Undefined variable 'reveal_type'
Error

Line: 10 Column: 1

                  reveal_type(context)   # E: numpy.nditer

reveal_type(len(nditer_obj))  # E: builtins.int
reveal_type(copy.copy(nditer_obj))  # E: numpy.nditer
reveal_type(next(nditer_obj))  # E: Any
reveal_type(iter(nditer_obj))  # E: typing.Iterator[Any]
reveal_type(nditer_obj[1])  # E: Any
reveal_type(nditer_obj[1:5])  # E: Any


            

Reported by Pylint.

Undefined variable 'reveal_type'
Error

Line: 11 Column: 1

              
reveal_type(len(nditer_obj))  # E: builtins.int
reveal_type(copy.copy(nditer_obj))  # E: numpy.nditer
reveal_type(next(nditer_obj))  # E: Any
reveal_type(iter(nditer_obj))  # E: typing.Iterator[Any]
reveal_type(nditer_obj[1])  # E: Any
reveal_type(nditer_obj[1:5])  # E: Any

nditer_obj[1] = 1

            

Reported by Pylint.

Undefined variable 'reveal_type'
Error

Line: 12 Column: 1

              reveal_type(len(nditer_obj))  # E: builtins.int
reveal_type(copy.copy(nditer_obj))  # E: numpy.nditer
reveal_type(next(nditer_obj))  # E: Any
reveal_type(iter(nditer_obj))  # E: typing.Iterator[Any]
reveal_type(nditer_obj[1])  # E: Any
reveal_type(nditer_obj[1:5])  # E: Any

nditer_obj[1] = 1
nditer_obj[1:5] = 1

            

Reported by Pylint.

Undefined variable 'reveal_type'
Error

Line: 13 Column: 1

              reveal_type(copy.copy(nditer_obj))  # E: numpy.nditer
reveal_type(next(nditer_obj))  # E: Any
reveal_type(iter(nditer_obj))  # E: typing.Iterator[Any]
reveal_type(nditer_obj[1])  # E: Any
reveal_type(nditer_obj[1:5])  # E: Any

nditer_obj[1] = 1
nditer_obj[1:5] = 1
del nditer_obj[1]

            

Reported by Pylint.

Undefined variable 'reveal_type'
Error

Line: 14 Column: 1

              reveal_type(next(nditer_obj))  # E: Any
reveal_type(iter(nditer_obj))  # E: typing.Iterator[Any]
reveal_type(nditer_obj[1])  # E: Any
reveal_type(nditer_obj[1:5])  # E: Any

nditer_obj[1] = 1
nditer_obj[1:5] = 1
del nditer_obj[1]
del nditer_obj[1:5]

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import copy
import numpy as np

nditer_obj: np.nditer

with nditer_obj as context:
    reveal_type(context)   # E: numpy.nditer

reveal_type(len(nditer_obj))  # E: builtins.int

            

Reported by Pylint.

numpy/distutils/fcompiler/lahey.py
8 issues
Method 'wrap_unlinkable_objects' is abstract in class 'FCompiler' but is not overridden
Error

Line: 7 Column: 1

              
compilers = ['LaheyFCompiler']

class LaheyFCompiler(FCompiler):

    compiler_type = 'lahey'
    description = 'Lahey/Fujitsu Fortran 95 Compiler'
    version_pattern =  r'Lahey/Fujitsu Fortran 95 Compiler Release (?P<version>[^\s*]*)'


            

Reported by Pylint.

Method 'find_library_file' is abstract in class 'CCompiler' but is not overridden
Error

Line: 7 Column: 1

              
compilers = ['LaheyFCompiler']

class LaheyFCompiler(FCompiler):

    compiler_type = 'lahey'
    description = 'Lahey/Fujitsu Fortran 95 Compiler'
    version_pattern =  r'Lahey/Fujitsu Fortran 95 Compiler Release (?P<version>[^\s*]*)'


            

Reported by Pylint.

Method 'runtime_library_dir_option' is abstract in class 'CCompiler' but is not overridden
Error

Line: 7 Column: 1

              
compilers = ['LaheyFCompiler']

class LaheyFCompiler(FCompiler):

    compiler_type = 'lahey'
    description = 'Lahey/Fujitsu Fortran 95 Compiler'
    version_pattern =  r'Lahey/Fujitsu Fortran 95 Compiler Release (?P<version>[^\s*]*)'


            

Reported by Pylint.

XXX Fix me
Error

Line: 23 Column: 2

                      'ranlib'       : ["ranlib"]
        }

    module_dir_switch = None  #XXX Fix me
    module_include_switch = None #XXX Fix me

    def get_flags_opt(self):
        return ['-O']
    def get_flags_debug(self):

            

Reported by Pylint.

XXX Fix me
Error

Line: 24 Column: 2

                      }

    module_dir_switch = None  #XXX Fix me
    module_include_switch = None #XXX Fix me

    def get_flags_opt(self):
        return ['-O']
    def get_flags_debug(self):
        return ['-g', '--chk', '--chkglobal']

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import os

from numpy.distutils.fcompiler import FCompiler

compilers = ['LaheyFCompiler']

class LaheyFCompiler(FCompiler):

    compiler_type = 'lahey'

            

Reported by Pylint.

Missing class docstring
Error

Line: 7 Column: 1

              
compilers = ['LaheyFCompiler']

class LaheyFCompiler(FCompiler):

    compiler_type = 'lahey'
    description = 'Lahey/Fujitsu Fortran 95 Compiler'
    version_pattern =  r'Lahey/Fujitsu Fortran 95 Compiler Release (?P<version>[^\s*]*)'


            

Reported by Pylint.

Variable name "d" doesn't conform to snake_case naming style
Error

Line: 32 Column: 9

                      return ['-g', '--chk', '--chkglobal']
    def get_library_dirs(self):
        opt = []
        d = os.environ.get('LAHEY')
        if d:
            opt.append(os.path.join(d, 'lib'))
        return opt
    def get_libraries(self):
        opt = []

            

Reported by Pylint.

numpy/core/_type_aliases.py
8 issues
Redefining name 'name' from outer scope (line 229)
Error

Line: 75 Column: 9

              

def _add_types():
    for name, info in _concrete_typeinfo.items():
        # define C-name and insert typenum and typechar references also
        allTypes[name] = info.type
        sctypeDict[name] = info.type
        sctypeDict[info.char] = info.type
        sctypeDict[info.num] = info.type

            

Reported by Pylint.

Redefining name 'name' from outer scope (line 229)
Error

Line: 95 Column: 9

              _uint_ctypes = list('u' + t for t in _int_ctypes)

def _add_aliases():
    for name, info in _concrete_typeinfo.items():
        # these are handled by _add_integer_aliases
        if name in _int_ctypes or name in _uint_ctypes:
            continue

        # insert bit-width version for this class (if relevant)

            

Reported by Pylint.

Redefining built-in 'bytes'
Error

Line: 205 Column: 9

              def _set_array_types():
    ibytes = [1, 2, 4, 8, 16, 32, 64]
    fbytes = [2, 4, 8, 10, 12, 16, 32, 64]
    for bytes in ibytes:
        bits = 8*bytes
        _add_array_type('int', bits)
        _add_array_type('uint', bits)
    for bytes in fbytes:
        bits = 8*bytes

            

Reported by Pylint.

Variable name "dt" doesn't conform to snake_case naming style
Error

Line: 61 Column: 5

              def bitname(obj):
    """Return a bit-width name for a given type object"""
    bits = _bits_of(obj)
    dt = dtype(obj)
    char = dt.kind
    base = _kind_name(dt)

    if base == 'object':
        bits = 0

            

Reported by Pylint.

Variable name "t" doesn't conform to snake_case naming style
Error

Line: 171 Column: 16

                                ('str_', 'unicode'),
                  ('unicode_', 'unicode'),
                  ('object_', 'object')]
    for alias, t in type_pairs:
        allTypes[alias] = allTypes[t]
        sctypeDict[alias] = sctypeDict[t]
    # Remove aliases overriding python types and modules
    to_remove = ['ulong', 'object', 'int', 'float',
                 'complex', 'bool', 'string', 'datetime', 'timedelta',

            

Reported by Pylint.

Variable name "t" doesn't conform to snake_case naming style
Error

Line: 179 Column: 9

                               'complex', 'bool', 'string', 'datetime', 'timedelta',
                 'bytes', 'str']

    for t in to_remove:
        try:
            del allTypes[t]
            del sctypeDict[t]
        except KeyError:
            pass

            

Reported by Pylint.

Variable name "t" doesn't conform to snake_case naming style
Error

Line: 196 Column: 9

              
def _add_array_type(typename, bits):
    try:
        t = allTypes['%s%d' % (typename, bits)]
    except KeyError:
        pass
    else:
        sctypes[typename].append(t)


            

Reported by Pylint.

Variable name "sz" doesn't conform to snake_case naming style
Error

Line: 216 Column: 9

                  _gi = dtype('p')
    if _gi.type not in sctypes['int']:
        indx = 0
        sz = _gi.itemsize
        _lst = sctypes['int']
        while (indx < len(_lst) and sz >= _lst[indx](0).itemsize):
            indx += 1
        sctypes['int'].insert(indx, _gi.type)
        sctypes['uint'].insert(indx, dtype('P').type)

            

Reported by Pylint.

numpy/matrixlib/tests/test_numeric.py
8 issues
Missing module docstring
Error

Line: 1 Column: 1

              import numpy as np
from numpy.testing import assert_equal

class TestDot:
    def test_matscalar(self):
        b1 = np.matrix(np.ones((3, 3), dtype=complex))
        assert_equal(b1*1.0, b1)



            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 4 Column: 1

              import numpy as np
from numpy.testing import assert_equal

class TestDot:
    def test_matscalar(self):
        b1 = np.matrix(np.ones((3, 3), dtype=complex))
        assert_equal(b1*1.0, b1)



            

Reported by Pylint.

Missing class docstring
Error

Line: 4 Column: 1

              import numpy as np
from numpy.testing import assert_equal

class TestDot:
    def test_matscalar(self):
        b1 = np.matrix(np.ones((3, 3), dtype=complex))
        assert_equal(b1*1.0, b1)



            

Reported by Pylint.

Method could be a function
Error

Line: 5 Column: 5

              from numpy.testing import assert_equal

class TestDot:
    def test_matscalar(self):
        b1 = np.matrix(np.ones((3, 3), dtype=complex))
        assert_equal(b1*1.0, b1)


def test_diagonal():

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 5 Column: 5

              from numpy.testing import assert_equal

class TestDot:
    def test_matscalar(self):
        b1 = np.matrix(np.ones((3, 3), dtype=complex))
        assert_equal(b1*1.0, b1)


def test_diagonal():

            

Reported by Pylint.

Variable name "b1" doesn't conform to snake_case naming style
Error

Line: 6 Column: 9

              
class TestDot:
    def test_matscalar(self):
        b1 = np.matrix(np.ones((3, 3), dtype=complex))
        assert_equal(b1*1.0, b1)


def test_diagonal():
    b1 = np.matrix([[1,2],[3,4]])

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 10 Column: 1

                      assert_equal(b1*1.0, b1)


def test_diagonal():
    b1 = np.matrix([[1,2],[3,4]])
    diag_b1 = np.matrix([[1, 4]])
    array_b1 = np.array([1, 4])

    assert_equal(b1.diagonal(), diag_b1)

            

Reported by Pylint.

Variable name "b1" doesn't conform to snake_case naming style
Error

Line: 11 Column: 5

              

def test_diagonal():
    b1 = np.matrix([[1,2],[3,4]])
    diag_b1 = np.matrix([[1, 4]])
    array_b1 = np.array([1, 4])

    assert_equal(b1.diagonal(), diag_b1)
    assert_equal(np.diagonal(b1), array_b1)

            

Reported by Pylint.

numpy/typing/tests/data/fail/testing.py
8 issues
Module 'numpy.typing' has no 'NDArray' member
Error

Line: 4 Column: 7

              import numpy as np
import numpy.typing as npt

AR_U: npt.NDArray[np.str_]

def func() -> bool: ...

np.testing.assert_(True, msg=1)  # E: incompatible type
np.testing.build_err_msg(1, "test")  # E: incompatible type

            

Reported by Pylint.

No value for argument 'expected_regexp' in function call
Error

Line: 17 Column: 1

              np.testing.assert_string_equal(b"a", b"a")  # E: incompatible type

np.testing.assert_raises(expected_exception=TypeError, callable=func)  # E: No overload variant
np.testing.assert_raises_regex(expected_exception=TypeError, expected_regex="T", callable=func)  # E: No overload variant

np.testing.assert_allclose(AR_U, AR_U)  # E: incompatible type
np.testing.assert_array_almost_equal_nulp(AR_U, AR_U)  # E: incompatible type
np.testing.assert_array_max_ulp(AR_U, AR_U)  # E: incompatible type


            

Reported by Pylint.

No value for argument 'exception_class' in function call
Error

Line: 17 Column: 1

              np.testing.assert_string_equal(b"a", b"a")  # E: incompatible type

np.testing.assert_raises(expected_exception=TypeError, callable=func)  # E: No overload variant
np.testing.assert_raises_regex(expected_exception=TypeError, expected_regex="T", callable=func)  # E: No overload variant

np.testing.assert_allclose(AR_U, AR_U)  # E: incompatible type
np.testing.assert_array_almost_equal_nulp(AR_U, AR_U)  # E: incompatible type
np.testing.assert_array_max_ulp(AR_U, AR_U)  # E: incompatible type


            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 8 Column: 1

              
def func() -> bool: ...

np.testing.assert_(True, msg=1)  # E: incompatible type
np.testing.build_err_msg(1, "test")  # E: incompatible type
np.testing.assert_almost_equal(AR_U, AR_U)  # E: incompatible type
np.testing.assert_approx_equal([1, 2, 3], [1, 2, 3])  # E: incompatible type
np.testing.assert_array_almost_equal(AR_U, AR_U)  # E: incompatible type
np.testing.assert_array_less(AR_U, AR_U)  # E: incompatible type

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import numpy as np
import numpy.typing as npt

AR_U: npt.NDArray[np.str_]

def func() -> bool: ...

np.testing.assert_(True, msg=1)  # E: incompatible type
np.testing.build_err_msg(1, "test")  # E: incompatible type

            

Reported by Pylint.

More than one statement on a single line
Error

Line: 6 Column: 21

              
AR_U: npt.NDArray[np.str_]

def func() -> bool: ...

np.testing.assert_(True, msg=1)  # E: incompatible type
np.testing.build_err_msg(1, "test")  # E: incompatible type
np.testing.assert_almost_equal(AR_U, AR_U)  # E: incompatible type
np.testing.assert_approx_equal([1, 2, 3], [1, 2, 3])  # E: incompatible type

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 6 Column: 1

              
AR_U: npt.NDArray[np.str_]

def func() -> bool: ...

np.testing.assert_(True, msg=1)  # E: incompatible type
np.testing.build_err_msg(1, "test")  # E: incompatible type
np.testing.assert_almost_equal(AR_U, AR_U)  # E: incompatible type
np.testing.assert_approx_equal([1, 2, 3], [1, 2, 3])  # E: incompatible type

            

Reported by Pylint.

Line too long (121/100)
Error

Line: 17 Column: 1

              np.testing.assert_string_equal(b"a", b"a")  # E: incompatible type

np.testing.assert_raises(expected_exception=TypeError, callable=func)  # E: No overload variant
np.testing.assert_raises_regex(expected_exception=TypeError, expected_regex="T", callable=func)  # E: No overload variant

np.testing.assert_allclose(AR_U, AR_U)  # E: incompatible type
np.testing.assert_array_almost_equal_nulp(AR_U, AR_U)  # E: incompatible type
np.testing.assert_array_max_ulp(AR_U, AR_U)  # E: incompatible type


            

Reported by Pylint.

numpy/typing/tests/data/fail/arrayterator.py
8 issues
Value 'np.ndarray' is unsubscriptable
Error

Line: 4 Column: 8

              from typing import Any
import numpy as np

AR_i8: np.ndarray[Any, np.dtype[np.int64]]
ar_iter = np.lib.Arrayterator(AR_i8)

np.lib.Arrayterator(np.int64())  # E: incompatible type
ar_iter.shape = (10, 5)  # E: is read-only
ar_iter[None]  # E: Invalid index type

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 9 Column: 1

              
np.lib.Arrayterator(np.int64())  # E: incompatible type
ar_iter.shape = (10, 5)  # E: is read-only
ar_iter[None]  # E: Invalid index type
ar_iter[None, 1]  # E: Invalid index type
ar_iter[np.intp()]  # E: Invalid index type
ar_iter[np.intp(), ...]  # E: Invalid index type
ar_iter[AR_i8]  # E: Invalid index type
ar_iter[AR_i8, :]  # E: Invalid index type

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 10 Column: 1

              np.lib.Arrayterator(np.int64())  # E: incompatible type
ar_iter.shape = (10, 5)  # E: is read-only
ar_iter[None]  # E: Invalid index type
ar_iter[None, 1]  # E: Invalid index type
ar_iter[np.intp()]  # E: Invalid index type
ar_iter[np.intp(), ...]  # E: Invalid index type
ar_iter[AR_i8]  # E: Invalid index type
ar_iter[AR_i8, :]  # E: Invalid index type

            

Reported by Pylint.

Expression "ar_iter[np.intp()]" is assigned to nothing
Error

Line: 11 Column: 1

              ar_iter.shape = (10, 5)  # E: is read-only
ar_iter[None]  # E: Invalid index type
ar_iter[None, 1]  # E: Invalid index type
ar_iter[np.intp()]  # E: Invalid index type
ar_iter[np.intp(), ...]  # E: Invalid index type
ar_iter[AR_i8]  # E: Invalid index type
ar_iter[AR_i8, :]  # E: Invalid index type

            

Reported by Pylint.

Expression "ar_iter[np.intp(), ...]" is assigned to nothing
Error

Line: 12 Column: 1

              ar_iter[None]  # E: Invalid index type
ar_iter[None, 1]  # E: Invalid index type
ar_iter[np.intp()]  # E: Invalid index type
ar_iter[np.intp(), ...]  # E: Invalid index type
ar_iter[AR_i8]  # E: Invalid index type
ar_iter[AR_i8, :]  # E: Invalid index type

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 13 Column: 1

              ar_iter[None, 1]  # E: Invalid index type
ar_iter[np.intp()]  # E: Invalid index type
ar_iter[np.intp(), ...]  # E: Invalid index type
ar_iter[AR_i8]  # E: Invalid index type
ar_iter[AR_i8, :]  # E: Invalid index type

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 14 Column: 1

              ar_iter[np.intp()]  # E: Invalid index type
ar_iter[np.intp(), ...]  # E: Invalid index type
ar_iter[AR_i8]  # E: Invalid index type
ar_iter[AR_i8, :]  # E: Invalid index type

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from typing import Any
import numpy as np

AR_i8: np.ndarray[Any, np.dtype[np.int64]]
ar_iter = np.lib.Arrayterator(AR_i8)

np.lib.Arrayterator(np.int64())  # E: incompatible type
ar_iter.shape = (10, 5)  # E: is read-only
ar_iter[None]  # E: Invalid index type

            

Reported by Pylint.

tools/find_deprecated_escaped_characters.py
8 issues
Unused variable 'tree'
Error

Line: 46 Column: 17

                      with tokenize.open(str(path)) as f:
            with warnings.catch_warnings(record=True) as w:
                warnings.simplefilter('always')
                tree = ast.parse(f.read())
            if w:
                print("file: ", str(path))
                for e in w:
                    print('line: ', e.lineno, ': ', e.message)
                print()

            

Reported by Pylint.

Import outside toplevel (ast)
Error

Line: 32 Column: 5

                  None

    """
    import ast
    import tokenize
    import warnings
    from pathlib import Path

    count = 0

            

Reported by Pylint.

Import outside toplevel (tokenize)
Error

Line: 33 Column: 5

              
    """
    import ast
    import tokenize
    import warnings
    from pathlib import Path

    count = 0
    base = Path(root)

            

Reported by Pylint.

Import outside toplevel (warnings)
Error

Line: 34 Column: 5

                  """
    import ast
    import tokenize
    import warnings
    from pathlib import Path

    count = 0
    base = Path(root)
    paths = base.rglob("*.py") if base.is_dir() else [base]

            

Reported by Pylint.

Import outside toplevel (pathlib.Path)
Error

Line: 35 Column: 5

                  import ast
    import tokenize
    import warnings
    from pathlib import Path

    count = 0
    base = Path(root)
    paths = base.rglob("*.py") if base.is_dir() else [base]
    for path in paths:

            

Reported by Pylint.

Variable name "f" doesn't conform to snake_case naming style
Error

Line: 43 Column: 42

                  for path in paths:
        # use tokenize to auto-detect encoding on systems where no
        # default encoding is defined (e.g. LANG='C')
        with tokenize.open(str(path)) as f:
            with warnings.catch_warnings(record=True) as w:
                warnings.simplefilter('always')
                tree = ast.parse(f.read())
            if w:
                print("file: ", str(path))

            

Reported by Pylint.

Variable name "w" doesn't conform to snake_case naming style
Error

Line: 44 Column: 58

                      # use tokenize to auto-detect encoding on systems where no
        # default encoding is defined (e.g. LANG='C')
        with tokenize.open(str(path)) as f:
            with warnings.catch_warnings(record=True) as w:
                warnings.simplefilter('always')
                tree = ast.parse(f.read())
            if w:
                print("file: ", str(path))
                for e in w:

            

Reported by Pylint.

Variable name "e" doesn't conform to snake_case naming style
Error

Line: 49 Column: 21

                              tree = ast.parse(f.read())
            if w:
                print("file: ", str(path))
                for e in w:
                    print('line: ', e.lineno, ': ', e.message)
                print()
                count += len(w)
    print("Errors Found", count)


            

Reported by Pylint.

numpy/distutils/tests/test_mingw32ccompiler.py
8 issues
Unable to import 'pytest'
Error

Line: 4 Column: 1

              import shutil
import subprocess
import sys
import pytest

from numpy.distutils import mingw32ccompiler


@pytest.mark.skipif(sys.platform != 'win32', reason='win32 only test')

            

Reported by Pylint.

Access to a protected member _check_for_import_lib of a client class
Error

Line: 32 Column: 32

                                       "dlls when using 64-bit python. Supported "
                         "formats: '%s'" % supported)
    # Hide the import library to force a build
    has_import_lib, fullpath = mingw32ccompiler._check_for_import_lib()
    if has_import_lib: 
        shutil.move(fullpath, fullpath + '.bak')

    try: 
        # Whew, now we can actually test the function

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import shutil
import subprocess
import sys
import pytest

from numpy.distutils import mingw32ccompiler


@pytest.mark.skipif(sys.platform != 'win32', reason='win32 only test')

            

Reported by Pylint.

Consider possible security implications associated with subprocess module.
Security blacklist

Line: 2
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_imports.html#b404-import-subprocess

              import shutil
import subprocess
import sys
import pytest

from numpy.distutils import mingw32ccompiler


@pytest.mark.skipif(sys.platform != 'win32', reason='win32 only test')

            

Reported by Bandit.

subprocess call - check for execution of untrusted input.
Security injection

Line: 18
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b603_subprocess_without_shell_equals_true.html

                  # make sure `nm.exe` exists and supports the current python version. This
    # can get mixed up when the PATH has a 64-bit nm but the python is 32-bit
    try:
        out = subprocess.check_output(['nm.exe', '--help'])
    except FileNotFoundError:
        pytest.skip("'nm.exe' not on path, is mingw installed?")
    supported = out[out.find(b'supported targets:'):]
    if sys.maxsize < 2**32:
        if b'pe-i386' not in supported:

            

Reported by Bandit.

Starting a process with a partial executable path
Security injection

Line: 18
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b607_start_process_with_partial_path.html

                  # make sure `nm.exe` exists and supports the current python version. This
    # can get mixed up when the PATH has a 64-bit nm but the python is 32-bit
    try:
        out = subprocess.check_output(['nm.exe', '--help'])
    except FileNotFoundError:
        pytest.skip("'nm.exe' not on path, is mingw installed?")
    supported = out[out.find(b'supported targets:'):]
    if sys.maxsize < 2**32:
        if b'pe-i386' not in supported:

            

Reported by Bandit.

Trailing whitespace
Error

Line: 33 Column: 23

                                       "formats: '%s'" % supported)
    # Hide the import library to force a build
    has_import_lib, fullpath = mingw32ccompiler._check_for_import_lib()
    if has_import_lib: 
        shutil.move(fullpath, fullpath + '.bak')

    try: 
        # Whew, now we can actually test the function
        mingw32ccompiler.build_import_library()

            

Reported by Pylint.

Trailing whitespace
Error

Line: 36 Column: 9

                  if has_import_lib: 
        shutil.move(fullpath, fullpath + '.bak')

    try: 
        # Whew, now we can actually test the function
        mingw32ccompiler.build_import_library()

    finally:
        if has_import_lib:

            

Reported by Pylint.

numpy/core/_ufunc_config.py
8 issues
Attempted relative import beyond top-level package
Error

Line: 9 Column: 1

              import collections.abc
import contextlib

from .overrides import set_module
from .umath import (
    UFUNC_BUFSIZE_DEFAULT,
    ERR_IGNORE, ERR_WARN, ERR_RAISE, ERR_CALL, ERR_PRINT, ERR_LOG, ERR_DEFAULT,
    SHIFT_DIVIDEBYZERO, SHIFT_OVERFLOW, SHIFT_UNDERFLOW, SHIFT_INVALID,
)

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 10 Column: 1

              import contextlib

from .overrides import set_module
from .umath import (
    UFUNC_BUFSIZE_DEFAULT,
    ERR_IGNORE, ERR_WARN, ERR_RAISE, ERR_CALL, ERR_PRINT, ERR_LOG, ERR_DEFAULT,
    SHIFT_DIVIDEBYZERO, SHIFT_OVERFLOW, SHIFT_UNDERFLOW, SHIFT_INVALID,
)
from . import umath

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 15 Column: 1

                  ERR_IGNORE, ERR_WARN, ERR_RAISE, ERR_CALL, ERR_PRINT, ERR_LOG, ERR_DEFAULT,
    SHIFT_DIVIDEBYZERO, SHIFT_OVERFLOW, SHIFT_UNDERFLOW, SHIFT_INVALID,
)
from . import umath

__all__ = [
    "seterr", "geterr", "setbufsize", "getbufsize", "seterrcall", "geterrcall",
    "errstate",
]

            

Reported by Pylint.

Redefining built-in 'all'
Error

Line: 33 Column: 12

              

@set_module('numpy')
def seterr(all=None, divide=None, over=None, under=None, invalid=None):
    """
    Set how floating-point errors are handled.

    Note that operations on integer scalar types (such as `int16`) are
    handled like floating point, and are affected by these settings.

            

Reported by Pylint.

Attribute 'oldstate' defined outside __init__
Error

Line: 430 Column: 9

                      self.kwargs = kwargs

    def __enter__(self):
        self.oldstate = seterr(**self.kwargs)
        if self.call is not _Unspecified:
            self.oldcall = seterrcall(self.call)

    def __exit__(self, *exc_info):
        seterr(**self.oldstate)

            

Reported by Pylint.

Attribute 'oldcall' defined outside __init__
Error

Line: 432 Column: 13

                  def __enter__(self):
        self.oldstate = seterr(**self.kwargs)
        if self.call is not _Unspecified:
            self.oldcall = seterrcall(self.call)

    def __exit__(self, *exc_info):
        seterr(**self.oldstate)
        if self.call is not _Unspecified:
            seterrcall(self.oldcall)

            

Reported by Pylint.

Too few public methods (0/2)
Error

Line: 359 Column: 1

                  return umath.geterrobj()[2]


class _unspecified:
    pass


_Unspecified = _unspecified()


            

Reported by Pylint.

Class name "errstate" doesn't conform to PascalCase naming style
Error

Line: 367 Column: 1

              

@set_module('numpy')
class errstate(contextlib.ContextDecorator):
    """
    errstate(**kwargs)

    Context manager for floating-point error handling.


            

Reported by Pylint.