The following issues were found

numpy/typing/_generic_alias.py
10 issues
Module 'types' has no 'GenericAlias' member
Error

Line: 202 Column: 43

              
# See `_GenericAlias.__eq__`
if sys.version_info >= (3, 9):
    _GENERIC_ALIAS_TYPE = (_GenericAlias, types.GenericAlias)
else:
    _GENERIC_ALIAS_TYPE = (_GenericAlias,)

ScalarType = TypeVar("ScalarType", bound=np.generic, covariant=True)


            

Reported by Pylint.

Value 'np.ndarray' is unsubscriptable
Error

Line: 210 Column: 15

              
if TYPE_CHECKING:
    _DType = np.dtype[ScalarType]
    NDArray = np.ndarray[Any, np.dtype[ScalarType]]
elif sys.version_info >= (3, 9):
    _DType = types.GenericAlias(np.dtype, (ScalarType,))
    NDArray = types.GenericAlias(np.ndarray, (Any, _DType))
else:
    _DType = _GenericAlias(np.dtype, (ScalarType,))

            

Reported by Pylint.

Module 'types' has no 'GenericAlias' member
Error

Line: 212 Column: 14

                  _DType = np.dtype[ScalarType]
    NDArray = np.ndarray[Any, np.dtype[ScalarType]]
elif sys.version_info >= (3, 9):
    _DType = types.GenericAlias(np.dtype, (ScalarType,))
    NDArray = types.GenericAlias(np.ndarray, (Any, _DType))
else:
    _DType = _GenericAlias(np.dtype, (ScalarType,))
    NDArray = _GenericAlias(np.ndarray, (Any, _DType))

            

Reported by Pylint.

Module 'types' has no 'GenericAlias' member
Error

Line: 213 Column: 15

                  NDArray = np.ndarray[Any, np.dtype[ScalarType]]
elif sys.version_info >= (3, 9):
    _DType = types.GenericAlias(np.dtype, (ScalarType,))
    NDArray = types.GenericAlias(np.ndarray, (Any, _DType))
else:
    _DType = _GenericAlias(np.dtype, (ScalarType,))
    NDArray = _GenericAlias(np.ndarray, (Any, _DType))

            

Reported by Pylint.

Unused argument 'bases'
Error

Line: 124 Column: 31

                      cls = type(self)
        return cls, (self.__origin__, self.__args__)

    def __mro_entries__(self, bases: Iterable[object]) -> Tuple[type]:
        return (self.__origin__,)

    def __dir__(self) -> List[str]:
        """Implement ``dir(self)``."""
        cls = type(self)

            

Reported by Pylint.

Attribute '_hash' defined outside __init__
Error

Line: 139 Column: 13

                      try:
            return super().__getattribute__("_hash")
        except AttributeError:
            self._hash: int = hash(self.__origin__) ^ hash(self.__args__)
            return super().__getattribute__("_hash")

    def __instancecheck__(self, obj: object) -> NoReturn:
        """Check if an `obj` is an instance."""
        raise TypeError("isinstance() argument 2 cannot be a "

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from __future__ import annotations

import sys
import types
from typing import (
    Any,
    ClassVar,
    FrozenSet,
    Generator,

            

Reported by Pylint.

Unnecessary "elif" after "return"
Error

Line: 29 Column: 5

              
def _to_str(obj: object) -> str:
    """Helper function for `_GenericAlias.__repr__`."""
    if obj is Ellipsis:
        return '...'
    elif isinstance(obj, type) and not isinstance(obj, _GENERIC_ALIAS_TYPE):
        if obj.__module__ == 'builtins':
            return obj.__qualname__
        else:

            

Reported by Pylint.

Unnecessary "else" after "return"
Error

Line: 32 Column: 9

                  if obj is Ellipsis:
        return '...'
    elif isinstance(obj, type) and not isinstance(obj, _GENERIC_ALIAS_TYPE):
        if obj.__module__ == 'builtins':
            return obj.__qualname__
        else:
            return f'{obj.__module__}.{obj.__qualname__}'
    else:
        return repr(obj)

            

Reported by Pylint.

Unnecessary "elif" after "raise"
Error

Line: 162 Column: 9

                      """Return ``self[key]``."""
        key_tup = key if isinstance(key, tuple) else (key,)

        if len(self.__parameters__) == 0:
            raise TypeError(f"There are no type variables left in {self}")
        elif len(key_tup) > len(self.__parameters__):
            raise TypeError(f"Too many arguments for {self}")
        elif len(key_tup) < len(self.__parameters__):
            raise TypeError(f"Too few arguments for {self}")

            

Reported by Pylint.

numpy/distutils/_shell_utils.py
10 issues
Consider explicitly re-raising using the 'from' keyword
Error

Line: 53 Column: 13

                      try:
            ctypes.windll
        except AttributeError:
            raise NotImplementedError

        # Windows has special parsing rules for the executable (no quotes),
        # that we do not care about - insert a dummy element
        if not cmd:
            return []

            

Reported by Pylint.

Consider possible security implications associated with subprocess module.
Security blacklist

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

              """
import os
import shlex
import subprocess
try:
    from shlex import quote
except ImportError:
    from pipes import quote


            

Reported by Bandit.

Missing function or method docstring
Error

Line: 43 Column: 5

                  Note that this is _not_ the behavior of cmd.
    """
    @staticmethod
    def join(argv):
        # note that list2cmdline is specific to the windows syntax
        return subprocess.list2cmdline(argv)

    @staticmethod
    def split(cmd):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 48 Column: 5

                      return subprocess.list2cmdline(argv)

    @staticmethod
    def split(cmd):
        import ctypes  # guarded import for systems without ctypes
        try:
            ctypes.windll
        except AttributeError:
            raise NotImplementedError

            

Reported by Pylint.

Import outside toplevel (ctypes)
Error

Line: 49 Column: 9

              
    @staticmethod
    def split(cmd):
        import ctypes  # guarded import for systems without ctypes
        try:
            ctypes.windll
        except AttributeError:
            raise NotImplementedError


            

Reported by Pylint.

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

Line: 61 Column: 9

                          return []
        cmd = 'dummy ' + cmd

        CommandLineToArgvW = ctypes.windll.shell32.CommandLineToArgvW
        CommandLineToArgvW.restype = ctypes.POINTER(ctypes.c_wchar_p)
        CommandLineToArgvW.argtypes = (ctypes.c_wchar_p, ctypes.POINTER(ctypes.c_int))

        nargs = ctypes.c_int()
        lpargs = CommandLineToArgvW(cmd, ctypes.byref(nargs))

            

Reported by Pylint.

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

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

                      nargs = ctypes.c_int()
        lpargs = CommandLineToArgvW(cmd, ctypes.byref(nargs))
        args = [lpargs[i] for i in range(nargs.value)]
        assert not ctypes.windll.kernel32.LocalFree(lpargs)

        # strip the element we inserted
        assert args[0] == "dummy"
        return args[1:]


            

Reported by Bandit.

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

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

                      assert not ctypes.windll.kernel32.LocalFree(lpargs)

        # strip the element we inserted
        assert args[0] == "dummy"
        return args[1:]


class PosixParser:
    """

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 80 Column: 5

                  The parsing behavior used by `subprocess.call("string", shell=True)` on Posix.
    """
    @staticmethod
    def join(argv):
        return ' '.join(quote(arg) for arg in argv)

    @staticmethod
    def split(cmd):
        return shlex.split(cmd, posix=True)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 84 Column: 5

                      return ' '.join(quote(arg) for arg in argv)

    @staticmethod
    def split(cmd):
        return shlex.split(cmd, posix=True)


if os.name == 'nt':
    NativeParser = WindowsParser

            

Reported by Pylint.

tools/functions_missing_types.py
10 issues
Method name "visit_FunctionDef" doesn't conform to snake_case naming style
Error

Line: 80 Column: 5

                  def __init__(self):
        self.attributes = set()

    def visit_FunctionDef(self, node):
        if node.name == "__getattr__":
            # Not really a module member.
            return
        self.attributes.add(node.name)
        # Do not call self.generic_visit; we are only interested in

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 80 Column: 5

                  def __init__(self):
        self.attributes = set()

    def visit_FunctionDef(self, node):
        if node.name == "__getattr__":
            # Not really a module member.
            return
        self.attributes.add(node.name)
        # Do not call self.generic_visit; we are only interested in

            

Reported by Pylint.

Method name "visit_ClassDef" doesn't conform to snake_case naming style
Error

Line: 89 Column: 5

                      # top-level functions.
        return

    def visit_ClassDef(self, node):
        if not node.name.startswith("_"):
            self.attributes.add(node.name)
        return

    def visit_AnnAssign(self, node):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 89 Column: 5

                      # top-level functions.
        return

    def visit_ClassDef(self, node):
        if not node.name.startswith("_"):
            self.attributes.add(node.name)
        return

    def visit_AnnAssign(self, node):

            

Reported by Pylint.

Useless return at end of function or method
Error

Line: 89 Column: 5

                      # top-level functions.
        return

    def visit_ClassDef(self, node):
        if not node.name.startswith("_"):
            self.attributes.add(node.name)
        return

    def visit_AnnAssign(self, node):

            

Reported by Pylint.

Method name "visit_AnnAssign" doesn't conform to snake_case naming style
Error

Line: 94 Column: 5

                          self.attributes.add(node.name)
        return

    def visit_AnnAssign(self, node):
        self.attributes.add(node.target.id)


def find_missing(module_name):
    module_path = os.path.join(

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 94 Column: 5

                          self.attributes.add(node.name)
        return

    def visit_AnnAssign(self, node):
        self.attributes.add(node.target.id)


def find_missing(module_name):
    module_path = os.path.join(

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 98 Column: 1

                      self.attributes.add(node.target.id)


def find_missing(module_name):
    module_path = os.path.join(
        NUMPY_ROOT,
        module_name.replace(".", os.sep),
        "__init__.pyi",
    )

            

Reported by Pylint.

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

Line: 111 Column: 35

                  }

    if os.path.isfile(module_path):
        with open(module_path) as f:
            tree = ast.parse(f.read())
        ast_visitor = FindAttributes()
        ast_visitor.visit(tree)
        stubs_attributes = ast_visitor.attributes
    else:

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 126 Column: 1

                  print("\n".join(sorted(missing)))


def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("module")
    args = parser.parse_args()

    find_missing(args.module)

            

Reported by Pylint.

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

Line: 7 Column: 7

              
i8: np.int64

AR_b: npt.NDArray[np.bool_]
AR_u1: npt.NDArray[np.uint8]
AR_i8: npt.NDArray[np.int64]
AR_f8: npt.NDArray[np.float64]
AR_M: npt.NDArray[np.datetime64]


            

Reported by Pylint.

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

Line: 8 Column: 8

              i8: np.int64

AR_b: npt.NDArray[np.bool_]
AR_u1: npt.NDArray[np.uint8]
AR_i8: npt.NDArray[np.int64]
AR_f8: npt.NDArray[np.float64]
AR_M: npt.NDArray[np.datetime64]

M: np.datetime64

            

Reported by Pylint.

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

Line: 9 Column: 8

              
AR_b: npt.NDArray[np.bool_]
AR_u1: npt.NDArray[np.uint8]
AR_i8: npt.NDArray[np.int64]
AR_f8: npt.NDArray[np.float64]
AR_M: npt.NDArray[np.datetime64]

M: np.datetime64


            

Reported by Pylint.

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

Line: 10 Column: 8

              AR_b: npt.NDArray[np.bool_]
AR_u1: npt.NDArray[np.uint8]
AR_i8: npt.NDArray[np.int64]
AR_f8: npt.NDArray[np.float64]
AR_M: npt.NDArray[np.datetime64]

M: np.datetime64

AR_LIKE_f: List[float]

            

Reported by Pylint.

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

Line: 11 Column: 7

              AR_u1: npt.NDArray[np.uint8]
AR_i8: npt.NDArray[np.int64]
AR_f8: npt.NDArray[np.float64]
AR_M: npt.NDArray[np.datetime64]

M: np.datetime64

AR_LIKE_f: List[float]


            

Reported by Pylint.

Unused argument 'a'
Error

Line: 17 Column: 10

              
AR_LIKE_f: List[float]

def func(a: int) -> None: ...

np.where(AR_b, 1)  # E: No overload variant

np.can_cast(AR_f8, 1)  # E: incompatible type


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

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

i8: np.int64

AR_b: npt.NDArray[np.bool_]
AR_u1: npt.NDArray[np.uint8]
AR_i8: npt.NDArray[np.int64]

            

Reported by Pylint.

More than one statement on a single line
Error

Line: 17 Column: 27

              
AR_LIKE_f: List[float]

def func(a: int) -> None: ...

np.where(AR_b, 1)  # E: No overload variant

np.can_cast(AR_f8, 1)  # E: incompatible type


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 17 Column: 1

              
AR_LIKE_f: List[float]

def func(a: int) -> None: ...

np.where(AR_b, 1)  # E: No overload variant

np.can_cast(AR_f8, 1)  # E: incompatible type


            

Reported by Pylint.

Argument name "a" doesn't conform to snake_case naming style
Error

Line: 17 Column: 1

              
AR_LIKE_f: List[float]

def func(a: int) -> None: ...

np.where(AR_b, 1)  # E: No overload variant

np.can_cast(AR_f8, 1)  # E: incompatible type


            

Reported by Pylint.

numpy/tests/test_scripts.py
10 issues
Unable to import 'pytest'
Error

Line: 7 Column: 1

              """
import sys
import os
import pytest
from os.path import join as pathjoin, isfile, dirname
import subprocess

import numpy as np
from numpy.testing import assert_equal

            

Reported by Pylint.

standard import "from os.path import join as pathjoin, isfile, dirname" should be placed before "import pytest"
Error

Line: 8 Column: 1

              import sys
import os
import pytest
from os.path import join as pathjoin, isfile, dirname
import subprocess

import numpy as np
from numpy.testing import assert_equal


            

Reported by Pylint.

Consider possible security implications associated with subprocess module.
Security blacklist

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

              import os
import pytest
from os.path import join as pathjoin, isfile, dirname
import subprocess

import numpy as np
from numpy.testing import assert_equal

is_inplace = isfile(pathjoin(dirname(np.__file__),  '..', 'setup.py'))

            

Reported by Bandit.

standard import "import subprocess" should be placed before "import pytest"
Error

Line: 9 Column: 1

              import os
import pytest
from os.path import join as pathjoin, isfile, dirname
import subprocess

import numpy as np
from numpy.testing import assert_equal

is_inplace = isfile(pathjoin(dirname(np.__file__),  '..', 'setup.py'))

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 17 Column: 1

              is_inplace = isfile(pathjoin(dirname(np.__file__),  '..', 'setup.py'))


def find_f2py_commands():
    if sys.platform == 'win32':
        exe_dir = dirname(sys.executable)
        if exe_dir.endswith('Scripts'): # virtualenv
            return [os.path.join(exe_dir, 'f2py')]
        else:

            

Reported by Pylint.

Unnecessary "else" after "return"
Error

Line: 20 Column: 9

              def find_f2py_commands():
    if sys.platform == 'win32':
        exe_dir = dirname(sys.executable)
        if exe_dir.endswith('Scripts'): # virtualenv
            return [os.path.join(exe_dir, 'f2py')]
        else:
            return [os.path.join(exe_dir, "Scripts", 'f2py')]
    else:
        # Three scripts are installed in Unix-like systems:

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 38 Column: 1

              @pytest.mark.skipif(is_inplace, reason="Cannot test f2py command inplace")
@pytest.mark.xfail(reason="Test is unreliable")
@pytest.mark.parametrize('f2py_cmd', find_f2py_commands())
def test_f2py(f2py_cmd):
    # test that we can run f2py script
    stdout = subprocess.check_output([f2py_cmd, '-v'])
    assert_equal(stdout.strip(), np.__version__.encode('ascii'))



            

Reported by Pylint.

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

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

              @pytest.mark.parametrize('f2py_cmd', find_f2py_commands())
def test_f2py(f2py_cmd):
    # test that we can run f2py script
    stdout = subprocess.check_output([f2py_cmd, '-v'])
    assert_equal(stdout.strip(), np.__version__.encode('ascii'))


def test_pep338():
    stdout = subprocess.check_output([sys.executable, '-mnumpy.f2py', '-v'])

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 44 Column: 1

                  assert_equal(stdout.strip(), np.__version__.encode('ascii'))


def test_pep338():
    stdout = subprocess.check_output([sys.executable, '-mnumpy.f2py', '-v'])
    assert_equal(stdout.strip(), np.__version__.encode('ascii'))

            

Reported by Pylint.

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

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

              

def test_pep338():
    stdout = subprocess.check_output([sys.executable, '-mnumpy.f2py', '-v'])
    assert_equal(stdout.strip(), np.__version__.encode('ascii'))

            

Reported by Bandit.

numpy/f2py/tests/test_mixed.py
9 issues
Unable to import 'pytest'
Error

Line: 3 Column: 1

              import os
import textwrap
import pytest

from numpy.testing import assert_, assert_equal, IS_PYPY
from . import util


def _path(*a):

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 6 Column: 1

              import pytest

from numpy.testing import assert_, assert_equal, IS_PYPY
from . import util


def _path(*a):
    return os.path.join(*((os.path.dirname(__file__),) + a))


            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 19 Column: 9

                             _path('src', 'mixed', 'foo_free.f90')]

    def test_all(self):
        assert_(self.module.bar11() == 11)
        assert_(self.module.foo_fixed.bar12() == 12)
        assert_(self.module.foo_free.bar13() == 13)

    @pytest.mark.xfail(IS_PYPY,
                       reason="PyPy cannot modify tp_doc after PyType_Ready")

            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 20 Column: 9

              
    def test_all(self):
        assert_(self.module.bar11() == 11)
        assert_(self.module.foo_fixed.bar12() == 12)
        assert_(self.module.foo_free.bar13() == 13)

    @pytest.mark.xfail(IS_PYPY,
                       reason="PyPy cannot modify tp_doc after PyType_Ready")
    def test_docstring(self):

            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 21 Column: 9

                  def test_all(self):
        assert_(self.module.bar11() == 11)
        assert_(self.module.foo_fixed.bar12() == 12)
        assert_(self.module.foo_free.bar13() == 13)

    @pytest.mark.xfail(IS_PYPY,
                       reason="PyPy cannot modify tp_doc after PyType_Ready")
    def test_docstring(self):
        expected = textwrap.dedent("""\

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import os
import textwrap
import pytest

from numpy.testing import assert_, assert_equal, IS_PYPY
from . import util


def _path(*a):

            

Reported by Pylint.

Missing class docstring
Error

Line: 13 Column: 1

                  return os.path.join(*((os.path.dirname(__file__),) + a))


class TestMixed(util.F2PyTest):
    sources = [_path('src', 'mixed', 'foo.f'),
               _path('src', 'mixed', 'foo_fixed.f90'),
               _path('src', 'mixed', 'foo_free.f90')]

    def test_all(self):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 18 Column: 5

                             _path('src', 'mixed', 'foo_fixed.f90'),
               _path('src', 'mixed', 'foo_free.f90')]

    def test_all(self):
        assert_(self.module.bar11() == 11)
        assert_(self.module.foo_fixed.bar12() == 12)
        assert_(self.module.foo_free.bar13() == 13)

    @pytest.mark.xfail(IS_PYPY,

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 25 Column: 5

              
    @pytest.mark.xfail(IS_PYPY,
                       reason="PyPy cannot modify tp_doc after PyType_Ready")
    def test_docstring(self):
        expected = textwrap.dedent("""\
        a = bar11()

        Wrapper for ``bar11``.


            

Reported by Pylint.

numpy/distutils/tests/test_fcompiler_nagfor.py
9 issues
Using deprecated method assert_()
Error

Line: 22 Column: 13

                      for comp, vs, version in nag_version_strings:
            fc = numpy.distutils.fcompiler.new_fcompiler(compiler=comp)
            v = fc.version_match(vs)
            assert_(v == version)

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from numpy.testing import assert_
import numpy.distutils.fcompiler

nag_version_strings = [('nagfor', 'NAG Fortran Compiler Release '
                        '6.2(Chiyoda) Build 6200', '6.2'),
                       ('nagfor', 'NAG Fortran Compiler Release '
                        '6.1(Tozai) Build 6136', '6.1'),
                       ('nagfor', 'NAG Fortran Compiler Release '
                        '6.0(Hibiya) Build 1021', '6.0'),

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 17 Column: 1

                                      '431,435,437,446,459-460,463,472,494,496,503,508,'
                        '511,517,529,555,557,565)', '5.1')]

class TestNagFCompilerVersions:
    def test_version_match(self):
        for comp, vs, version in nag_version_strings:
            fc = numpy.distutils.fcompiler.new_fcompiler(compiler=comp)
            v = fc.version_match(vs)
            assert_(v == version)

            

Reported by Pylint.

Missing class docstring
Error

Line: 17 Column: 1

                                      '431,435,437,446,459-460,463,472,494,496,503,508,'
                        '511,517,529,555,557,565)', '5.1')]

class TestNagFCompilerVersions:
    def test_version_match(self):
        for comp, vs, version in nag_version_strings:
            fc = numpy.distutils.fcompiler.new_fcompiler(compiler=comp)
            v = fc.version_match(vs)
            assert_(v == version)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 18 Column: 5

                                      '511,517,529,555,557,565)', '5.1')]

class TestNagFCompilerVersions:
    def test_version_match(self):
        for comp, vs, version in nag_version_strings:
            fc = numpy.distutils.fcompiler.new_fcompiler(compiler=comp)
            v = fc.version_match(vs)
            assert_(v == version)

            

Reported by Pylint.

Method could be a function
Error

Line: 18 Column: 5

                                      '511,517,529,555,557,565)', '5.1')]

class TestNagFCompilerVersions:
    def test_version_match(self):
        for comp, vs, version in nag_version_strings:
            fc = numpy.distutils.fcompiler.new_fcompiler(compiler=comp)
            v = fc.version_match(vs)
            assert_(v == version)

            

Reported by Pylint.

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

Line: 19 Column: 19

              
class TestNagFCompilerVersions:
    def test_version_match(self):
        for comp, vs, version in nag_version_strings:
            fc = numpy.distutils.fcompiler.new_fcompiler(compiler=comp)
            v = fc.version_match(vs)
            assert_(v == version)

            

Reported by Pylint.

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

Line: 20 Column: 13

              class TestNagFCompilerVersions:
    def test_version_match(self):
        for comp, vs, version in nag_version_strings:
            fc = numpy.distutils.fcompiler.new_fcompiler(compiler=comp)
            v = fc.version_match(vs)
            assert_(v == version)

            

Reported by Pylint.

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

Line: 21 Column: 13

                  def test_version_match(self):
        for comp, vs, version in nag_version_strings:
            fc = numpy.distutils.fcompiler.new_fcompiler(compiler=comp)
            v = fc.version_match(vs)
            assert_(v == version)

            

Reported by Pylint.

numpy/distutils/__init__.py
9 issues
Unable to import '__init__.npy_pkg_config'
Error

Line: 27 Column: 1

              from . import ccompiler
from . import unixccompiler

from .npy_pkg_config import *

# If numpy is installed, add distutils.test()
try:
    from . import __config__
    # Normally numpy is installed if the above import works, but an interrupted

            

Reported by Pylint.

Module import itself
Error

Line: 24 Column: 1

              
# Must import local ccompiler ASAP in order to get
# customized CCompiler.spawn effective.
from . import ccompiler
from . import unixccompiler

from .npy_pkg_config import *

# If numpy is installed, add distutils.test()

            

Reported by Pylint.

Module import itself
Error

Line: 25 Column: 1

              # Must import local ccompiler ASAP in order to get
# customized CCompiler.spawn effective.
from . import ccompiler
from . import unixccompiler

from .npy_pkg_config import *

# If numpy is installed, add distutils.test()
try:

            

Reported by Pylint.

Module import itself
Error

Line: 31 Column: 5

              
# If numpy is installed, add distutils.test()
try:
    from . import __config__
    # Normally numpy is installed if the above import works, but an interrupted
    # in-place build could also have left a __config__.py.  In that case the
    # next import may still fail, so keep it inside the try block.
    from numpy._pytesttester import PytestTester
    test = PytestTester(__name__)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 42 Column: 1

                  pass


def customized_fcompiler(plat=None, compiler=None):
    from numpy.distutils.fcompiler import new_fcompiler
    c = new_fcompiler(plat=plat, compiler=compiler)
    c.customize()
    return c


            

Reported by Pylint.

Import outside toplevel (numpy.distutils.fcompiler.new_fcompiler)
Error

Line: 43 Column: 5

              

def customized_fcompiler(plat=None, compiler=None):
    from numpy.distutils.fcompiler import new_fcompiler
    c = new_fcompiler(plat=plat, compiler=compiler)
    c.customize()
    return c

def customized_ccompiler(plat=None, compiler=None, verbose=1):

            

Reported by Pylint.

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

Line: 44 Column: 5

              
def customized_fcompiler(plat=None, compiler=None):
    from numpy.distutils.fcompiler import new_fcompiler
    c = new_fcompiler(plat=plat, compiler=compiler)
    c.customize()
    return c

def customized_ccompiler(plat=None, compiler=None, verbose=1):
    c = ccompiler.new_compiler(plat=plat, compiler=compiler, verbose=verbose)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 48 Column: 1

                  c.customize()
    return c

def customized_ccompiler(plat=None, compiler=None, verbose=1):
    c = ccompiler.new_compiler(plat=plat, compiler=compiler, verbose=verbose)
    c.customize('')
    return c

            

Reported by Pylint.

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

Line: 49 Column: 5

                  return c

def customized_ccompiler(plat=None, compiler=None, verbose=1):
    c = ccompiler.new_compiler(plat=plat, compiler=compiler, verbose=verbose)
    c.customize('')
    return c

            

Reported by Pylint.

numpy/core/_asarray.py
9 issues
Attempted relative import beyond top-level package
Error

Line: 6 Column: 1

              
`require` fits this category despite its name not matching this pattern.
"""
from .overrides import (
    array_function_dispatch,
    set_array_function_like_doc,
    set_module,
)
from .multiarray import array, asanyarray

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 11 Column: 1

                  set_array_function_like_doc,
    set_module,
)
from .multiarray import array, asanyarray


__all__ = ["require"]



            

Reported by Pylint.

Unused argument 'requirements'
Error

Line: 18 Column: 40

              


def _require_dispatcher(a, dtype=None, requirements=None, *, like=None):
    return (like,)


@set_array_function_like_doc
@set_module('numpy')

            

Reported by Pylint.

Unused argument 'dtype'
Error

Line: 18 Column: 28

              


def _require_dispatcher(a, dtype=None, requirements=None, *, like=None):
    return (like,)


@set_array_function_like_doc
@set_module('numpy')

            

Reported by Pylint.

Unused argument 'a'
Error

Line: 18 Column: 25

              


def _require_dispatcher(a, dtype=None, requirements=None, *, like=None):
    return (like,)


@set_array_function_like_doc
@set_module('numpy')

            

Reported by Pylint.

Argument name "a" doesn't conform to snake_case naming style
Error

Line: 18 Column: 1

              


def _require_dispatcher(a, dtype=None, requirements=None, *, like=None):
    return (like,)


@set_array_function_like_doc
@set_module('numpy')

            

Reported by Pylint.

Argument name "a" doesn't conform to snake_case naming style
Error

Line: 24 Column: 1

              
@set_array_function_like_doc
@set_module('numpy')
def require(a, dtype=None, requirements=None, *, like=None):
    """
    Return an ndarray of the provided type that satisfies requirements.

    This function is useful to be sure that an array with the correct flags
    is returned for passing to compiled code (perhaps through ctypes).

            

Reported by Pylint.

Unnecessary "else" after "return"
Error

Line: 108 Column: 5

                                    'W': 'W', 'WRITEABLE': 'W',
                      'O': 'O', 'OWNDATA': 'O',
                      'E': 'E', 'ENSUREARRAY': 'E'}
    if not requirements:
        return asanyarray(a, dtype=dtype)
    else:
        requirements = {possible_flags[x.upper()] for x in requirements}

    if 'E' in requirements:

            

Reported by Pylint.

Unnecessary "elif" after "raise"
Error

Line: 120 Column: 5

                      subok = True

    order = 'A'
    if requirements >= {'C', 'F'}:
        raise ValueError('Cannot specify both "C" and "F" order')
    elif 'F' in requirements:
        order = 'F'
        requirements.remove('F')
    elif 'C' in requirements:

            

Reported by Pylint.

benchmarks/asv_pip_nopep517.py
9 issues
Instance of 'Exception' has no 'output' member
Error

Line: 10 Column: 18

              try:
    output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, universal_newlines=True)
except Exception as e:
    output = str(e.output)
if "no such option" in output:
    print("old version of pip, escape '--no-use-pep517'")
    cmd.pop()

subprocess.run(cmd + sys.argv[1:])

            

Reported by Pylint.

Catching too general exception Exception
Error

Line: 9 Column: 8

              cmd = [sys.executable, '-mpip', 'wheel', '--no-use-pep517']
try:
    output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, universal_newlines=True)
except Exception as e:
    output = str(e.output)
if "no such option" in output:
    print("old version of pip, escape '--no-use-pep517'")
    cmd.pop()


            

Reported by Pylint.

Using subprocess.run without explicitly set `check` is not recommended.
Error

Line: 15 Column: 1

                  print("old version of pip, escape '--no-use-pep517'")
    cmd.pop()

subprocess.run(cmd + sys.argv[1:])

            

Reported by Pylint.

Multiple imports on one line (subprocess, sys)
Error

Line: 4 Column: 1

              """
This file is used by asv_compare.conf.json.tpl.
"""
import subprocess, sys
# pip ignores '--global-option' when pep517 is enabled therefore we disable it.
cmd = [sys.executable, '-mpip', 'wheel', '--no-use-pep517']
try:
    output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, universal_newlines=True)
except Exception as e:

            

Reported by Pylint.

Consider possible security implications associated with subprocess module.
Security blacklist

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

              """
This file is used by asv_compare.conf.json.tpl.
"""
import subprocess, sys
# pip ignores '--global-option' when pep517 is enabled therefore we disable it.
cmd = [sys.executable, '-mpip', 'wheel', '--no-use-pep517']
try:
    output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, universal_newlines=True)
except Exception as e:

            

Reported by Bandit.

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

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

              # pip ignores '--global-option' when pep517 is enabled therefore we disable it.
cmd = [sys.executable, '-mpip', 'wheel', '--no-use-pep517']
try:
    output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, universal_newlines=True)
except Exception as e:
    output = str(e.output)
if "no such option" in output:
    print("old version of pip, escape '--no-use-pep517'")
    cmd.pop()

            

Reported by Bandit.

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

Line: 9 Column: 1

              cmd = [sys.executable, '-mpip', 'wheel', '--no-use-pep517']
try:
    output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, universal_newlines=True)
except Exception as e:
    output = str(e.output)
if "no such option" in output:
    print("old version of pip, escape '--no-use-pep517'")
    cmd.pop()


            

Reported by Pylint.

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

Line: 10 Column: 5

              try:
    output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, universal_newlines=True)
except Exception as e:
    output = str(e.output)
if "no such option" in output:
    print("old version of pip, escape '--no-use-pep517'")
    cmd.pop()

subprocess.run(cmd + sys.argv[1:])

            

Reported by Pylint.

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

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

                  print("old version of pip, escape '--no-use-pep517'")
    cmd.pop()

subprocess.run(cmd + sys.argv[1:])

            

Reported by Bandit.