The following issues were found

numpy/matrixlib/tests/test_multiarray.py
11 issues
Using deprecated method assert_()
Error

Line: 7 Column: 9

              class TestView:
    def test_type(self):
        x = np.array([1, 2, 3])
        assert_(isinstance(x.view(np.matrix), np.matrix))

    def test_keywords(self):
        x = np.array([(1, 2)], dtype=[('a', np.int8), ('b', np.int8)])
        # We must be specific about the endianness here:
        y = x.view(dtype='<i2', type=np.matrix)

            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 15 Column: 9

                      y = x.view(dtype='<i2', type=np.matrix)
        assert_array_equal(y, [[513]])

        assert_(isinstance(y, np.matrix))
        assert_equal(y.dtype, np.dtype('<i2'))

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import numpy as np
from numpy.testing import assert_, assert_equal, assert_array_equal

class TestView:
    def test_type(self):
        x = np.array([1, 2, 3])
        assert_(isinstance(x.view(np.matrix), np.matrix))

    def test_keywords(self):

            

Reported by Pylint.

Missing class docstring
Error

Line: 4 Column: 1

              import numpy as np
from numpy.testing import assert_, assert_equal, assert_array_equal

class TestView:
    def test_type(self):
        x = np.array([1, 2, 3])
        assert_(isinstance(x.view(np.matrix), np.matrix))

    def test_keywords(self):

            

Reported by Pylint.

Method could be a function
Error

Line: 5 Column: 5

              from numpy.testing import assert_, assert_equal, assert_array_equal

class TestView:
    def test_type(self):
        x = np.array([1, 2, 3])
        assert_(isinstance(x.view(np.matrix), np.matrix))

    def test_keywords(self):
        x = np.array([(1, 2)], dtype=[('a', np.int8), ('b', np.int8)])

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 5 Column: 5

              from numpy.testing import assert_, assert_equal, assert_array_equal

class TestView:
    def test_type(self):
        x = np.array([1, 2, 3])
        assert_(isinstance(x.view(np.matrix), np.matrix))

    def test_keywords(self):
        x = np.array([(1, 2)], dtype=[('a', np.int8), ('b', np.int8)])

            

Reported by Pylint.

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

Line: 6 Column: 9

              
class TestView:
    def test_type(self):
        x = np.array([1, 2, 3])
        assert_(isinstance(x.view(np.matrix), np.matrix))

    def test_keywords(self):
        x = np.array([(1, 2)], dtype=[('a', np.int8), ('b', np.int8)])
        # We must be specific about the endianness here:

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 9 Column: 5

                      x = np.array([1, 2, 3])
        assert_(isinstance(x.view(np.matrix), np.matrix))

    def test_keywords(self):
        x = np.array([(1, 2)], dtype=[('a', np.int8), ('b', np.int8)])
        # We must be specific about the endianness here:
        y = x.view(dtype='<i2', type=np.matrix)
        assert_array_equal(y, [[513]])


            

Reported by Pylint.

Method could be a function
Error

Line: 9 Column: 5

                      x = np.array([1, 2, 3])
        assert_(isinstance(x.view(np.matrix), np.matrix))

    def test_keywords(self):
        x = np.array([(1, 2)], dtype=[('a', np.int8), ('b', np.int8)])
        # We must be specific about the endianness here:
        y = x.view(dtype='<i2', type=np.matrix)
        assert_array_equal(y, [[513]])


            

Reported by Pylint.

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

Line: 10 Column: 9

                      assert_(isinstance(x.view(np.matrix), np.matrix))

    def test_keywords(self):
        x = np.array([(1, 2)], dtype=[('a', np.int8), ('b', np.int8)])
        # We must be specific about the endianness here:
        y = x.view(dtype='<i2', type=np.matrix)
        assert_array_equal(y, [[513]])

        assert_(isinstance(y, np.matrix))

            

Reported by Pylint.

tools/linter.py
11 issues
Instance of 'Exception' has no 'GitCommandError' member
Error

Line: 36 Column: 16

                      """
        try:
            commit = self.repo.merge_base(self.branch, self.head)[0]
        except exc.GitCommandError:
            print(f"Branch with name `{self.branch}` does not exist")
            sys.exit(1)

        exclude = [f':(exclude){i}' for i in EXCLUDE]
        if uncommitted:

            

Reported by Pylint.

Instance of 'GitError' has no 'GitCommandError' member
Error

Line: 36 Column: 16

                      """
        try:
            commit = self.repo.merge_base(self.branch, self.head)[0]
        except exc.GitCommandError:
            print(f"Branch with name `{self.branch}` does not exist")
            sys.exit(1)

        exclude = [f':(exclude){i}' for i in EXCLUDE]
        if uncommitted:

            

Reported by Pylint.

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

Line: 58 Column: 15

                            https://github.com/scipy/scipy/blob/main/tools/lint_diff.py
            Run pycodestyle on the given diff.
        """
        res = subprocess.run(
            ['pycodestyle', '--diff', '--config', CONFIG],
            input=diff,
            stdout=subprocess.PIPE,
            encoding='utf-8',
        )

            

Reported by Pylint.

Expression "errors and print(errors)" is assigned to nothing
Error

Line: 70 Column: 9

                      diff = self.get_branch_diff(uncommitted)
        retcode, errors = self.run_pycodestyle(diff)

        errors and print(errors)

        sys.exit(retcode)


if __name__ == '__main__':

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import os
import sys
import subprocess
from argparse import ArgumentParser
from git import Repo, exc

CONFIG = os.path.join(
         os.path.abspath(os.path.dirname(__file__)),
         'lint_diff.ini',

            

Reported by Pylint.

Consider possible security implications associated with subprocess module.
Security blacklist

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

              import os
import sys
import subprocess
from argparse import ArgumentParser
from git import Repo, exc

CONFIG = os.path.join(
         os.path.abspath(os.path.dirname(__file__)),
         'lint_diff.ini',

            

Reported by Bandit.

Missing class docstring
Error

Line: 21 Column: 1

              )


class DiffLinter:
    def __init__(self, branch):
        self.branch = branch
        self.repo = Repo('.')
        self.head = self.repo.head.commit


            

Reported by Pylint.

Method could be a function
Error

Line: 51 Column: 5

                          )
        return diff

    def run_pycodestyle(self, diff):
        """
            Original Author: Josh Wilson (@person142)
            Source:
              https://github.com/scipy/scipy/blob/main/tools/lint_diff.py
            Run pycodestyle on the given diff.

            

Reported by Pylint.

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

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

                            https://github.com/scipy/scipy/blob/main/tools/lint_diff.py
            Run pycodestyle on the given diff.
        """
        res = subprocess.run(
            ['pycodestyle', '--diff', '--config', CONFIG],
            input=diff,
            stdout=subprocess.PIPE,
            encoding='utf-8',
        )

            

Reported by Bandit.

Starting a process with a partial executable path
Security injection

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

                            https://github.com/scipy/scipy/blob/main/tools/lint_diff.py
            Run pycodestyle on the given diff.
        """
        res = subprocess.run(
            ['pycodestyle', '--diff', '--config', CONFIG],
            input=diff,
            stdout=subprocess.PIPE,
            encoding='utf-8',
        )

            

Reported by Bandit.

numpy/core/tests/test_protocols.py
11 issues
Unable to import 'pytest'
Error

Line: 1 Column: 1

              import pytest
import warnings
import numpy as np


@pytest.mark.filterwarnings("error")
def test_getattr_warning():
    # issue gh-14735: make sure we clear only getattr errors, and let warnings
    # through

            

Reported by Pylint.

Unused argument 'result'
Error

Line: 37 Column: 29

              def test_array_called():
    class Wrapper:
        val = '0' * 100
        def __array__(self, result=None):
            return np.array([self.val], dtype=object)


    wrapped = Wrapper()
    arr = np.array(wrapped, dtype=str)

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import pytest
import warnings
import numpy as np


@pytest.mark.filterwarnings("error")
def test_getattr_warning():
    # issue gh-14735: make sure we clear only getattr errors, and let warnings
    # through

            

Reported by Pylint.

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

Line: 2 Column: 1

              import pytest
import warnings
import numpy as np


@pytest.mark.filterwarnings("error")
def test_getattr_warning():
    # issue gh-14735: make sure we clear only getattr errors, and let warnings
    # through

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 7 Column: 1

              

@pytest.mark.filterwarnings("error")
def test_getattr_warning():
    # issue gh-14735: make sure we clear only getattr errors, and let warnings
    # through
    class Wrapper:
        def __init__(self, array):
            self.array = array

            

Reported by Pylint.

Missing class docstring
Error

Line: 10 Column: 5

              def test_getattr_warning():
    # issue gh-14735: make sure we clear only getattr errors, and let warnings
    # through
    class Wrapper:
        def __init__(self, array):
            self.array = array

        def __len__(self):
            return len(self.array)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 34 Column: 1

                      np.asarray(array)


def test_array_called():
    class Wrapper:
        val = '0' * 100
        def __array__(self, result=None):
            return np.array([self.val], dtype=object)


            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 35 Column: 5

              

def test_array_called():
    class Wrapper:
        val = '0' * 100
        def __array__(self, result=None):
            return np.array([self.val], dtype=object)



            

Reported by Pylint.

Missing class docstring
Error

Line: 35 Column: 5

              

def test_array_called():
    class Wrapper:
        val = '0' * 100
        def __array__(self, result=None):
            return np.array([self.val], dtype=object)



            

Reported by Pylint.

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

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

              
    wrapped = Wrapper()
    arr = np.array(wrapped, dtype=str)
    assert arr.dtype == 'U100'
    assert arr[0] == Wrapper.val

            

Reported by Bandit.

numpy/distutils/fcompiler/absoft.py
11 issues
Method 'find_library_file' is abstract in class 'CCompiler' but is not overridden
Error

Line: 16 Column: 1

              
compilers = ['AbsoftFCompiler']

class AbsoftFCompiler(FCompiler):

    compiler_type = 'absoft'
    description = 'Absoft Corp Fortran Compiler'
    #version_pattern = r'FORTRAN 77 Compiler (?P<version>[^\s*,]*).*?Absoft Corp'
    version_pattern = r'(f90:.*?(Absoft Pro FORTRAN Version|FORTRAN 77 Compiler|Absoft Fortran Compiler Version|Copyright Absoft Corporation.*?Version))'+\

            

Reported by Pylint.

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

Line: 16 Column: 1

              
compilers = ['AbsoftFCompiler']

class AbsoftFCompiler(FCompiler):

    compiler_type = 'absoft'
    description = 'Absoft Corp Fortran Compiler'
    #version_pattern = r'FORTRAN 77 Compiler (?P<version>[^\s*,]*).*?Absoft Corp'
    version_pattern = r'(f90:.*?(Absoft Pro FORTRAN Version|FORTRAN 77 Compiler|Absoft Fortran Compiler Version|Copyright Absoft Corporation.*?Version))'+\

            

Reported by Pylint.

Method 'wrap_unlinkable_objects' is abstract in class 'FCompiler' but is not overridden
Error

Line: 16 Column: 1

              
compilers = ['AbsoftFCompiler']

class AbsoftFCompiler(FCompiler):

    compiler_type = 'absoft'
    description = 'Absoft Corp Fortran Compiler'
    #version_pattern = r'FORTRAN 77 Compiler (?P<version>[^\s*,]*).*?Absoft Corp'
    version_pattern = r'(f90:.*?(Absoft Pro FORTRAN Version|FORTRAN 77 Compiler|Absoft Fortran Compiler Version|Copyright Absoft Corporation.*?Version))'+\

            

Reported by Pylint.

Redefining built-in 'dir'
Error

Line: 65 Column: 34

                          opt = ["-K", "shared"]
        return opt

    def library_dir_option(self, dir):
        if os.name=='nt':
            return ['-link', '/PATH:%s' % (dir)]
        return "-L" + dir

    def library_option(self, lib):

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              
# http://www.absoft.com/literature/osxuserguide.pdf
# http://www.absoft.com/documentation.html

# Notes:
# - when using -g77 then use -DUNDERSCORE_G77 to compile f2py
#   generated extension modules (works for f2py v2.45.241_1936 and up)
import os


            

Reported by Pylint.

Missing class docstring
Error

Line: 16 Column: 1

              
compilers = ['AbsoftFCompiler']

class AbsoftFCompiler(FCompiler):

    compiler_type = 'absoft'
    description = 'Absoft Corp Fortran Compiler'
    #version_pattern = r'FORTRAN 77 Compiler (?P<version>[^\s*,]*).*?Absoft Corp'
    version_pattern = r'(f90:.*?(Absoft Pro FORTRAN Version|FORTRAN 77 Compiler|Absoft Fortran Compiler Version|Copyright Absoft Corporation.*?Version))'+\

            

Reported by Pylint.

Line too long (155/100)
Error

Line: 21 Column: 1

                  compiler_type = 'absoft'
    description = 'Absoft Corp Fortran Compiler'
    #version_pattern = r'FORTRAN 77 Compiler (?P<version>[^\s*,]*).*?Absoft Corp'
    version_pattern = r'(f90:.*?(Absoft Pro FORTRAN Version|FORTRAN 77 Compiler|Absoft Fortran Compiler Version|Copyright Absoft Corporation.*?Version))'+\
                       r' (?P<version>[^\s*,]*)(.*?Absoft Corp|)'

    # on windows: f90 -V -c dummy.f
    # f90: Copyright Absoft Corporation 1994-1998 mV2; Cray Research, Inc. 1994-1996 CF90 (2.x.x.x  f36t87) Version 2.3 Wed Apr 19, 2006  13:05:16


            

Reported by Pylint.

Line too long (146/100)
Error

Line: 25 Column: 1

                                     r' (?P<version>[^\s*,]*)(.*?Absoft Corp|)'

    # on windows: f90 -V -c dummy.f
    # f90: Copyright Absoft Corporation 1994-1998 mV2; Cray Research, Inc. 1994-1996 CF90 (2.x.x.x  f36t87) Version 2.3 Wed Apr 19, 2006  13:05:16

    # samt5735(8)$ f90 -V -c dummy.f
    # f90: Copyright Absoft Corporation 1994-2002; Absoft Pro FORTRAN Version 8.0
    # Note that fink installs g77 as f77, so need to use f90 for detection.


            

Reported by Pylint.

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

Line: 48 Column: 9

                  module_include_switch = '-p'

    def update_executables(self):
        f = cyg2win32(dummy_fortran_file())
        self.executables['version_cmd'] = ['<F90>', '-V', '-c',
                                           f+'.f', '-o', f+'.o']

    def get_flags_linker_so(self):
        if os.name=='nt':

            

Reported by Pylint.

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

Line: 77 Column: 9

              
    def get_library_dirs(self):
        opt = FCompiler.get_library_dirs(self)
        d = os.environ.get('ABSOFT')
        if d:
            if self.get_version() >= '10.0':
                # use shared libraries, the static libraries were not compiled -fPIC
                prefix = 'sh'
            else:

            

Reported by Pylint.

numpy/typing/tests/data/reveal/datasource.py
10 issues
Undefined variable 'reveal_type'
Error

Line: 11 Column: 1

              d2 = np.DataSource(path2)
d3 = np.DataSource(None)

reveal_type(d1.abspath("..."))  # E: str
reveal_type(d2.abspath("..."))  # E: str
reveal_type(d3.abspath("..."))  # E: str

reveal_type(d1.exists("..."))  # E: bool
reveal_type(d2.exists("..."))  # E: bool

            

Reported by Pylint.

Undefined variable 'reveal_type'
Error

Line: 12 Column: 1

              d3 = np.DataSource(None)

reveal_type(d1.abspath("..."))  # E: str
reveal_type(d2.abspath("..."))  # E: str
reveal_type(d3.abspath("..."))  # E: str

reveal_type(d1.exists("..."))  # E: bool
reveal_type(d2.exists("..."))  # E: bool
reveal_type(d3.exists("..."))  # E: bool

            

Reported by Pylint.

Undefined variable 'reveal_type'
Error

Line: 13 Column: 1

              
reveal_type(d1.abspath("..."))  # E: str
reveal_type(d2.abspath("..."))  # E: str
reveal_type(d3.abspath("..."))  # E: str

reveal_type(d1.exists("..."))  # E: bool
reveal_type(d2.exists("..."))  # E: bool
reveal_type(d3.exists("..."))  # E: bool


            

Reported by Pylint.

Undefined variable 'reveal_type'
Error

Line: 15 Column: 1

              reveal_type(d2.abspath("..."))  # E: str
reveal_type(d3.abspath("..."))  # E: str

reveal_type(d1.exists("..."))  # E: bool
reveal_type(d2.exists("..."))  # E: bool
reveal_type(d3.exists("..."))  # E: bool

reveal_type(d1.open("...", "r"))  # E: IO[Any]
reveal_type(d2.open("...", encoding="utf8"))  # E: IO[Any]

            

Reported by Pylint.

Undefined variable 'reveal_type'
Error

Line: 16 Column: 1

              reveal_type(d3.abspath("..."))  # E: str

reveal_type(d1.exists("..."))  # E: bool
reveal_type(d2.exists("..."))  # E: bool
reveal_type(d3.exists("..."))  # E: bool

reveal_type(d1.open("...", "r"))  # E: IO[Any]
reveal_type(d2.open("...", encoding="utf8"))  # E: IO[Any]
reveal_type(d3.open("...", newline="/n"))  # E: IO[Any]

            

Reported by Pylint.

Undefined variable 'reveal_type'
Error

Line: 17 Column: 1

              
reveal_type(d1.exists("..."))  # E: bool
reveal_type(d2.exists("..."))  # E: bool
reveal_type(d3.exists("..."))  # E: bool

reveal_type(d1.open("...", "r"))  # E: IO[Any]
reveal_type(d2.open("...", encoding="utf8"))  # E: IO[Any]
reveal_type(d3.open("...", newline="/n"))  # E: IO[Any]

            

Reported by Pylint.

Undefined variable 'reveal_type'
Error

Line: 19 Column: 1

              reveal_type(d2.exists("..."))  # E: bool
reveal_type(d3.exists("..."))  # E: bool

reveal_type(d1.open("...", "r"))  # E: IO[Any]
reveal_type(d2.open("...", encoding="utf8"))  # E: IO[Any]
reveal_type(d3.open("...", newline="/n"))  # E: IO[Any]

            

Reported by Pylint.

Undefined variable 'reveal_type'
Error

Line: 20 Column: 1

              reveal_type(d3.exists("..."))  # E: bool

reveal_type(d1.open("...", "r"))  # E: IO[Any]
reveal_type(d2.open("...", encoding="utf8"))  # E: IO[Any]
reveal_type(d3.open("...", newline="/n"))  # E: IO[Any]

            

Reported by Pylint.

Undefined variable 'reveal_type'
Error

Line: 21 Column: 1

              
reveal_type(d1.open("...", "r"))  # E: IO[Any]
reveal_type(d2.open("...", encoding="utf8"))  # E: IO[Any]
reveal_type(d3.open("...", newline="/n"))  # E: IO[Any]

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from pathlib import Path
import numpy as np

path1: Path
path2: str

d1 = np.DataSource(path1)
d2 = np.DataSource(path2)
d3 = np.DataSource(None)

            

Reported by Pylint.

numpy/typing/tests/data/pass/flatiter.py
10 issues
Instance of 'ndarray' has no 'coords' member
Error

Line: 7 Column: 1

              
a.base
a.copy()
a.coords
a.index
iter(a)
next(a)
a[0]
a[[0, 1, 2]]

            

Reported by Pylint.

Instance of 'ndarray' has no 'index' member
Error

Line: 8 Column: 1

              a.base
a.copy()
a.coords
a.index
iter(a)
next(a)
a[0]
a[[0, 1, 2]]
a[...]

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 5 Column: 1

              
a = np.empty((2, 2)).flat

a.base
a.copy()
a.coords
a.index
iter(a)
next(a)

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 7 Column: 1

              
a.base
a.copy()
a.coords
a.index
iter(a)
next(a)
a[0]
a[[0, 1, 2]]

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 8 Column: 1

              a.base
a.copy()
a.coords
a.index
iter(a)
next(a)
a[0]
a[[0, 1, 2]]
a[...]

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 11 Column: 1

              a.index
iter(a)
next(a)
a[0]
a[[0, 1, 2]]
a[...]
a[:]
a.__array__()
a.__array__(np.dtype(np.float64))

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 12 Column: 1

              iter(a)
next(a)
a[0]
a[[0, 1, 2]]
a[...]
a[:]
a.__array__()
a.__array__(np.dtype(np.float64))

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 13 Column: 1

              next(a)
a[0]
a[[0, 1, 2]]
a[...]
a[:]
a.__array__()
a.__array__(np.dtype(np.float64))

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 14 Column: 1

              a[0]
a[[0, 1, 2]]
a[...]
a[:]
a.__array__()
a.__array__(np.dtype(np.float64))

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import numpy as np

a = np.empty((2, 2)).flat

a.base
a.copy()
a.coords
a.index
iter(a)

            

Reported by Pylint.

benchmarks/benchmarks/bench_trim_zeros.py
10 issues
Attempted relative import beyond top-level package
Error

Line: 1 Column: 1

              from .common import Benchmark

import numpy as np

_FLOAT = np.dtype('float64')
_COMPLEX = np.dtype('complex128')
_INT = np.dtype('int64')
_BOOL = np.dtype('bool')


            

Reported by Pylint.

Attribute 'array' defined outside __init__
Error

Line: 20 Column: 9

              
    def setup(self, dtype, size):
        n = size // 3
        self.array = np.hstack([
            np.zeros(n),
            np.random.uniform(size=n),
            np.zeros(n),
        ]).astype(dtype)


            

Reported by Pylint.

Unused argument 'dtype'
Error

Line: 26 Column: 31

                          np.zeros(n),
        ]).astype(dtype)

    def time_trim_zeros(self, dtype, size):
        np.trim_zeros(self.array)

            

Reported by Pylint.

Unused argument 'size'
Error

Line: 26 Column: 38

                          np.zeros(n),
        ]).astype(dtype)

    def time_trim_zeros(self, dtype, size):
        np.trim_zeros(self.array)

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from .common import Benchmark

import numpy as np

_FLOAT = np.dtype('float64')
_COMPLEX = np.dtype('complex128')
_INT = np.dtype('int64')
_BOOL = np.dtype('bool')


            

Reported by Pylint.

third party import "import numpy as np" should be placed before "from .common import Benchmark"
Error

Line: 3 Column: 1

              from .common import Benchmark

import numpy as np

_FLOAT = np.dtype('float64')
_COMPLEX = np.dtype('complex128')
_INT = np.dtype('int64')
_BOOL = np.dtype('bool')


            

Reported by Pylint.

Missing class docstring
Error

Line: 11 Column: 1

              _BOOL = np.dtype('bool')


class TrimZeros(Benchmark):
    param_names = ["dtype", "size"]
    params = [
        [_INT, _FLOAT, _COMPLEX, _BOOL],
        [3000, 30_000, 300_000]
    ]

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 18 Column: 5

                      [3000, 30_000, 300_000]
    ]

    def setup(self, dtype, size):
        n = size // 3
        self.array = np.hstack([
            np.zeros(n),
            np.random.uniform(size=n),
            np.zeros(n),

            

Reported by Pylint.

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

Line: 19 Column: 9

                  ]

    def setup(self, dtype, size):
        n = size // 3
        self.array = np.hstack([
            np.zeros(n),
            np.random.uniform(size=n),
            np.zeros(n),
        ]).astype(dtype)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 26 Column: 5

                          np.zeros(n),
        ]).astype(dtype)

    def time_trim_zeros(self, dtype, size):
        np.trim_zeros(self.array)

            

Reported by Pylint.

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

Line: 2 Column: 1

              import platform
import pytest

from . import util
from numpy.testing import assert_equal

@pytest.mark.skipif(
    platform.system() == 'Darwin',
    reason="Prone to error when run with numpy/f2py/tests on mac os, "

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 4 Column: 1

              import platform
import pytest

from . import util
from numpy.testing import assert_equal

@pytest.mark.skipif(
    platform.system() == 'Darwin',
    reason="Prone to error when run with numpy/f2py/tests on mac os, "

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import platform
import pytest

from . import util
from numpy.testing import assert_equal

@pytest.mark.skipif(
    platform.system() == 'Darwin',
    reason="Prone to error when run with numpy/f2py/tests on mac os, "

            

Reported by Pylint.

third party import "from numpy.testing import assert_equal" should be placed before "from . import util"
Error

Line: 5 Column: 1

              import pytest

from . import util
from numpy.testing import assert_equal

@pytest.mark.skipif(
    platform.system() == 'Darwin',
    reason="Prone to error when run with numpy/f2py/tests on mac os, "
           "but not when run in isolation")

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 11 Column: 1

                  platform.system() == 'Darwin',
    reason="Prone to error when run with numpy/f2py/tests on mac os, "
           "but not when run in isolation")
class TestMultiline(util.F2PyTest):
    suffix = ".pyf"
    module_name = "multiline"
    code = """
python module {module}
    usercode '''

            

Reported by Pylint.

Missing class docstring
Error

Line: 11 Column: 1

                  platform.system() == 'Darwin',
    reason="Prone to error when run with numpy/f2py/tests on mac os, "
           "but not when run in isolation")
class TestMultiline(util.F2PyTest):
    suffix = ".pyf"
    module_name = "multiline"
    code = """
python module {module}
    usercode '''

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 31 Column: 5

              end python module {module}
    """.format(module=module_name)

    def test_multiline(self):
        assert_equal(self.module.foo(), 42)


@pytest.mark.skipif(
    platform.system() == 'Darwin',

            

Reported by Pylint.

Missing class docstring
Error

Line: 39 Column: 1

                  platform.system() == 'Darwin',
    reason="Prone to error when run with numpy/f2py/tests on mac os, "
           "but not when run in isolation")
class TestCallstatement(util.F2PyTest):
    suffix = ".pyf"
    module_name = "callstatement"
    code = """
python module {module}
    usercode '''

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 39 Column: 1

                  platform.system() == 'Darwin',
    reason="Prone to error when run with numpy/f2py/tests on mac os, "
           "but not when run in isolation")
class TestCallstatement(util.F2PyTest):
    suffix = ".pyf"
    module_name = "callstatement"
    code = """
python module {module}
    usercode '''

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 62 Column: 5

              end python module {module}
    """.format(module=module_name)

    def test_callstatement(self):
        assert_equal(self.module.foo(), 42)

            

Reported by Pylint.

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

Line: 6 Column: 1

              this is private API, but when added, public API may be added here.
"""

import pytest

import numpy as np
from numpy.core._multiarray_umath import _get_castingimpl as get_castingimpl



            

Reported by Pylint.

Unable to import 'numpy.core._multiarray_umath'
Error

Line: 9 Column: 1

              import pytest

import numpy as np
from numpy.core._multiarray_umath import _get_castingimpl as get_castingimpl


class TestResolveDescriptors:
    # Test mainly error paths of the resolve_descriptors function,
    # note that the `casting_unittests` tests exercise this non-error paths.

            

Reported by Pylint.

Access to a protected member _resolve_descriptors of a client class
Error

Line: 29 Column: 13

                  ])
    def test_invalid_arguments(self, args):
        with pytest.raises(TypeError):
            self.method._resolve_descriptors(*args)


class TestSimpleStridedCall:
    # Test mainly error paths of the resolve_descriptors function,
    # note that the `casting_unittests` tests exercise this non-error paths.

            

Reported by Pylint.

Access to a protected member _simple_strided_call of a client class
Error

Line: 58 Column: 13

                  def test_invalid_arguments(self, args, error):
        # This is private API, which may be modified freely
        with pytest.raises(error):
            self.method._simple_strided_call(*args)

            

Reported by Pylint.

Missing class docstring
Error

Line: 12 Column: 1

              from numpy.core._multiarray_umath import _get_castingimpl as get_castingimpl


class TestResolveDescriptors:
    # Test mainly error paths of the resolve_descriptors function,
    # note that the `casting_unittests` tests exercise this non-error paths.

    # Casting implementations are the main/only current user:
    method = get_castingimpl(type(np.dtype("d")), type(np.dtype("f")))

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 12 Column: 1

              from numpy.core._multiarray_umath import _get_castingimpl as get_castingimpl


class TestResolveDescriptors:
    # Test mainly error paths of the resolve_descriptors function,
    # note that the `casting_unittests` tests exercise this non-error paths.

    # Casting implementations are the main/only current user:
    method = get_castingimpl(type(np.dtype("d")), type(np.dtype("f")))

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 26 Column: 5

                      ((None, None),),  # Input dtype is None, which is invalid.
        ((np.dtype("d"), True),),  # Output dtype is not a dtype
        ((np.dtype("f"), None),),  # Input dtype does not match method
    ])
    def test_invalid_arguments(self, args):
        with pytest.raises(TypeError):
            self.method._resolve_descriptors(*args)



            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 32 Column: 1

                          self.method._resolve_descriptors(*args)


class TestSimpleStridedCall:
    # Test mainly error paths of the resolve_descriptors function,
    # note that the `casting_unittests` tests exercise this non-error paths.

    # Casting implementations are the main/only current user:
    method = get_castingimpl(type(np.dtype("d")), type(np.dtype("f")))

            

Reported by Pylint.

Missing class docstring
Error

Line: 32 Column: 1

                          self.method._resolve_descriptors(*args)


class TestSimpleStridedCall:
    # Test mainly error paths of the resolve_descriptors function,
    # note that the `casting_unittests` tests exercise this non-error paths.

    # Casting implementations are the main/only current user:
    method = get_castingimpl(type(np.dtype("d")), type(np.dtype("f")))

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 54 Column: 5

                      (((np.frombuffer(b"\0x00"*3*2, dtype="d"),
           np.frombuffer(b"\0x00"*3, dtype="f")),),
         ValueError),  # output not writeable
    ])
    def test_invalid_arguments(self, args, error):
        # This is private API, which may be modified freely
        with pytest.raises(error):
            self.method._simple_strided_call(*args)

            

Reported by Pylint.

numpy/typing/tests/data/reveal/nbit_base_example.py
10 issues
Value 'np.floating' is unsubscriptable
Error

Line: 8 Column: 51

              T1 = TypeVar("T1", bound=npt.NBitBase)
T2 = TypeVar("T2", bound=npt.NBitBase)

def add(a: np.floating[T1], b: np.integer[T2]) -> np.floating[Union[T1, T2]]:
    return a + b

i8: np.int64
i4: np.int32
f8: np.float64

            

Reported by Pylint.

Value 'np.floating' is unsubscriptable
Error

Line: 8 Column: 12

              T1 = TypeVar("T1", bound=npt.NBitBase)
T2 = TypeVar("T2", bound=npt.NBitBase)

def add(a: np.floating[T1], b: np.integer[T2]) -> np.floating[Union[T1, T2]]:
    return a + b

i8: np.int64
i4: np.int32
f8: np.float64

            

Reported by Pylint.

Undefined variable 'reveal_type'
Error

Line: 16 Column: 1

              f8: np.float64
f4: np.float32

reveal_type(add(f8, i8))  # E: {float64}
reveal_type(add(f4, i8))  # E: {float64}
reveal_type(add(f8, i4))  # E: {float64}
reveal_type(add(f4, i4))  # E: {float32}

            

Reported by Pylint.

Undefined variable 'reveal_type'
Error

Line: 17 Column: 1

              f4: np.float32

reveal_type(add(f8, i8))  # E: {float64}
reveal_type(add(f4, i8))  # E: {float64}
reveal_type(add(f8, i4))  # E: {float64}
reveal_type(add(f4, i4))  # E: {float32}

            

Reported by Pylint.

Undefined variable 'reveal_type'
Error

Line: 18 Column: 1

              
reveal_type(add(f8, i8))  # E: {float64}
reveal_type(add(f4, i8))  # E: {float64}
reveal_type(add(f8, i4))  # E: {float64}
reveal_type(add(f4, i4))  # E: {float32}

            

Reported by Pylint.

Undefined variable 'reveal_type'
Error

Line: 19 Column: 1

              reveal_type(add(f8, i8))  # E: {float64}
reveal_type(add(f4, i8))  # E: {float64}
reveal_type(add(f8, i4))  # E: {float64}
reveal_type(add(f4, i4))  # E: {float32}

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from typing import TypeVar, Union
import numpy as np
import numpy.typing as npt

T1 = TypeVar("T1", bound=npt.NBitBase)
T2 = TypeVar("T2", bound=npt.NBitBase)

def add(a: np.floating[T1], b: np.integer[T2]) -> np.floating[Union[T1, T2]]:
    return a + b

            

Reported by Pylint.

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

Line: 8 Column: 1

              T1 = TypeVar("T1", bound=npt.NBitBase)
T2 = TypeVar("T2", bound=npt.NBitBase)

def add(a: np.floating[T1], b: np.integer[T2]) -> np.floating[Union[T1, T2]]:
    return a + b

i8: np.int64
i4: np.int32
f8: np.float64

            

Reported by Pylint.

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

Line: 8 Column: 1

              T1 = TypeVar("T1", bound=npt.NBitBase)
T2 = TypeVar("T2", bound=npt.NBitBase)

def add(a: np.floating[T1], b: np.integer[T2]) -> np.floating[Union[T1, T2]]:
    return a + b

i8: np.int64
i4: np.int32
f8: np.float64

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 8 Column: 1

              T1 = TypeVar("T1", bound=npt.NBitBase)
T2 = TypeVar("T2", bound=npt.NBitBase)

def add(a: np.floating[T1], b: np.integer[T2]) -> np.floating[Union[T1, T2]]:
    return a + b

i8: np.int64
i4: np.int32
f8: np.float64

            

Reported by Pylint.