The following issues were found

numpy/typing/_dtype_like.py
17 issues
Attempted relative import beyond top-level package
Error

Line: 6 Column: 1

              
import numpy as np

from . import _HAS_TYPING_EXTENSIONS
from ._shape import _ShapeLike
from ._generic_alias import _DType as DType

if sys.version_info >= (3, 8):
    from typing import Protocol, TypedDict

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 7 Column: 1

              import numpy as np

from . import _HAS_TYPING_EXTENSIONS
from ._shape import _ShapeLike
from ._generic_alias import _DType as DType

if sys.version_info >= (3, 8):
    from typing import Protocol, TypedDict
elif _HAS_TYPING_EXTENSIONS:

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 8 Column: 1

              
from . import _HAS_TYPING_EXTENSIONS
from ._shape import _ShapeLike
from ._generic_alias import _DType as DType

if sys.version_info >= (3, 8):
    from typing import Protocol, TypedDict
elif _HAS_TYPING_EXTENSIONS:
    from typing_extensions import Protocol, TypedDict

            

Reported by Pylint.

Unable to import 'typing_extensions'
Error

Line: 13 Column: 5

              if sys.version_info >= (3, 8):
    from typing import Protocol, TypedDict
elif _HAS_TYPING_EXTENSIONS:
    from typing_extensions import Protocol, TypedDict
else:
    from ._generic_alias import _GenericAlias as GenericAlias

from ._char_codes import (
    _BoolCodes,

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 15 Column: 5

              elif _HAS_TYPING_EXTENSIONS:
    from typing_extensions import Protocol, TypedDict
else:
    from ._generic_alias import _GenericAlias as GenericAlias

from ._char_codes import (
    _BoolCodes,
    _UInt8Codes,
    _UInt16Codes,

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 17 Column: 1

              else:
    from ._generic_alias import _GenericAlias as GenericAlias

from ._char_codes import (
    _BoolCodes,
    _UInt8Codes,
    _UInt16Codes,
    _UInt32Codes,
    _UInt64Codes,

            

Reported by Pylint.

TODO: wait for support for recursive types
Error

Line: 59 Column: 3

                  _ObjectCodes,
)

_DTypeLikeNested = Any  # TODO: wait for support for recursive types
_DType_co = TypeVar("_DType_co", covariant=True, bound=DType[Any])

if TYPE_CHECKING or _HAS_TYPING_EXTENSIONS or sys.version_info >= (3, 8):
    # Mandatory keys
    class _DTypeDictBase(TypedDict):

            

Reported by Pylint.

TODO: enumerate these when we add type hints for numpy scalars
Error

Line: 113 Column: 3

                  # default data type (float64)
    None,
    # array-scalar types and generic types
    Type[Any],  # TODO: enumerate these when we add type hints for numpy scalars
    # anything with a dtype attribute
    _SupportsDType[DType[Any]],
    # character codes, type strings or comma-separated fields, e.g., 'float64'
    str,
    _VoidDTypeLike,

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import sys
from typing import Any, List, Sequence, Tuple, Union, Type, TypeVar, TYPE_CHECKING

import numpy as np

from . import _HAS_TYPING_EXTENSIONS
from ._shape import _ShapeLike
from ._generic_alias import _DType as DType


            

Reported by Pylint.

Import "from ._char_codes import _BoolCodes, _UInt8Codes, _UInt16Codes, _UInt32Codes, _UInt64Codes, _Int8Codes, _Int16Codes, _Int32Codes, _Int64Codes, _Float16Codes, _Float32Codes, _Float64Codes, _Complex64Codes, _Complex128Codes, _ByteCodes, _ShortCodes, _IntCCodes, _IntPCodes, _IntCodes, _LongLongCodes, _UByteCodes, _UShortCodes, _UIntCCodes, _UIntPCodes, _UIntCodes, _ULongLongCodes, _HalfCodes, _SingleCodes, _DoubleCodes, _LongDoubleCodes, _CSingleCodes, _CDoubleCodes, _CLongDoubleCodes, _DT64Codes, _TD64Codes, _StrCodes, _BytesCodes, _VoidCodes, _ObjectCodes" should be placed at the top of the module
Error

Line: 17 Column: 1

              else:
    from ._generic_alias import _GenericAlias as GenericAlias

from ._char_codes import (
    _BoolCodes,
    _UInt8Codes,
    _UInt16Codes,
    _UInt32Codes,
    _UInt64Codes,

            

Reported by Pylint.

numpy/distutils/command/install.py
17 issues
Attribute 'install_lib' defined outside __init__
Error

Line: 22 Column: 9

              
    def finalize_options (self):
        old_install.finalize_options(self)
        self.install_lib = self.install_libbase

    def setuptools_run(self):
        """ The setuptools version of the .run() method.

        We must pull in the entire code so we can override the level used in the

            

Reported by Pylint.

Access to a protected member _getframe of a client class
Error

Line: 44 Column: 18

                      # called by 'run_commands'.  This is slightly kludgy, but seems to
        # work.
        #
        caller = sys._getframe(3)
        caller_module = caller.f_globals.get('__name__', '')
        caller_name = caller.f_code.co_name

        if caller_module != 'distutils.dist' or caller_name!='run_commands':
            # We weren't called from the command line or setup(), so we

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import sys
if 'setuptools' in sys.modules:
    import setuptools.command.install as old_install_mod
    have_setuptools = True
else:
    import distutils.command.install as old_install_mod
    have_setuptools = False
from distutils.file_util import write_file


            

Reported by Pylint.

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

Line: 4 Column: 5

              import sys
if 'setuptools' in sys.modules:
    import setuptools.command.install as old_install_mod
    have_setuptools = True
else:
    import distutils.command.install as old_install_mod
    have_setuptools = False
from distutils.file_util import write_file


            

Reported by Pylint.

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

Line: 7 Column: 5

                  have_setuptools = True
else:
    import distutils.command.install as old_install_mod
    have_setuptools = False
from distutils.file_util import write_file

old_install = old_install_mod.install

class install(old_install):

            

Reported by Pylint.

Import "from distutils.file_util import write_file" should be placed at the top of the module
Error

Line: 8 Column: 1

              else:
    import distutils.command.install as old_install_mod
    have_setuptools = False
from distutils.file_util import write_file

old_install = old_install_mod.install

class install(old_install):


            

Reported by Pylint.

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

Line: 10 Column: 1

                  have_setuptools = False
from distutils.file_util import write_file

old_install = old_install_mod.install

class install(old_install):

    # Always run install_clib - the command is cheap, so no need to bypass it;
    # but it's not run by setuptools -- so it's run again in install_data

            

Reported by Pylint.

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

Line: 12 Column: 1

              
old_install = old_install_mod.install

class install(old_install):

    # Always run install_clib - the command is cheap, so no need to bypass it;
    # but it's not run by setuptools -- so it's run again in install_data
    sub_commands = old_install.sub_commands + [
        ('install_clib', lambda x: True)

            

Reported by Pylint.

Missing class docstring
Error

Line: 12 Column: 1

              
old_install = old_install_mod.install

class install(old_install):

    # Always run install_clib - the command is cheap, so no need to bypass it;
    # but it's not run by setuptools -- so it's run again in install_data
    sub_commands = old_install.sub_commands + [
        ('install_clib', lambda x: True)

            

Reported by Pylint.

Either all return statements in a function should return an expression, or none of them should.
Error

Line: 24 Column: 5

                      old_install.finalize_options(self)
        self.install_lib = self.install_libbase

    def setuptools_run(self):
        """ The setuptools version of the .run() method.

        We must pull in the entire code so we can override the level used in the
        _getframe() call since we wrap this call by one more level.
        """

            

Reported by Pylint.

numpy/typing/tests/data/reveal/arraypad.py
17 issues
Unable to import 'typing_extensions'
Error

Line: 2 Column: 1

              from typing import List, Any, Mapping, Tuple
from typing_extensions import SupportsIndex

import numpy as np
import numpy.typing as npt

def mode_func(
    ar: npt.NDArray[np.number[Any]],
    width: Tuple[int, int],

            

Reported by Pylint.

Module 'numpy.typing' has no 'NDArray' member
Error

Line: 8 Column: 9

              import numpy.typing as npt

def mode_func(
    ar: npt.NDArray[np.number[Any]],
    width: Tuple[int, int],
    iaxis: SupportsIndex,
    kwargs: Mapping[str, Any],
) -> None: ...


            

Reported by Pylint.

Value 'np.number' is unsubscriptable
Error

Line: 8 Column: 21

              import numpy.typing as npt

def mode_func(
    ar: npt.NDArray[np.number[Any]],
    width: Tuple[int, int],
    iaxis: SupportsIndex,
    kwargs: Mapping[str, Any],
) -> None: ...


            

Reported by Pylint.

Module 'numpy.typing' has no 'NDArray' member
Error

Line: 14 Column: 8

                  kwargs: Mapping[str, Any],
) -> None: ...

AR_i8: npt.NDArray[np.int64]
AR_f8: npt.NDArray[np.float64]
AR_LIKE: List[int]

reveal_type(np.pad(AR_i8, (2, 3), "constant"))  # E: numpy.ndarray[Any, numpy.dtype[{int64}]]
reveal_type(np.pad(AR_LIKE, (2, 3), "constant"))  # E: numpy.ndarray[Any, numpy.dtype[Any]]

            

Reported by Pylint.

Module 'numpy.typing' has no 'NDArray' member
Error

Line: 15 Column: 8

              ) -> None: ...

AR_i8: npt.NDArray[np.int64]
AR_f8: npt.NDArray[np.float64]
AR_LIKE: List[int]

reveal_type(np.pad(AR_i8, (2, 3), "constant"))  # E: numpy.ndarray[Any, numpy.dtype[{int64}]]
reveal_type(np.pad(AR_LIKE, (2, 3), "constant"))  # E: numpy.ndarray[Any, numpy.dtype[Any]]


            

Reported by Pylint.

Undefined variable 'reveal_type'
Error

Line: 18 Column: 1

              AR_f8: npt.NDArray[np.float64]
AR_LIKE: List[int]

reveal_type(np.pad(AR_i8, (2, 3), "constant"))  # E: numpy.ndarray[Any, numpy.dtype[{int64}]]
reveal_type(np.pad(AR_LIKE, (2, 3), "constant"))  # E: numpy.ndarray[Any, numpy.dtype[Any]]

reveal_type(np.pad(AR_f8, (2, 3), mode_func))  # E: numpy.ndarray[Any, numpy.dtype[{float64}]]
reveal_type(np.pad(AR_f8, (2, 3), mode_func, a=1, b=2))  # E: numpy.ndarray[Any, numpy.dtype[{float64}]]

            

Reported by Pylint.

Undefined variable 'reveal_type'
Error

Line: 19 Column: 1

              AR_LIKE: List[int]

reveal_type(np.pad(AR_i8, (2, 3), "constant"))  # E: numpy.ndarray[Any, numpy.dtype[{int64}]]
reveal_type(np.pad(AR_LIKE, (2, 3), "constant"))  # E: numpy.ndarray[Any, numpy.dtype[Any]]

reveal_type(np.pad(AR_f8, (2, 3), mode_func))  # E: numpy.ndarray[Any, numpy.dtype[{float64}]]
reveal_type(np.pad(AR_f8, (2, 3), mode_func, a=1, b=2))  # E: numpy.ndarray[Any, numpy.dtype[{float64}]]

            

Reported by Pylint.

Undefined variable 'reveal_type'
Error

Line: 21 Column: 1

              reveal_type(np.pad(AR_i8, (2, 3), "constant"))  # E: numpy.ndarray[Any, numpy.dtype[{int64}]]
reveal_type(np.pad(AR_LIKE, (2, 3), "constant"))  # E: numpy.ndarray[Any, numpy.dtype[Any]]

reveal_type(np.pad(AR_f8, (2, 3), mode_func))  # E: numpy.ndarray[Any, numpy.dtype[{float64}]]
reveal_type(np.pad(AR_f8, (2, 3), mode_func, a=1, b=2))  # E: numpy.ndarray[Any, numpy.dtype[{float64}]]

            

Reported by Pylint.

Undefined variable 'reveal_type'
Error

Line: 22 Column: 1

              reveal_type(np.pad(AR_LIKE, (2, 3), "constant"))  # E: numpy.ndarray[Any, numpy.dtype[Any]]

reveal_type(np.pad(AR_f8, (2, 3), mode_func))  # E: numpy.ndarray[Any, numpy.dtype[{float64}]]
reveal_type(np.pad(AR_f8, (2, 3), mode_func, a=1, b=2))  # E: numpy.ndarray[Any, numpy.dtype[{float64}]]

            

Reported by Pylint.

Unused argument 'ar'
Error

Line: 8 Column: 5

              import numpy.typing as npt

def mode_func(
    ar: npt.NDArray[np.number[Any]],
    width: Tuple[int, int],
    iaxis: SupportsIndex,
    kwargs: Mapping[str, Any],
) -> None: ...


            

Reported by Pylint.

doc/neps/nep-0016-benchmark.py
17 issues
Unable to import 'perf'
Error

Line: 1 Column: 1

              import perf
import abc
import numpy as np

class NotArray:
    pass

class AttrArray:
    __array_implementer__ = True

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import perf
import abc
import numpy as np

class NotArray:
    pass

class AttrArray:
    __array_implementer__ = True

            

Reported by Pylint.

Module name "nep-0016-benchmark" doesn't conform to snake_case naming style
Error

Line: 1 Column: 1

              import perf
import abc
import numpy as np

class NotArray:
    pass

class AttrArray:
    __array_implementer__ = True

            

Reported by Pylint.

standard import "import abc" should be placed before "import perf"
Error

Line: 2 Column: 1

              import perf
import abc
import numpy as np

class NotArray:
    pass

class AttrArray:
    __array_implementer__ = True

            

Reported by Pylint.

Missing class docstring
Error

Line: 5 Column: 1

              import abc
import numpy as np

class NotArray:
    pass

class AttrArray:
    __array_implementer__ = True


            

Reported by Pylint.

Too few public methods (0/2)
Error

Line: 5 Column: 1

              import abc
import numpy as np

class NotArray:
    pass

class AttrArray:
    __array_implementer__ = True


            

Reported by Pylint.

Missing class docstring
Error

Line: 8 Column: 1

              class NotArray:
    pass

class AttrArray:
    __array_implementer__ = True

class ArrayBase(abc.ABC):
    pass


            

Reported by Pylint.

Too few public methods (0/2)
Error

Line: 8 Column: 1

              class NotArray:
    pass

class AttrArray:
    __array_implementer__ = True

class ArrayBase(abc.ABC):
    pass


            

Reported by Pylint.

Missing class docstring
Error

Line: 11 Column: 1

              class AttrArray:
    __array_implementer__ = True

class ArrayBase(abc.ABC):
    pass

class ABCArray1(ArrayBase):
    pass


            

Reported by Pylint.

Too few public methods (0/2)
Error

Line: 11 Column: 1

              class AttrArray:
    __array_implementer__ = True

class ArrayBase(abc.ABC):
    pass

class ABCArray1(ArrayBase):
    pass


            

Reported by Pylint.

numpy/distutils/exec_command.py
17 issues
subprocess call with shell=True identified, security issue.
Security injection

Line: 283
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b602_subprocess_popen_with_shell_equals_true.html

                      # will return bytes. We need to decode the output ourselves
        # so that Python will not raise a UnicodeDecodeError when
        # it encounters an invalid character; rather, we simply replace it
        proc = subprocess.Popen(command, shell=use_shell, env=env,
                                stdout=subprocess.PIPE,
                                stderr=subprocess.STDOUT,
                                universal_newlines=False)
    except EnvironmentError:
        # Return 127, as os.spawn*() and /bin/sh do

            

Reported by Bandit.

Dangerous default value {} as argument
Error

Line: 116 Column: 1

                      assert os.path.isfile(pythonexe), '%r is not a file' % (pythonexe,)
    return pythonexe

def find_executable(exe, path=None, _cache={}):
    """Return full path of a executable or None.

    Symbolic links are not followed.
    """
    key = exe, path

            

Reported by Pylint.

Unused variable 'err'
Error

Line: 291 Column: 11

                      # Return 127, as os.spawn*() and /bin/sh do
        return 127, ''

    text, err = proc.communicate()
    mylocale = locale.getpreferredencoding(False)
    if mylocale is None:
        mylocale = 'ascii'
    text = text.decode(mylocale, errors='replace')
    text = text.replace('\r\n', '\n')

            

Reported by Pylint.

Consider possible security implications associated with subprocess module.
Security blacklist

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

              
import os
import sys
import subprocess
import locale
import warnings

from numpy.distutils.misc_util import is_sequence, make_temp_file
from numpy.distutils import log

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 99 Column: 1

                      sys.stdout.write(val.decode('utf8', errors='replace'))


def temp_file_name():
    # 2019-01-30, 1.17
    warnings.warn('temp_file_name is deprecated since NumPy v1.17, use '
                  'tempfile.mkstemp instead', DeprecationWarning, stacklevel=1)
    fo, name = make_temp_file()
    fo.close()

            

Reported by Pylint.

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

Line: 103 Column: 5

                  # 2019-01-30, 1.17
    warnings.warn('temp_file_name is deprecated since NumPy v1.17, use '
                  'tempfile.mkstemp instead', DeprecationWarning, stacklevel=1)
    fo, name = make_temp_file()
    fo.close()
    return name

def get_pythonexe():
    pythonexe = sys.executable

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 107 Column: 1

                  fo.close()
    return name

def get_pythonexe():
    pythonexe = sys.executable
    if os.name in ['nt', 'dos']:
        fdir, fn = os.path.split(pythonexe)
        fn = fn.upper().replace('PYTHONW', 'PYTHON')
        pythonexe = os.path.join(fdir, fn)

            

Reported by Pylint.

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

Line: 110 Column: 15

              def get_pythonexe():
    pythonexe = sys.executable
    if os.name in ['nt', 'dos']:
        fdir, fn = os.path.split(pythonexe)
        fn = fn.upper().replace('PYTHONW', 'PYTHON')
        pythonexe = os.path.join(fdir, fn)
        assert os.path.isfile(pythonexe), '%r is not a file' % (pythonexe,)
    return pythonexe


            

Reported by Pylint.

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

Line: 111 Column: 9

                  pythonexe = sys.executable
    if os.name in ['nt', 'dos']:
        fdir, fn = os.path.split(pythonexe)
        fn = fn.upper().replace('PYTHONW', 'PYTHON')
        pythonexe = os.path.join(fdir, fn)
        assert os.path.isfile(pythonexe), '%r is not a file' % (pythonexe,)
    return pythonexe

def find_executable(exe, path=None, _cache={}):

            

Reported by Pylint.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 113
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

                      fdir, fn = os.path.split(pythonexe)
        fn = fn.upper().replace('PYTHONW', 'PYTHON')
        pythonexe = os.path.join(fdir, fn)
        assert os.path.isfile(pythonexe), '%r is not a file' % (pythonexe,)
    return pythonexe

def find_executable(exe, path=None, _cache={}):
    """Return full path of a executable or None.


            

Reported by Bandit.

numpy/core/code_generators/generate_ufunc_api.py
17 issues
Unable to import 'genapi'
Error

Line: 2 Column: 1

              import os
import genapi

import numpy_api

from genapi import TypeApi, FunctionApi

h_template = r"""
#ifdef _UMATHMODULE

            

Reported by Pylint.

Unable to import 'numpy_api'
Error

Line: 4 Column: 1

              import os
import genapi

import numpy_api

from genapi import TypeApi, FunctionApi

h_template = r"""
#ifdef _UMATHMODULE

            

Reported by Pylint.

Unable to import 'genapi'
Error

Line: 6 Column: 1

              
import numpy_api

from genapi import TypeApi, FunctionApi

h_template = r"""
#ifdef _UMATHMODULE

extern NPY_NO_EXPORT PyTypeObject PyUFunc_Type;

            

Reported by Pylint.

Unused argument 'sources'
Error

Line: 137 Column: 30

              
    return targets

def do_generate_api(targets, sources):
    header_file = targets[0]
    c_file = targets[1]
    doc_file = targets[2]

    ufunc_api_index = genapi.merge_api_dicts((

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import os
import genapi

import numpy_api

from genapi import TypeApi, FunctionApi

h_template = r"""
#ifdef _UMATHMODULE

            

Reported by Pylint.

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

Line: 8 Column: 1

              
from genapi import TypeApi, FunctionApi

h_template = r"""
#ifdef _UMATHMODULE

extern NPY_NO_EXPORT PyTypeObject PyUFunc_Type;

%s

            

Reported by Pylint.

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

Line: 110 Column: 1

              #endif
"""

c_template = r"""
/* These pointers will be stored in the C-object for use in other
    extension modules
*/

void *PyUFunc_API[] = {

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 120 Column: 1

              };
"""

def generate_api(output_dir, force=False):
    basename = 'ufunc_api'

    h_file = os.path.join(output_dir, '__%s.h' % basename)
    c_file = os.path.join(output_dir, '__%s.c' % basename)
    d_file = os.path.join(output_dir, '%s.txt' % basename)

            

Reported by Pylint.

Unnecessary "else" after "return"
Error

Line: 130 Column: 5

              
    sources = ['ufunc_api_order.txt']

    if (not force and not genapi.should_rebuild(targets, sources + [__file__])):
        return targets
    else:
        do_generate_api(targets, sources)

    return targets

            

Reported by Pylint.

Too many local variables (20/15)
Error

Line: 137 Column: 1

              
    return targets

def do_generate_api(targets, sources):
    header_file = targets[0]
    c_file = targets[1]
    doc_file = targets[2]

    ufunc_api_index = genapi.merge_api_dicts((

            

Reported by Pylint.

numpy/typing/tests/data/pass/multiarray.py
17 issues
Module 'numpy.typing' has no 'NDArray' member
Error

Line: 5 Column: 8

              import numpy as np
import numpy.typing as npt

AR_f8: npt.NDArray[np.float64] = np.array([1.0])
AR_i4 = np.array([1], dtype=np.int32)
AR_u1 = np.array([1], dtype=np.uint8)

AR_LIKE_f = [1.5]
AR_LIKE_i = [1]

            

Reported by Pylint.

Unused Any imported from typing
Error

Line: 1 Column: 1

              from typing import Any
import numpy as np
import numpy.typing as npt

AR_f8: npt.NDArray[np.float64] = np.array([1.0])
AR_i4 = np.array([1], dtype=np.int32)
AR_u1 = np.array([1], dtype=np.uint8)

AR_LIKE_f = [1.5]

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 17 Column: 1

              
next(b_f8)
b_f8.reset()
b_f8.index
b_f8.iters
b_f8.nd
b_f8.ndim
b_f8.numiter
b_f8.shape

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 18 Column: 1

              next(b_f8)
b_f8.reset()
b_f8.index
b_f8.iters
b_f8.nd
b_f8.ndim
b_f8.numiter
b_f8.shape
b_f8.size

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 19 Column: 1

              b_f8.reset()
b_f8.index
b_f8.iters
b_f8.nd
b_f8.ndim
b_f8.numiter
b_f8.shape
b_f8.size


            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 20 Column: 1

              b_f8.index
b_f8.iters
b_f8.nd
b_f8.ndim
b_f8.numiter
b_f8.shape
b_f8.size

next(b_i4_f8_f8)

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 21 Column: 1

              b_f8.iters
b_f8.nd
b_f8.ndim
b_f8.numiter
b_f8.shape
b_f8.size

next(b_i4_f8_f8)
b_i4_f8_f8.reset()

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 22 Column: 1

              b_f8.nd
b_f8.ndim
b_f8.numiter
b_f8.shape
b_f8.size

next(b_i4_f8_f8)
b_i4_f8_f8.reset()
b_i4_f8_f8.ndim

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 23 Column: 1

              b_f8.ndim
b_f8.numiter
b_f8.shape
b_f8.size

next(b_i4_f8_f8)
b_i4_f8_f8.reset()
b_i4_f8_f8.ndim
b_i4_f8_f8.index

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 27 Column: 1

              
next(b_i4_f8_f8)
b_i4_f8_f8.reset()
b_i4_f8_f8.ndim
b_i4_f8_f8.index
b_i4_f8_f8.iters
b_i4_f8_f8.nd
b_i4_f8_f8.numiter
b_i4_f8_f8.shape

            

Reported by Pylint.

numpy/typing/mypy_plugin.py
16 issues
Unable to import 'mypy.types'
Error

Line: 41 Column: 5

              import numpy as np

try:
    import mypy.types
    from mypy.types import Type
    from mypy.plugin import Plugin, AnalyzeTypeContext
    from mypy.nodes import MypyFile, ImportFrom, Statement
    from mypy.build import PRI_MED


            

Reported by Pylint.

Unable to import 'mypy.types'
Error

Line: 42 Column: 5

              
try:
    import mypy.types
    from mypy.types import Type
    from mypy.plugin import Plugin, AnalyzeTypeContext
    from mypy.nodes import MypyFile, ImportFrom, Statement
    from mypy.build import PRI_MED

    _HookFunc = t.Callable[[AnalyzeTypeContext], Type]

            

Reported by Pylint.

Unable to import 'mypy.plugin'
Error

Line: 43 Column: 5

              try:
    import mypy.types
    from mypy.types import Type
    from mypy.plugin import Plugin, AnalyzeTypeContext
    from mypy.nodes import MypyFile, ImportFrom, Statement
    from mypy.build import PRI_MED

    _HookFunc = t.Callable[[AnalyzeTypeContext], Type]
    MYPY_EX: None | ModuleNotFoundError = None

            

Reported by Pylint.

Unable to import 'mypy.nodes'
Error

Line: 44 Column: 5

                  import mypy.types
    from mypy.types import Type
    from mypy.plugin import Plugin, AnalyzeTypeContext
    from mypy.nodes import MypyFile, ImportFrom, Statement
    from mypy.build import PRI_MED

    _HookFunc = t.Callable[[AnalyzeTypeContext], Type]
    MYPY_EX: None | ModuleNotFoundError = None
except ModuleNotFoundError as ex:

            

Reported by Pylint.

Unable to import 'mypy.build'
Error

Line: 45 Column: 5

                  from mypy.types import Type
    from mypy.plugin import Plugin, AnalyzeTypeContext
    from mypy.nodes import MypyFile, ImportFrom, Statement
    from mypy.build import PRI_MED

    _HookFunc = t.Callable[[AnalyzeTypeContext], Type]
    MYPY_EX: None | ModuleNotFoundError = None
except ModuleNotFoundError as ex:
    MYPY_EX = ex

            

Reported by Pylint.

Method 'dtype' has no 'itemsize' member
Error

Line: 71 Column: 22

                  ]
    ret = {}
    for name, typ in names:
        n: int = 8 * typ().dtype.itemsize
        ret[f'numpy.typing._nbit.{name}'] = f"numpy._{n}Bit"
    return ret


def _get_extended_precision_list() -> t.List[str]:

            

Reported by Pylint.

No value for argument 'value' in constructor call
Error

Line: 71 Column: 22

                  ]
    ret = {}
    for name, typ in names:
        n: int = 8 * typ().dtype.itemsize
        ret[f'numpy.typing._nbit.{name}'] = f"numpy._{n}Bit"
    return ret


def _get_extended_precision_list() -> t.List[str]:

            

Reported by Pylint.

Unused import mypy.types
Error

Line: 41 Column: 5

              import numpy as np

try:
    import mypy.types
    from mypy.types import Type
    from mypy.plugin import Plugin, AnalyzeTypeContext
    from mypy.nodes import MypyFile, ImportFrom, Statement
    from mypy.build import PRI_MED


            

Reported by Pylint.

Redefining built-in 'id'
Error

Line: 128 Column: 49

              

if t.TYPE_CHECKING or MYPY_EX is None:
    def _index(iterable: t.Iterable[Statement], id: str) -> int:
        """Identify the first ``ImportFrom`` instance the specified `id`."""
        for i, value in enumerate(iterable):
            if getattr(value, "id", None) == id:
                return i
        else:

            

Reported by Pylint.

Else clause on loop without a break statement
Error

Line: 133 Column: 9

                      for i, value in enumerate(iterable):
            if getattr(value, "id", None) == id:
                return i
        else:
            raise ValueError("Failed to identify a `ImportFrom` instance "
                             f"with the following id: {id!r}")

    def _override_imports(
        file: MypyFile,

            

Reported by Pylint.

numpy/distutils/lib2def.py
16 issues
subprocess call with shell=True identified, security issue.
Security injection

Line: 66
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b602_subprocess_popen_with_shell_equals_true.html

                  """Returns the output of nm_cmd via a pipe.

nm_output = getnm(nm_cmd = 'nm -Cs py_lib')"""
    p = subprocess.Popen(nm_cmd, shell=shell, stdout=subprocess.PIPE,
                         stderr=subprocess.PIPE, universal_newlines=True)
    nm_output, nm_err = p.communicate()
    if p.returncode != 0:
        raise RuntimeError('failed to run "%s": "%s"' % (
                                     ' '.join(nm_cmd), nm_err))

            

Reported by Bandit.

Possible unbalanced tuple unpacking with sequence: left side has 2 label(s), right side has 0 value(s)
Error

Line: 44 Column: 13

              libfile, deffile = parse_cmd()"""
    if len(sys.argv) == 3:
        if sys.argv[1][-4:] == '.lib' and sys.argv[2][-4:] == '.def':
            libfile, deffile = sys.argv[1:]
        elif sys.argv[1][-4:] == '.def' and sys.argv[2][-4:] == '.lib':
            deffile, libfile = sys.argv[1:]
        else:
            print("I'm assuming that your first argument is the library")
            print("and the second is the DEF file.")

            

Reported by Pylint.

Redefining name 'deffile' from outer scope (line 108)
Error

Line: 44 Column: 22

              libfile, deffile = parse_cmd()"""
    if len(sys.argv) == 3:
        if sys.argv[1][-4:] == '.lib' and sys.argv[2][-4:] == '.def':
            libfile, deffile = sys.argv[1:]
        elif sys.argv[1][-4:] == '.def' and sys.argv[2][-4:] == '.lib':
            deffile, libfile = sys.argv[1:]
        else:
            print("I'm assuming that your first argument is the library")
            print("and the second is the DEF file.")

            

Reported by Pylint.

Redefining name 'libfile' from outer scope (line 108)
Error

Line: 44 Column: 13

              libfile, deffile = parse_cmd()"""
    if len(sys.argv) == 3:
        if sys.argv[1][-4:] == '.lib' and sys.argv[2][-4:] == '.def':
            libfile, deffile = sys.argv[1:]
        elif sys.argv[1][-4:] == '.def' and sys.argv[2][-4:] == '.lib':
            deffile, libfile = sys.argv[1:]
        else:
            print("I'm assuming that your first argument is the library")
            print("and the second is the DEF file.")

            

Reported by Pylint.

Possible unbalanced tuple unpacking with sequence: left side has 2 label(s), right side has 0 value(s)
Error

Line: 46 Column: 13

                      if sys.argv[1][-4:] == '.lib' and sys.argv[2][-4:] == '.def':
            libfile, deffile = sys.argv[1:]
        elif sys.argv[1][-4:] == '.def' and sys.argv[2][-4:] == '.lib':
            deffile, libfile = sys.argv[1:]
        else:
            print("I'm assuming that your first argument is the library")
            print("and the second is the DEF file.")
    elif len(sys.argv) == 2:
        if sys.argv[1][-4:] == '.def':

            

Reported by Pylint.

Redefining name 'nm_cmd' from outer scope (line 113)
Error

Line: 62 Column: 11

                      deffile = None
    return libfile, deffile

def getnm(nm_cmd=['nm', '-Cs', 'python%s.lib' % py_ver], shell=True):
    """Returns the output of nm_cmd via a pipe.

nm_output = getnm(nm_cmd = 'nm -Cs py_lib')"""
    p = subprocess.Popen(nm_cmd, shell=shell, stdout=subprocess.PIPE,
                         stderr=subprocess.PIPE, universal_newlines=True)

            

Reported by Pylint.

Dangerous default value [] as argument
Error

Line: 62 Column: 1

                      deffile = None
    return libfile, deffile

def getnm(nm_cmd=['nm', '-Cs', 'python%s.lib' % py_ver], shell=True):
    """Returns the output of nm_cmd via a pipe.

nm_output = getnm(nm_cmd = 'nm -Cs py_lib')"""
    p = subprocess.Popen(nm_cmd, shell=shell, stdout=subprocess.PIPE,
                         stderr=subprocess.PIPE, universal_newlines=True)

            

Reported by Pylint.

Redefining name 'nm_output' from outer scope (line 114)
Error

Line: 68 Column: 5

              nm_output = getnm(nm_cmd = 'nm -Cs py_lib')"""
    p = subprocess.Popen(nm_cmd, shell=shell, stdout=subprocess.PIPE,
                         stderr=subprocess.PIPE, universal_newlines=True)
    nm_output, nm_err = p.communicate()
    if p.returncode != 0:
        raise RuntimeError('failed to run "%s": "%s"' % (
                                     ' '.join(nm_cmd), nm_err))
    return nm_output


            

Reported by Pylint.

Redefining name 'nm_output' from outer scope (line 114)
Error

Line: 74 Column: 14

                                                   ' '.join(nm_cmd), nm_err))
    return nm_output

def parse_nm(nm_output):
    """Returns a tuple of lists: dlist for the list of data
symbols and flist for the list of function symbols.

dlist, flist = parse_nm(nm_output)"""
    data = DATA_RE.findall(nm_output)

            

Reported by Pylint.

Redefining name 'flist' from outer scope (line 115)
Error

Line: 82 Column: 5

                  data = DATA_RE.findall(nm_output)
    func = FUNC_RE.findall(nm_output)

    flist = []
    for sym in data:
        if sym in func and (sym[:2] == 'Py' or sym[:3] == '_Py' or sym[:4] == 'init'):
            flist.append(sym)

    dlist = []

            

Reported by Pylint.

numpy/matrixlib/tests/test_matrix_linalg.py
16 issues
Missing class docstring
Error

Line: 36 Column: 1

              # No need to make generalized or strided cases for matrices.


class MatrixTestCase(LinalgTestCase):
    TEST_CASES = CASES


class TestSolveMatrix(SolveCases, MatrixTestCase):
    pass

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 36 Column: 1

              # No need to make generalized or strided cases for matrices.


class MatrixTestCase(LinalgTestCase):
    TEST_CASES = CASES


class TestSolveMatrix(SolveCases, MatrixTestCase):
    pass

            

Reported by Pylint.

Missing class docstring
Error

Line: 40 Column: 1

                  TEST_CASES = CASES


class TestSolveMatrix(SolveCases, MatrixTestCase):
    pass


class TestInvMatrix(InvCases, MatrixTestCase):
    pass

            

Reported by Pylint.

Missing class docstring
Error

Line: 44 Column: 1

                  pass


class TestInvMatrix(InvCases, MatrixTestCase):
    pass


class TestEigvalsMatrix(EigvalsCases, MatrixTestCase):
    pass

            

Reported by Pylint.

Missing class docstring
Error

Line: 48 Column: 1

                  pass


class TestEigvalsMatrix(EigvalsCases, MatrixTestCase):
    pass


class TestEigMatrix(EigCases, MatrixTestCase):
    pass

            

Reported by Pylint.

Missing class docstring
Error

Line: 52 Column: 1

                  pass


class TestEigMatrix(EigCases, MatrixTestCase):
    pass


class TestSVDMatrix(SVDCases, MatrixTestCase):
    pass

            

Reported by Pylint.

Missing class docstring
Error

Line: 56 Column: 1

                  pass


class TestSVDMatrix(SVDCases, MatrixTestCase):
    pass


class TestCondMatrix(CondCases, MatrixTestCase):
    pass

            

Reported by Pylint.

Missing class docstring
Error

Line: 60 Column: 1

                  pass


class TestCondMatrix(CondCases, MatrixTestCase):
    pass


class TestPinvMatrix(PinvCases, MatrixTestCase):
    pass

            

Reported by Pylint.

Missing class docstring
Error

Line: 64 Column: 1

                  pass


class TestPinvMatrix(PinvCases, MatrixTestCase):
    pass


class TestDetMatrix(DetCases, MatrixTestCase):
    pass

            

Reported by Pylint.

Too many ancestors (8/7)
Error

Line: 64 Column: 1

                  pass


class TestPinvMatrix(PinvCases, MatrixTestCase):
    pass


class TestDetMatrix(DetCases, MatrixTestCase):
    pass

            

Reported by Pylint.