The following issues were found

numpy/f2py/f2py_testing.py
9 issues
Use of possibly insecure function - consider using safer ast.literal_eval.
Security blacklist

Line: 13
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b307-eval

                  repeat = 1
    for a in sys.argv[1:]:
        if m.match(a):
            repeat = eval(a)
        else:
            args.append(a)
    f2py_opts = ' '.join(args)
    return repeat, f2py_opts


            

Reported by Bandit.

Use of eval
Error

Line: 13 Column: 22

                  repeat = 1
    for a in sys.argv[1:]:
        if m.match(a):
            repeat = eval(a)
        else:
            args.append(a)
    f2py_opts = ' '.join(args)
    return repeat, f2py_opts


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import sys
import re

from numpy.testing import jiffies, memusage


def cmdline():
    m = re.compile(r'\A\d+\Z')
    args = []

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 7 Column: 1

              from numpy.testing import jiffies, memusage


def cmdline():
    m = re.compile(r'\A\d+\Z')
    args = []
    repeat = 1
    for a in sys.argv[1:]:
        if m.match(a):

            

Reported by Pylint.

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

Line: 8 Column: 5

              

def cmdline():
    m = re.compile(r'\A\d+\Z')
    args = []
    repeat = 1
    for a in sys.argv[1:]:
        if m.match(a):
            repeat = eval(a)

            

Reported by Pylint.

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

Line: 11 Column: 9

                  m = re.compile(r'\A\d+\Z')
    args = []
    repeat = 1
    for a in sys.argv[1:]:
        if m.match(a):
            repeat = eval(a)
        else:
            args.append(a)
    f2py_opts = ' '.join(args)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 20 Column: 1

                  return repeat, f2py_opts


def run(runtest, test_functions, repeat=1):
    l = [(t, repr(t.__doc__.split('\n')[1].strip())) for t in test_functions]
    start_memusage = memusage()
    diff_memusage = None
    start_jiffies = jiffies()
    i = 0

            

Reported by Pylint.

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

Line: 21 Column: 5

              

def run(runtest, test_functions, repeat=1):
    l = [(t, repr(t.__doc__.split('\n')[1].strip())) for t in test_functions]
    start_memusage = memusage()
    diff_memusage = None
    start_jiffies = jiffies()
    i = 0
    while i < repeat:

            

Reported by Pylint.

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

Line: 28 Column: 13

                  i = 0
    while i < repeat:
        i += 1
        for t, fname in l:
            runtest(t)
            if start_memusage is None:
                continue
            if diff_memusage is None:
                diff_memusage = memusage() - start_memusage

            

Reported by Pylint.

doc/source/reference/random/performance.py
9 issues
Unable to import 'pandas'
Error

Line: 3 Column: 1

              from timeit import repeat

import pandas as pd

import numpy as np
from numpy.random import MT19937, PCG64, PCG64DXSM, Philox, SFC64

PRNGS = [MT19937, PCG64, PCG64DXSM, Philox, SFC64]


            

Reported by Pylint.

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

Line: 58 Column: 9

              
columns = ['MT19937', 'PCG64', 'PCG64DXSM', 'Philox', 'SFC64', 'RandomState']
table = pd.DataFrame(table)
order = np.log(table).mean().sort_values().index
table = table.T
table = table.reindex(columns)
table = table.T
table = table.reindex([k for k in funcs], axis=0)
print(table.to_csv(float_format='%0.1f'))

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from timeit import repeat

import pandas as pd

import numpy as np
from numpy.random import MT19937, PCG64, PCG64DXSM, Philox, SFC64

PRNGS = [MT19937, PCG64, PCG64DXSM, Philox, SFC64]


            

Reported by Pylint.

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

Line: 11 Column: 1

              PRNGS = [MT19937, PCG64, PCG64DXSM, Philox, SFC64]

funcs = {}
integers = 'integers(0, 2**{bits},size=1000000, dtype="uint{bits}")'
funcs['32-bit Unsigned Ints'] = integers.format(bits=32)
funcs['64-bit Unsigned Ints'] = integers.format(bits=64)
funcs['Uniforms'] = 'random(size=1000000)'
funcs['Normals'] = 'standard_normal(size=1000000)'
funcs['Exponentials'] = 'standard_exponential(size=1000000)'

            

Reported by Pylint.

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

Line: 22 Column: 1

              funcs['Laplaces'] = 'laplace(size=1000000)'
funcs['Poissons'] = 'poisson(3.0, size=1000000)'

setup = """
from numpy.random import {prng}, Generator
rg = Generator({prng}())
"""

test = "rg.{func}"

            

Reported by Pylint.

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

Line: 27 Column: 1

              rg = Generator({prng}())
"""

test = "rg.{func}"
table = {}
for prng in PRNGS:
    print(prng)
    col = {}
    for key in funcs:

            

Reported by Pylint.

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

Line: 44 Column: 1

              npfuncs.update(funcs)
npfuncs['32-bit Unsigned Ints'] = 'randint(2**32,dtype="uint32",size=1000000)'
npfuncs['64-bit Unsigned Ints'] = 'randint(2**64,dtype="uint64",size=1000000)'
setup = """
from numpy.random import RandomState
rg = RandomState()
"""
col = {}
for key in npfuncs:

            

Reported by Pylint.

Unnecessary use of a comprehension
Error

Line: 62 Column: 1

              table = table.T
table = table.reindex(columns)
table = table.T
table = table.reindex([k for k in funcs], axis=0)
print(table.to_csv(float_format='%0.1f'))


rel = table.loc[:, ['RandomState']].values @ np.ones(
    (1, table.shape[1])) / table

            

Reported by Pylint.

Trailing newlines
Error

Line: 86 Column: 1

              print(xplat.T.round(1))




            

Reported by Pylint.

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

Line: 4 Column: 7

              from typing import List, Any
import numpy as np

AR_i: np.ndarray[Any, np.dtype[np.int64]]
AR_f: np.ndarray[Any, np.dtype[np.float64]]
AR_m: np.ndarray[Any, np.dtype[np.timedelta64]]
AR_O: np.ndarray[Any, np.dtype[np.object_]]
AR_U: np.ndarray[Any, np.dtype[np.str_]]


            

Reported by Pylint.

Value 'np.ndarray' is unsubscriptable
Error

Line: 5 Column: 7

              import numpy as np

AR_i: np.ndarray[Any, np.dtype[np.int64]]
AR_f: np.ndarray[Any, np.dtype[np.float64]]
AR_m: np.ndarray[Any, np.dtype[np.timedelta64]]
AR_O: np.ndarray[Any, np.dtype[np.object_]]
AR_U: np.ndarray[Any, np.dtype[np.str_]]

np.einsum("i,i->i", AR_i, AR_m)  # E: incompatible type

            

Reported by Pylint.

Value 'np.ndarray' is unsubscriptable
Error

Line: 6 Column: 7

              
AR_i: np.ndarray[Any, np.dtype[np.int64]]
AR_f: np.ndarray[Any, np.dtype[np.float64]]
AR_m: np.ndarray[Any, np.dtype[np.timedelta64]]
AR_O: np.ndarray[Any, np.dtype[np.object_]]
AR_U: np.ndarray[Any, np.dtype[np.str_]]

np.einsum("i,i->i", AR_i, AR_m)  # E: incompatible type
np.einsum("i,i->i", AR_O, AR_O)  # E: incompatible type

            

Reported by Pylint.

Value 'np.ndarray' is unsubscriptable
Error

Line: 7 Column: 7

              AR_i: np.ndarray[Any, np.dtype[np.int64]]
AR_f: np.ndarray[Any, np.dtype[np.float64]]
AR_m: np.ndarray[Any, np.dtype[np.timedelta64]]
AR_O: np.ndarray[Any, np.dtype[np.object_]]
AR_U: np.ndarray[Any, np.dtype[np.str_]]

np.einsum("i,i->i", AR_i, AR_m)  # E: incompatible type
np.einsum("i,i->i", AR_O, AR_O)  # E: incompatible type
np.einsum("i,i->i", AR_f, AR_f, dtype=np.int32)  # E: incompatible type

            

Reported by Pylint.

Value 'np.ndarray' is unsubscriptable
Error

Line: 8 Column: 7

              AR_f: np.ndarray[Any, np.dtype[np.float64]]
AR_m: np.ndarray[Any, np.dtype[np.timedelta64]]
AR_O: np.ndarray[Any, np.dtype[np.object_]]
AR_U: np.ndarray[Any, np.dtype[np.str_]]

np.einsum("i,i->i", AR_i, AR_m)  # E: incompatible type
np.einsum("i,i->i", AR_O, AR_O)  # E: incompatible type
np.einsum("i,i->i", AR_f, AR_f, dtype=np.int32)  # E: incompatible type
np.einsum("i,i->i", AR_i, AR_i, dtype=np.timedelta64, casting="unsafe")  # E: No overload variant

            

Reported by Pylint.

Unused List imported from typing
Error

Line: 1 Column: 1

              from typing import List, Any
import numpy as np

AR_i: np.ndarray[Any, np.dtype[np.int64]]
AR_f: np.ndarray[Any, np.dtype[np.float64]]
AR_m: np.ndarray[Any, np.dtype[np.timedelta64]]
AR_O: np.ndarray[Any, np.dtype[np.object_]]
AR_U: np.ndarray[Any, np.dtype[np.str_]]


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from typing import List, Any
import numpy as np

AR_i: np.ndarray[Any, np.dtype[np.int64]]
AR_f: np.ndarray[Any, np.dtype[np.float64]]
AR_m: np.ndarray[Any, np.dtype[np.timedelta64]]
AR_O: np.ndarray[Any, np.dtype[np.object_]]
AR_U: np.ndarray[Any, np.dtype[np.str_]]


            

Reported by Pylint.

Line too long (105/100)
Error

Line: 14 Column: 1

              np.einsum("i,i->i", AR_O, AR_O)  # E: incompatible type
np.einsum("i,i->i", AR_f, AR_f, dtype=np.int32)  # E: incompatible type
np.einsum("i,i->i", AR_i, AR_i, dtype=np.timedelta64, casting="unsafe")  # E: No overload variant
np.einsum("i,i->i", AR_i, AR_i, out=AR_U)  # E: Value of type variable "_ArrayType" of "einsum" cannot be
np.einsum("i,i->i", AR_i, AR_i, out=AR_U, casting="unsafe")  # E: No overload variant

            

Reported by Pylint.

numpy/core/tests/test_machar.py
8 issues
Fixme, this needs to raise a 'skip' exception.
Error

Line: 19 Column: 3

                          hiprec = ntypes.float96
            MachAr(lambda v: array(v, hiprec))
        except AttributeError:
            # Fixme, this needs to raise a 'skip' exception.
            "Skipping test: no ntypes.float96 available on this platform."

    def test_underlow(self):
        # Regression test for #759:
        # instantiating MachAr for dtype = np.float96 raises spurious warning.

            

Reported by Pylint.

String statement has no effect
Error

Line: 20 Column: 13

                          MachAr(lambda v: array(v, hiprec))
        except AttributeError:
            # Fixme, this needs to raise a 'skip' exception.
            "Skipping test: no ntypes.float96 available on this platform."

    def test_underlow(self):
        # Regression test for #759:
        # instantiating MachAr for dtype = np.float96 raises spurious warning.
        with errstate(all='raise'):

            

Reported by Pylint.

Consider explicitly re-raising using the 'from' keyword
Error

Line: 30 Column: 17

                              self._run_machar_highprec()
            except FloatingPointError as e:
                msg = "Caught %s exception, should not have been raised." % e
                raise AssertionError(msg)

            

Reported by Pylint.

Missing class docstring
Error

Line: 11 Column: 1

              from numpy import errstate, array


class TestMachAr:
    def _run_machar_highprec(self):
        # Instantiate MachAr instance with high enough precision to cause
        # underflow
        try:
            hiprec = ntypes.float96

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 11 Column: 1

              from numpy import errstate, array


class TestMachAr:
    def _run_machar_highprec(self):
        # Instantiate MachAr instance with high enough precision to cause
        # underflow
        try:
            hiprec = ntypes.float96

            

Reported by Pylint.

Method could be a function
Error

Line: 12 Column: 5

              

class TestMachAr:
    def _run_machar_highprec(self):
        # Instantiate MachAr instance with high enough precision to cause
        # underflow
        try:
            hiprec = ntypes.float96
            MachAr(lambda v: array(v, hiprec))

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 22 Column: 5

                          # Fixme, this needs to raise a 'skip' exception.
            "Skipping test: no ntypes.float96 available on this platform."

    def test_underlow(self):
        # Regression test for #759:
        # instantiating MachAr for dtype = np.float96 raises spurious warning.
        with errstate(all='raise'):
            try:
                self._run_machar_highprec()

            

Reported by Pylint.

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

Line: 28 Column: 13

                      with errstate(all='raise'):
            try:
                self._run_machar_highprec()
            except FloatingPointError as e:
                msg = "Caught %s exception, should not have been raised." % e
                raise AssertionError(msg)

            

Reported by Pylint.

numpy/compat/tests/test_compat.py
8 issues
Using deprecated method assert_()
Error

Line: 13 Column: 13

                      filename = join(folder, 'a.bin')

        with open(filename, 'wb') as f:
            assert_(isfileobj(f))

        with open(filename, 'ab') as f:
            assert_(isfileobj(f))

        with open(filename, 'rb') as f:

            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 16 Column: 13

                          assert_(isfileobj(f))

        with open(filename, 'ab') as f:
            assert_(isfileobj(f))

        with open(filename, 'rb') as f:
            assert_(isfileobj(f))

            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 19 Column: 13

                          assert_(isfileobj(f))

        with open(filename, 'rb') as f:
            assert_(isfileobj(f))

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from os.path import join

from numpy.compat import isfileobj
from numpy.testing import assert_
from numpy.testing import tempdir


def test_isfileobj():
    with tempdir(prefix="numpy_test_compat_") as folder:

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 8 Column: 1

              from numpy.testing import tempdir


def test_isfileobj():
    with tempdir(prefix="numpy_test_compat_") as folder:
        filename = join(folder, 'a.bin')

        with open(filename, 'wb') as f:
            assert_(isfileobj(f))

            

Reported by Pylint.

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

Line: 12 Column: 38

                  with tempdir(prefix="numpy_test_compat_") as folder:
        filename = join(folder, 'a.bin')

        with open(filename, 'wb') as f:
            assert_(isfileobj(f))

        with open(filename, 'ab') as f:
            assert_(isfileobj(f))


            

Reported by Pylint.

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

Line: 15 Column: 38

                      with open(filename, 'wb') as f:
            assert_(isfileobj(f))

        with open(filename, 'ab') as f:
            assert_(isfileobj(f))

        with open(filename, 'rb') as f:
            assert_(isfileobj(f))

            

Reported by Pylint.

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

Line: 18 Column: 38

                      with open(filename, 'ab') as f:
            assert_(isfileobj(f))

        with open(filename, 'rb') as f:
            assert_(isfileobj(f))

            

Reported by Pylint.

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

Line: 5 Column: 1

              
compilers = ['NVHPCFCompiler']

class NVHPCFCompiler(FCompiler):
    """ NVIDIA High Performance Computing (HPC) SDK Fortran Compiler
   
    https://developer.nvidia.com/hpc-sdk
   
    Since august 2020 the NVIDIA HPC SDK includes the compilers formerly known as The Portland Group compilers,

            

Reported by Pylint.

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

Line: 5 Column: 1

              
compilers = ['NVHPCFCompiler']

class NVHPCFCompiler(FCompiler):
    """ NVIDIA High Performance Computing (HPC) SDK Fortran Compiler
   
    https://developer.nvidia.com/hpc-sdk
   
    Since august 2020 the NVIDIA HPC SDK includes the compilers formerly known as The Portland Group compilers,

            

Reported by Pylint.

Redefining built-in 'dir'
Error

Line: 46 Column: 42

                  def get_flags_linker_so(self):
        return ["-shared", '-fpic']

    def runtime_library_dir_option(self, dir):
        return '-R%s' % dir

if __name__ == '__main__':
    from distutils import log
    log.set_verbosity(2)

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from numpy.distutils.fcompiler import FCompiler

compilers = ['NVHPCFCompiler']

class NVHPCFCompiler(FCompiler):
    """ NVIDIA High Performance Computing (HPC) SDK Fortran Compiler
   
    https://developer.nvidia.com/hpc-sdk
   

            

Reported by Pylint.

Trailing whitespace
Error

Line: 7 Column: 1

              
class NVHPCFCompiler(FCompiler):
    """ NVIDIA High Performance Computing (HPC) SDK Fortran Compiler
   
    https://developer.nvidia.com/hpc-sdk
   
    Since august 2020 the NVIDIA HPC SDK includes the compilers formerly known as The Portland Group compilers,
    https://www.pgroup.com/index.htm.
    See also `numpy.distutils.fcompiler.pg`.

            

Reported by Pylint.

Trailing whitespace
Error

Line: 9 Column: 1

                  """ NVIDIA High Performance Computing (HPC) SDK Fortran Compiler
   
    https://developer.nvidia.com/hpc-sdk
   
    Since august 2020 the NVIDIA HPC SDK includes the compilers formerly known as The Portland Group compilers,
    https://www.pgroup.com/index.htm.
    See also `numpy.distutils.fcompiler.pg`.
    """


            

Reported by Pylint.

Line too long (111/100)
Error

Line: 10 Column: 1

                 
    https://developer.nvidia.com/hpc-sdk
   
    Since august 2020 the NVIDIA HPC SDK includes the compilers formerly known as The Portland Group compilers,
    https://www.pgroup.com/index.htm.
    See also `numpy.distutils.fcompiler.pg`.
    """

    compiler_type = 'nv'

            

Reported by Pylint.

Line too long (102/100)
Error

Line: 17 Column: 1

              
    compiler_type = 'nv'
    description = 'NVIDIA HPC SDK'
    version_pattern = r'\s*(nvfortran|(pg(f77|f90|fortran)) \(aka nvfortran\)) (?P<version>[\d.-]+).*'

    executables = {
        'version_cmd': ["<F90>", "-V"],
        'compiler_f77': ["nvfortran"],
        'compiler_fix': ["nvfortran", "-Mfixed"],

            

Reported by Pylint.

numpy/f2py/tests/test_module_doc.py
8 issues
Unable to import 'pytest'
Error

Line: 3 Column: 1

              import os
import sys
import pytest
import textwrap

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



            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 6 Column: 1

              import pytest
import textwrap

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


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

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import os
import sys
import pytest
import textwrap

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



            

Reported by Pylint.

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

Line: 4 Column: 1

              import os
import sys
import pytest
import textwrap

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



            

Reported by Pylint.

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

Line: 7 Column: 1

              import textwrap

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


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


            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 14 Column: 1

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


class TestModuleDocString(util.F2PyTest):
    sources = [_path('src', 'module_data', 'module_data_docstring.f90')]

    @pytest.mark.skipif(sys.platform=='win32',
                        reason='Fails with MinGW64 Gfortran (Issue #9673)')
    @pytest.mark.xfail(IS_PYPY,

            

Reported by Pylint.

Missing class docstring
Error

Line: 14 Column: 1

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


class TestModuleDocString(util.F2PyTest):
    sources = [_path('src', 'module_data', 'module_data_docstring.f90')]

    @pytest.mark.skipif(sys.platform=='win32',
                        reason='Fails with MinGW64 Gfortran (Issue #9673)')
    @pytest.mark.xfail(IS_PYPY,

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 21 Column: 5

                                      reason='Fails with MinGW64 Gfortran (Issue #9673)')
    @pytest.mark.xfail(IS_PYPY,
                       reason="PyPy cannot modify tp_doc after PyType_Ready")
    def test_module_docstring(self):
        assert_equal(self.module.mod.__doc__,
                     textwrap.dedent('''\
                     i : 'i'-scalar
                     x : 'i'-array(4)
                     a : 'f'-array(2,3)

            

Reported by Pylint.

numpy/random/_examples/cffi/parse.py
8 issues
Missing module docstring
Error

Line: 1 Column: 1

              import os


def parse_distributions_h(ffi, inc_dir):
    """
    Parse distributions.h located in inc_dir for CFFI, filling in the ffi.cdef

    Read the function declarations without the "#define ..." macros that will
    be filled in when loading the library.

            

Reported by Pylint.

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

Line: 13 Column: 9

                  """

    with open(os.path.join(inc_dir, 'random', 'bitgen.h')) as fid:
        s = []
        for line in fid:
            # massage the include file
            if line.strip().startswith('#'):
                continue
            s.append(line)

            

Reported by Pylint.

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

Line: 22 Column: 9

                      ffi.cdef('\n'.join(s))

    with open(os.path.join(inc_dir, 'random', 'distributions.h')) as fid:
        s = []
        in_skip = 0
        ignoring = False
        for line in fid:
            # check for and remove extern "C" guards
            if ignoring:

            

Reported by Pylint.

Trailing whitespace
Error

Line: 33 Column: 1

                              continue
            if line.strip().startswith('#ifdef __cplusplus'):
                ignoring = True
            
            # massage the include file
            if line.strip().startswith('#'):
                continue
    
            # skip any inlined function definition

            

Reported by Pylint.

Trailing whitespace
Error

Line: 37 Column: 1

                          # massage the include file
            if line.strip().startswith('#'):
                continue
    
            # skip any inlined function definition
            # which starts with 'static NPY_INLINE xxx(...) {'
            # and ends with a closing '}'
            if line.strip().startswith('static NPY_INLINE'):
                in_skip += line.count('{')

            

Reported by Pylint.

Unnecessary "elif" after "continue"
Error

Line: 41 Column: 13

                          # skip any inlined function definition
            # which starts with 'static NPY_INLINE xxx(...) {'
            # and ends with a closing '}'
            if line.strip().startswith('static NPY_INLINE'):
                in_skip += line.count('{')
                continue
            elif in_skip > 0:
                in_skip += line.count('{')
                in_skip -= line.count('}')

            

Reported by Pylint.

Trailing whitespace
Error

Line: 48 Column: 1

                              in_skip += line.count('{')
                in_skip -= line.count('}')
                continue
    
            # replace defines with their value or remove them
            line = line.replace('DECLDIR', '')
            line = line.replace('NPY_INLINE', '')
            line = line.replace('RAND_INT_TYPE', 'int64_t')
            s.append(line)

            

Reported by Pylint.

Trailing newlines
Error

Line: 55 Column: 1

                          line = line.replace('RAND_INT_TYPE', 'int64_t')
            s.append(line)
        ffi.cdef('\n'.join(s))


            

Reported by Pylint.

numpy/core/tests/test_argparse.py
8 issues
Unable to import 'pytest'
Error

Line: 14 Column: 1

                      return None
"""

import pytest

import numpy as np
from numpy.core._multiarray_tests import argparse_example_function as func



            

Reported by Pylint.

Unable to import 'numpy.core._multiarray_tests'
Error

Line: 17 Column: 1

              import pytest

import numpy as np
from numpy.core._multiarray_tests import argparse_example_function as func


def test_invalid_integers():
    with pytest.raises(TypeError,
            match="integer argument expected, got float"):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 20 Column: 1

              from numpy.core._multiarray_tests import argparse_example_function as func


def test_invalid_integers():
    with pytest.raises(TypeError,
            match="integer argument expected, got float"):
        func(1.)
    with pytest.raises(OverflowError):
        func(2**100)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 28 Column: 1

                      func(2**100)


def test_missing_arguments():
    with pytest.raises(TypeError,
            match="missing required positional argument 0"):
        func()
    with pytest.raises(TypeError,
            match="missing required positional argument 0"):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 40 Column: 1

                      func(1, arg3=5)


def test_too_many_positional():
    # the second argument is positional but can be passed as keyword.
    with pytest.raises(TypeError,
            match="takes from 2 to 3 positional arguments but 4 were given"):
        func(1, 2, 3, 4)


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 47 Column: 1

                      func(1, 2, 3, 4)


def test_multiple_values():
    with pytest.raises(TypeError,
            match=r"given by name \('arg2'\) and position \(position 1\)"):
        func(1, 2, arg2=3)



            

Reported by Pylint.

Missing function or method docstring
Error

Line: 53 Column: 1

                      func(1, 2, arg2=3)


def test_string_fallbacks():
    # We can (currently?) use numpy strings to test the "slow" fallbacks
    # that should normally not be taken due to string interning.
    arg2 = np.unicode_("arg2")
    missing_arg = np.unicode_("missing_arg")
    func(1, **{arg2: 3})

            

Reported by Pylint.

Trailing newlines
Error

Line: 62 Column: 1

                  with pytest.raises(TypeError,
            match="got an unexpected keyword argument 'missing_arg'"):
        func(2, **{missing_arg: 3})


            

Reported by Pylint.

numpy/f2py/tests/test_kind.py
8 issues
Unable to import 'pytest'
Error

Line: 2 Column: 1

              import os
import pytest

from numpy.testing import assert_
from numpy.f2py.crackfortran import (
    _selected_int_kind_func as selected_int_kind,
    _selected_real_kind_func as selected_real_kind
    )
from . import util

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 9 Column: 1

                  _selected_int_kind_func as selected_int_kind,
    _selected_real_kind_func as selected_real_kind
    )
from . import util


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


            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 25 Column: 13

                      selectedintkind = self.module.selectedintkind

        for i in range(40):
            assert_(selectedintkind(i) in [selected_int_kind(i), -1],
                    'selectedintkind(%s): expected %r but got %r' %
                    (i, selected_int_kind(i), selectedintkind(i)))

        for i in range(20):
            assert_(selectedrealkind(i) in [selected_real_kind(i), -1],

            

Reported by Pylint.

Using deprecated method assert_()
Error

Line: 30 Column: 13

                                  (i, selected_int_kind(i), selectedintkind(i)))

        for i in range(20):
            assert_(selectedrealkind(i) in [selected_real_kind(i), -1],
                    'selectedrealkind(%s): expected %r but got %r' %
                    (i, selected_real_kind(i), selectedrealkind(i)))

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import os
import pytest

from numpy.testing import assert_
from numpy.f2py.crackfortran import (
    _selected_int_kind_func as selected_int_kind,
    _selected_real_kind_func as selected_real_kind
    )
from . import util

            

Reported by Pylint.

Missing class docstring
Error

Line: 16 Column: 1

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


class TestKind(util.F2PyTest):
    sources = [_path('src', 'kind', 'foo.f90')]

    @pytest.mark.slow
    def test_all(self):
        selectedrealkind = self.module.selectedrealkind

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 16 Column: 1

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


class TestKind(util.F2PyTest):
    sources = [_path('src', 'kind', 'foo.f90')]

    @pytest.mark.slow
    def test_all(self):
        selectedrealkind = self.module.selectedrealkind

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 20 Column: 5

                  sources = [_path('src', 'kind', 'foo.f90')]

    @pytest.mark.slow
    def test_all(self):
        selectedrealkind = self.module.selectedrealkind
        selectedintkind = self.module.selectedintkind

        for i in range(40):
            assert_(selectedintkind(i) in [selected_int_kind(i), -1],

            

Reported by Pylint.