The following issues were found
numpy/typing/_dtype_like.py
17 issues
Line: 6
Column: 1
import numpy as np
from . import _HAS_TYPING_EXTENSIONS
from ._shape import _ShapeLike
from ._generic_alias import _DType as DType
if sys.version_info >= (3, 8):
from typing import Protocol, TypedDict
Reported by Pylint.
Line: 7
Column: 1
import numpy as np
from . import _HAS_TYPING_EXTENSIONS
from ._shape import _ShapeLike
from ._generic_alias import _DType as DType
if sys.version_info >= (3, 8):
from typing import Protocol, TypedDict
elif _HAS_TYPING_EXTENSIONS:
Reported by Pylint.
Line: 8
Column: 1
from . import _HAS_TYPING_EXTENSIONS
from ._shape import _ShapeLike
from ._generic_alias import _DType as DType
if sys.version_info >= (3, 8):
from typing import Protocol, TypedDict
elif _HAS_TYPING_EXTENSIONS:
from typing_extensions import Protocol, TypedDict
Reported by Pylint.
Line: 13
Column: 5
if sys.version_info >= (3, 8):
from typing import Protocol, TypedDict
elif _HAS_TYPING_EXTENSIONS:
from typing_extensions import Protocol, TypedDict
else:
from ._generic_alias import _GenericAlias as GenericAlias
from ._char_codes import (
_BoolCodes,
Reported by Pylint.
Line: 15
Column: 5
elif _HAS_TYPING_EXTENSIONS:
from typing_extensions import Protocol, TypedDict
else:
from ._generic_alias import _GenericAlias as GenericAlias
from ._char_codes import (
_BoolCodes,
_UInt8Codes,
_UInt16Codes,
Reported by Pylint.
Line: 17
Column: 1
else:
from ._generic_alias import _GenericAlias as GenericAlias
from ._char_codes import (
_BoolCodes,
_UInt8Codes,
_UInt16Codes,
_UInt32Codes,
_UInt64Codes,
Reported by Pylint.
Line: 59
Column: 3
_ObjectCodes,
)
_DTypeLikeNested = Any # TODO: wait for support for recursive types
_DType_co = TypeVar("_DType_co", covariant=True, bound=DType[Any])
if TYPE_CHECKING or _HAS_TYPING_EXTENSIONS or sys.version_info >= (3, 8):
# Mandatory keys
class _DTypeDictBase(TypedDict):
Reported by Pylint.
Line: 113
Column: 3
# default data type (float64)
None,
# array-scalar types and generic types
Type[Any], # TODO: enumerate these when we add type hints for numpy scalars
# anything with a dtype attribute
_SupportsDType[DType[Any]],
# character codes, type strings or comma-separated fields, e.g., 'float64'
str,
_VoidDTypeLike,
Reported by Pylint.
Line: 1
Column: 1
import sys
from typing import Any, List, Sequence, Tuple, Union, Type, TypeVar, TYPE_CHECKING
import numpy as np
from . import _HAS_TYPING_EXTENSIONS
from ._shape import _ShapeLike
from ._generic_alias import _DType as DType
Reported by Pylint.
Line: 17
Column: 1
else:
from ._generic_alias import _GenericAlias as GenericAlias
from ._char_codes import (
_BoolCodes,
_UInt8Codes,
_UInt16Codes,
_UInt32Codes,
_UInt64Codes,
Reported by Pylint.
numpy/distutils/command/install.py
17 issues
Line: 22
Column: 9
def finalize_options (self):
old_install.finalize_options(self)
self.install_lib = self.install_libbase
def setuptools_run(self):
""" The setuptools version of the .run() method.
We must pull in the entire code so we can override the level used in the
Reported by Pylint.
Line: 44
Column: 18
# called by 'run_commands'. This is slightly kludgy, but seems to
# work.
#
caller = sys._getframe(3)
caller_module = caller.f_globals.get('__name__', '')
caller_name = caller.f_code.co_name
if caller_module != 'distutils.dist' or caller_name!='run_commands':
# We weren't called from the command line or setup(), so we
Reported by Pylint.
Line: 1
Column: 1
import sys
if 'setuptools' in sys.modules:
import setuptools.command.install as old_install_mod
have_setuptools = True
else:
import distutils.command.install as old_install_mod
have_setuptools = False
from distutils.file_util import write_file
Reported by Pylint.
Line: 4
Column: 5
import sys
if 'setuptools' in sys.modules:
import setuptools.command.install as old_install_mod
have_setuptools = True
else:
import distutils.command.install as old_install_mod
have_setuptools = False
from distutils.file_util import write_file
Reported by Pylint.
Line: 7
Column: 5
have_setuptools = True
else:
import distutils.command.install as old_install_mod
have_setuptools = False
from distutils.file_util import write_file
old_install = old_install_mod.install
class install(old_install):
Reported by Pylint.
Line: 8
Column: 1
else:
import distutils.command.install as old_install_mod
have_setuptools = False
from distutils.file_util import write_file
old_install = old_install_mod.install
class install(old_install):
Reported by Pylint.
Line: 10
Column: 1
have_setuptools = False
from distutils.file_util import write_file
old_install = old_install_mod.install
class install(old_install):
# Always run install_clib - the command is cheap, so no need to bypass it;
# but it's not run by setuptools -- so it's run again in install_data
Reported by Pylint.
Line: 12
Column: 1
old_install = old_install_mod.install
class install(old_install):
# Always run install_clib - the command is cheap, so no need to bypass it;
# but it's not run by setuptools -- so it's run again in install_data
sub_commands = old_install.sub_commands + [
('install_clib', lambda x: True)
Reported by Pylint.
Line: 12
Column: 1
old_install = old_install_mod.install
class install(old_install):
# Always run install_clib - the command is cheap, so no need to bypass it;
# but it's not run by setuptools -- so it's run again in install_data
sub_commands = old_install.sub_commands + [
('install_clib', lambda x: True)
Reported by Pylint.
Line: 24
Column: 5
old_install.finalize_options(self)
self.install_lib = self.install_libbase
def setuptools_run(self):
""" The setuptools version of the .run() method.
We must pull in the entire code so we can override the level used in the
_getframe() call since we wrap this call by one more level.
"""
Reported by Pylint.
numpy/typing/tests/data/reveal/arraypad.py
17 issues
Line: 2
Column: 1
from typing import List, Any, Mapping, Tuple
from typing_extensions import SupportsIndex
import numpy as np
import numpy.typing as npt
def mode_func(
ar: npt.NDArray[np.number[Any]],
width: Tuple[int, int],
Reported by Pylint.
Line: 8
Column: 9
import numpy.typing as npt
def mode_func(
ar: npt.NDArray[np.number[Any]],
width: Tuple[int, int],
iaxis: SupportsIndex,
kwargs: Mapping[str, Any],
) -> None: ...
Reported by Pylint.
Line: 8
Column: 21
import numpy.typing as npt
def mode_func(
ar: npt.NDArray[np.number[Any]],
width: Tuple[int, int],
iaxis: SupportsIndex,
kwargs: Mapping[str, Any],
) -> None: ...
Reported by Pylint.
Line: 14
Column: 8
kwargs: Mapping[str, Any],
) -> None: ...
AR_i8: npt.NDArray[np.int64]
AR_f8: npt.NDArray[np.float64]
AR_LIKE: List[int]
reveal_type(np.pad(AR_i8, (2, 3), "constant")) # E: numpy.ndarray[Any, numpy.dtype[{int64}]]
reveal_type(np.pad(AR_LIKE, (2, 3), "constant")) # E: numpy.ndarray[Any, numpy.dtype[Any]]
Reported by Pylint.
Line: 15
Column: 8
) -> None: ...
AR_i8: npt.NDArray[np.int64]
AR_f8: npt.NDArray[np.float64]
AR_LIKE: List[int]
reveal_type(np.pad(AR_i8, (2, 3), "constant")) # E: numpy.ndarray[Any, numpy.dtype[{int64}]]
reveal_type(np.pad(AR_LIKE, (2, 3), "constant")) # E: numpy.ndarray[Any, numpy.dtype[Any]]
Reported by Pylint.
Line: 18
Column: 1
AR_f8: npt.NDArray[np.float64]
AR_LIKE: List[int]
reveal_type(np.pad(AR_i8, (2, 3), "constant")) # E: numpy.ndarray[Any, numpy.dtype[{int64}]]
reveal_type(np.pad(AR_LIKE, (2, 3), "constant")) # E: numpy.ndarray[Any, numpy.dtype[Any]]
reveal_type(np.pad(AR_f8, (2, 3), mode_func)) # E: numpy.ndarray[Any, numpy.dtype[{float64}]]
reveal_type(np.pad(AR_f8, (2, 3), mode_func, a=1, b=2)) # E: numpy.ndarray[Any, numpy.dtype[{float64}]]
Reported by Pylint.
Line: 19
Column: 1
AR_LIKE: List[int]
reveal_type(np.pad(AR_i8, (2, 3), "constant")) # E: numpy.ndarray[Any, numpy.dtype[{int64}]]
reveal_type(np.pad(AR_LIKE, (2, 3), "constant")) # E: numpy.ndarray[Any, numpy.dtype[Any]]
reveal_type(np.pad(AR_f8, (2, 3), mode_func)) # E: numpy.ndarray[Any, numpy.dtype[{float64}]]
reveal_type(np.pad(AR_f8, (2, 3), mode_func, a=1, b=2)) # E: numpy.ndarray[Any, numpy.dtype[{float64}]]
Reported by Pylint.
Line: 21
Column: 1
reveal_type(np.pad(AR_i8, (2, 3), "constant")) # E: numpy.ndarray[Any, numpy.dtype[{int64}]]
reveal_type(np.pad(AR_LIKE, (2, 3), "constant")) # E: numpy.ndarray[Any, numpy.dtype[Any]]
reveal_type(np.pad(AR_f8, (2, 3), mode_func)) # E: numpy.ndarray[Any, numpy.dtype[{float64}]]
reveal_type(np.pad(AR_f8, (2, 3), mode_func, a=1, b=2)) # E: numpy.ndarray[Any, numpy.dtype[{float64}]]
Reported by Pylint.
Line: 22
Column: 1
reveal_type(np.pad(AR_LIKE, (2, 3), "constant")) # E: numpy.ndarray[Any, numpy.dtype[Any]]
reveal_type(np.pad(AR_f8, (2, 3), mode_func)) # E: numpy.ndarray[Any, numpy.dtype[{float64}]]
reveal_type(np.pad(AR_f8, (2, 3), mode_func, a=1, b=2)) # E: numpy.ndarray[Any, numpy.dtype[{float64}]]
Reported by Pylint.
Line: 8
Column: 5
import numpy.typing as npt
def mode_func(
ar: npt.NDArray[np.number[Any]],
width: Tuple[int, int],
iaxis: SupportsIndex,
kwargs: Mapping[str, Any],
) -> None: ...
Reported by Pylint.
doc/neps/nep-0016-benchmark.py
17 issues
Line: 1
Column: 1
import perf
import abc
import numpy as np
class NotArray:
pass
class AttrArray:
__array_implementer__ = True
Reported by Pylint.
Line: 1
Column: 1
import perf
import abc
import numpy as np
class NotArray:
pass
class AttrArray:
__array_implementer__ = True
Reported by Pylint.
Line: 1
Column: 1
import perf
import abc
import numpy as np
class NotArray:
pass
class AttrArray:
__array_implementer__ = True
Reported by Pylint.
Line: 2
Column: 1
import perf
import abc
import numpy as np
class NotArray:
pass
class AttrArray:
__array_implementer__ = True
Reported by Pylint.
Line: 5
Column: 1
import abc
import numpy as np
class NotArray:
pass
class AttrArray:
__array_implementer__ = True
Reported by Pylint.
Line: 5
Column: 1
import abc
import numpy as np
class NotArray:
pass
class AttrArray:
__array_implementer__ = True
Reported by Pylint.
Line: 8
Column: 1
class NotArray:
pass
class AttrArray:
__array_implementer__ = True
class ArrayBase(abc.ABC):
pass
Reported by Pylint.
Line: 8
Column: 1
class NotArray:
pass
class AttrArray:
__array_implementer__ = True
class ArrayBase(abc.ABC):
pass
Reported by Pylint.
Line: 11
Column: 1
class AttrArray:
__array_implementer__ = True
class ArrayBase(abc.ABC):
pass
class ABCArray1(ArrayBase):
pass
Reported by Pylint.
Line: 11
Column: 1
class AttrArray:
__array_implementer__ = True
class ArrayBase(abc.ABC):
pass
class ABCArray1(ArrayBase):
pass
Reported by Pylint.
numpy/distutils/exec_command.py
17 issues
Line: 283
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b602_subprocess_popen_with_shell_equals_true.html
# will return bytes. We need to decode the output ourselves
# so that Python will not raise a UnicodeDecodeError when
# it encounters an invalid character; rather, we simply replace it
proc = subprocess.Popen(command, shell=use_shell, env=env,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
universal_newlines=False)
except EnvironmentError:
# Return 127, as os.spawn*() and /bin/sh do
Reported by Bandit.
Line: 116
Column: 1
assert os.path.isfile(pythonexe), '%r is not a file' % (pythonexe,)
return pythonexe
def find_executable(exe, path=None, _cache={}):
"""Return full path of a executable or None.
Symbolic links are not followed.
"""
key = exe, path
Reported by Pylint.
Line: 291
Column: 11
# Return 127, as os.spawn*() and /bin/sh do
return 127, ''
text, err = proc.communicate()
mylocale = locale.getpreferredencoding(False)
if mylocale is None:
mylocale = 'ascii'
text = text.decode(mylocale, errors='replace')
text = text.replace('\r\n', '\n')
Reported by Pylint.
Line: 56
Suggestion:
https://bandit.readthedocs.io/en/latest/blacklists/blacklist_imports.html#b404-import-subprocess
import os
import sys
import subprocess
import locale
import warnings
from numpy.distutils.misc_util import is_sequence, make_temp_file
from numpy.distutils import log
Reported by Bandit.
Line: 99
Column: 1
sys.stdout.write(val.decode('utf8', errors='replace'))
def temp_file_name():
# 2019-01-30, 1.17
warnings.warn('temp_file_name is deprecated since NumPy v1.17, use '
'tempfile.mkstemp instead', DeprecationWarning, stacklevel=1)
fo, name = make_temp_file()
fo.close()
Reported by Pylint.
Line: 103
Column: 5
# 2019-01-30, 1.17
warnings.warn('temp_file_name is deprecated since NumPy v1.17, use '
'tempfile.mkstemp instead', DeprecationWarning, stacklevel=1)
fo, name = make_temp_file()
fo.close()
return name
def get_pythonexe():
pythonexe = sys.executable
Reported by Pylint.
Line: 107
Column: 1
fo.close()
return name
def get_pythonexe():
pythonexe = sys.executable
if os.name in ['nt', 'dos']:
fdir, fn = os.path.split(pythonexe)
fn = fn.upper().replace('PYTHONW', 'PYTHON')
pythonexe = os.path.join(fdir, fn)
Reported by Pylint.
Line: 110
Column: 15
def get_pythonexe():
pythonexe = sys.executable
if os.name in ['nt', 'dos']:
fdir, fn = os.path.split(pythonexe)
fn = fn.upper().replace('PYTHONW', 'PYTHON')
pythonexe = os.path.join(fdir, fn)
assert os.path.isfile(pythonexe), '%r is not a file' % (pythonexe,)
return pythonexe
Reported by Pylint.
Line: 111
Column: 9
pythonexe = sys.executable
if os.name in ['nt', 'dos']:
fdir, fn = os.path.split(pythonexe)
fn = fn.upper().replace('PYTHONW', 'PYTHON')
pythonexe = os.path.join(fdir, fn)
assert os.path.isfile(pythonexe), '%r is not a file' % (pythonexe,)
return pythonexe
def find_executable(exe, path=None, _cache={}):
Reported by Pylint.
Line: 113
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
fdir, fn = os.path.split(pythonexe)
fn = fn.upper().replace('PYTHONW', 'PYTHON')
pythonexe = os.path.join(fdir, fn)
assert os.path.isfile(pythonexe), '%r is not a file' % (pythonexe,)
return pythonexe
def find_executable(exe, path=None, _cache={}):
"""Return full path of a executable or None.
Reported by Bandit.
numpy/core/code_generators/generate_ufunc_api.py
17 issues
Line: 2
Column: 1
import os
import genapi
import numpy_api
from genapi import TypeApi, FunctionApi
h_template = r"""
#ifdef _UMATHMODULE
Reported by Pylint.
Line: 4
Column: 1
import os
import genapi
import numpy_api
from genapi import TypeApi, FunctionApi
h_template = r"""
#ifdef _UMATHMODULE
Reported by Pylint.
Line: 6
Column: 1
import numpy_api
from genapi import TypeApi, FunctionApi
h_template = r"""
#ifdef _UMATHMODULE
extern NPY_NO_EXPORT PyTypeObject PyUFunc_Type;
Reported by Pylint.
Line: 137
Column: 30
return targets
def do_generate_api(targets, sources):
header_file = targets[0]
c_file = targets[1]
doc_file = targets[2]
ufunc_api_index = genapi.merge_api_dicts((
Reported by Pylint.
Line: 1
Column: 1
import os
import genapi
import numpy_api
from genapi import TypeApi, FunctionApi
h_template = r"""
#ifdef _UMATHMODULE
Reported by Pylint.
Line: 8
Column: 1
from genapi import TypeApi, FunctionApi
h_template = r"""
#ifdef _UMATHMODULE
extern NPY_NO_EXPORT PyTypeObject PyUFunc_Type;
%s
Reported by Pylint.
Line: 110
Column: 1
#endif
"""
c_template = r"""
/* These pointers will be stored in the C-object for use in other
extension modules
*/
void *PyUFunc_API[] = {
Reported by Pylint.
Line: 120
Column: 1
};
"""
def generate_api(output_dir, force=False):
basename = 'ufunc_api'
h_file = os.path.join(output_dir, '__%s.h' % basename)
c_file = os.path.join(output_dir, '__%s.c' % basename)
d_file = os.path.join(output_dir, '%s.txt' % basename)
Reported by Pylint.
Line: 130
Column: 5
sources = ['ufunc_api_order.txt']
if (not force and not genapi.should_rebuild(targets, sources + [__file__])):
return targets
else:
do_generate_api(targets, sources)
return targets
Reported by Pylint.
Line: 137
Column: 1
return targets
def do_generate_api(targets, sources):
header_file = targets[0]
c_file = targets[1]
doc_file = targets[2]
ufunc_api_index = genapi.merge_api_dicts((
Reported by Pylint.
numpy/typing/tests/data/pass/multiarray.py
17 issues
Line: 5
Column: 8
import numpy as np
import numpy.typing as npt
AR_f8: npt.NDArray[np.float64] = np.array([1.0])
AR_i4 = np.array([1], dtype=np.int32)
AR_u1 = np.array([1], dtype=np.uint8)
AR_LIKE_f = [1.5]
AR_LIKE_i = [1]
Reported by Pylint.
Line: 1
Column: 1
from typing import Any
import numpy as np
import numpy.typing as npt
AR_f8: npt.NDArray[np.float64] = np.array([1.0])
AR_i4 = np.array([1], dtype=np.int32)
AR_u1 = np.array([1], dtype=np.uint8)
AR_LIKE_f = [1.5]
Reported by Pylint.
Line: 17
Column: 1
next(b_f8)
b_f8.reset()
b_f8.index
b_f8.iters
b_f8.nd
b_f8.ndim
b_f8.numiter
b_f8.shape
Reported by Pylint.
Line: 18
Column: 1
next(b_f8)
b_f8.reset()
b_f8.index
b_f8.iters
b_f8.nd
b_f8.ndim
b_f8.numiter
b_f8.shape
b_f8.size
Reported by Pylint.
Line: 19
Column: 1
b_f8.reset()
b_f8.index
b_f8.iters
b_f8.nd
b_f8.ndim
b_f8.numiter
b_f8.shape
b_f8.size
Reported by Pylint.
Line: 20
Column: 1
b_f8.index
b_f8.iters
b_f8.nd
b_f8.ndim
b_f8.numiter
b_f8.shape
b_f8.size
next(b_i4_f8_f8)
Reported by Pylint.
Line: 21
Column: 1
b_f8.iters
b_f8.nd
b_f8.ndim
b_f8.numiter
b_f8.shape
b_f8.size
next(b_i4_f8_f8)
b_i4_f8_f8.reset()
Reported by Pylint.
Line: 22
Column: 1
b_f8.nd
b_f8.ndim
b_f8.numiter
b_f8.shape
b_f8.size
next(b_i4_f8_f8)
b_i4_f8_f8.reset()
b_i4_f8_f8.ndim
Reported by Pylint.
Line: 23
Column: 1
b_f8.ndim
b_f8.numiter
b_f8.shape
b_f8.size
next(b_i4_f8_f8)
b_i4_f8_f8.reset()
b_i4_f8_f8.ndim
b_i4_f8_f8.index
Reported by Pylint.
Line: 27
Column: 1
next(b_i4_f8_f8)
b_i4_f8_f8.reset()
b_i4_f8_f8.ndim
b_i4_f8_f8.index
b_i4_f8_f8.iters
b_i4_f8_f8.nd
b_i4_f8_f8.numiter
b_i4_f8_f8.shape
Reported by Pylint.
numpy/typing/mypy_plugin.py
16 issues
Line: 41
Column: 5
import numpy as np
try:
import mypy.types
from mypy.types import Type
from mypy.plugin import Plugin, AnalyzeTypeContext
from mypy.nodes import MypyFile, ImportFrom, Statement
from mypy.build import PRI_MED
Reported by Pylint.
Line: 42
Column: 5
try:
import mypy.types
from mypy.types import Type
from mypy.plugin import Plugin, AnalyzeTypeContext
from mypy.nodes import MypyFile, ImportFrom, Statement
from mypy.build import PRI_MED
_HookFunc = t.Callable[[AnalyzeTypeContext], Type]
Reported by Pylint.
Line: 43
Column: 5
try:
import mypy.types
from mypy.types import Type
from mypy.plugin import Plugin, AnalyzeTypeContext
from mypy.nodes import MypyFile, ImportFrom, Statement
from mypy.build import PRI_MED
_HookFunc = t.Callable[[AnalyzeTypeContext], Type]
MYPY_EX: None | ModuleNotFoundError = None
Reported by Pylint.
Line: 44
Column: 5
import mypy.types
from mypy.types import Type
from mypy.plugin import Plugin, AnalyzeTypeContext
from mypy.nodes import MypyFile, ImportFrom, Statement
from mypy.build import PRI_MED
_HookFunc = t.Callable[[AnalyzeTypeContext], Type]
MYPY_EX: None | ModuleNotFoundError = None
except ModuleNotFoundError as ex:
Reported by Pylint.
Line: 45
Column: 5
from mypy.types import Type
from mypy.plugin import Plugin, AnalyzeTypeContext
from mypy.nodes import MypyFile, ImportFrom, Statement
from mypy.build import PRI_MED
_HookFunc = t.Callable[[AnalyzeTypeContext], Type]
MYPY_EX: None | ModuleNotFoundError = None
except ModuleNotFoundError as ex:
MYPY_EX = ex
Reported by Pylint.
Line: 71
Column: 22
]
ret = {}
for name, typ in names:
n: int = 8 * typ().dtype.itemsize
ret[f'numpy.typing._nbit.{name}'] = f"numpy._{n}Bit"
return ret
def _get_extended_precision_list() -> t.List[str]:
Reported by Pylint.
Line: 71
Column: 22
]
ret = {}
for name, typ in names:
n: int = 8 * typ().dtype.itemsize
ret[f'numpy.typing._nbit.{name}'] = f"numpy._{n}Bit"
return ret
def _get_extended_precision_list() -> t.List[str]:
Reported by Pylint.
Line: 41
Column: 5
import numpy as np
try:
import mypy.types
from mypy.types import Type
from mypy.plugin import Plugin, AnalyzeTypeContext
from mypy.nodes import MypyFile, ImportFrom, Statement
from mypy.build import PRI_MED
Reported by Pylint.
Line: 128
Column: 49
if t.TYPE_CHECKING or MYPY_EX is None:
def _index(iterable: t.Iterable[Statement], id: str) -> int:
"""Identify the first ``ImportFrom`` instance the specified `id`."""
for i, value in enumerate(iterable):
if getattr(value, "id", None) == id:
return i
else:
Reported by Pylint.
Line: 133
Column: 9
for i, value in enumerate(iterable):
if getattr(value, "id", None) == id:
return i
else:
raise ValueError("Failed to identify a `ImportFrom` instance "
f"with the following id: {id!r}")
def _override_imports(
file: MypyFile,
Reported by Pylint.
numpy/distutils/lib2def.py
16 issues
Line: 66
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b602_subprocess_popen_with_shell_equals_true.html
"""Returns the output of nm_cmd via a pipe.
nm_output = getnm(nm_cmd = 'nm -Cs py_lib')"""
p = subprocess.Popen(nm_cmd, shell=shell, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, universal_newlines=True)
nm_output, nm_err = p.communicate()
if p.returncode != 0:
raise RuntimeError('failed to run "%s": "%s"' % (
' '.join(nm_cmd), nm_err))
Reported by Bandit.
Line: 44
Column: 13
libfile, deffile = parse_cmd()"""
if len(sys.argv) == 3:
if sys.argv[1][-4:] == '.lib' and sys.argv[2][-4:] == '.def':
libfile, deffile = sys.argv[1:]
elif sys.argv[1][-4:] == '.def' and sys.argv[2][-4:] == '.lib':
deffile, libfile = sys.argv[1:]
else:
print("I'm assuming that your first argument is the library")
print("and the second is the DEF file.")
Reported by Pylint.
Line: 44
Column: 22
libfile, deffile = parse_cmd()"""
if len(sys.argv) == 3:
if sys.argv[1][-4:] == '.lib' and sys.argv[2][-4:] == '.def':
libfile, deffile = sys.argv[1:]
elif sys.argv[1][-4:] == '.def' and sys.argv[2][-4:] == '.lib':
deffile, libfile = sys.argv[1:]
else:
print("I'm assuming that your first argument is the library")
print("and the second is the DEF file.")
Reported by Pylint.
Line: 44
Column: 13
libfile, deffile = parse_cmd()"""
if len(sys.argv) == 3:
if sys.argv[1][-4:] == '.lib' and sys.argv[2][-4:] == '.def':
libfile, deffile = sys.argv[1:]
elif sys.argv[1][-4:] == '.def' and sys.argv[2][-4:] == '.lib':
deffile, libfile = sys.argv[1:]
else:
print("I'm assuming that your first argument is the library")
print("and the second is the DEF file.")
Reported by Pylint.
Line: 46
Column: 13
if sys.argv[1][-4:] == '.lib' and sys.argv[2][-4:] == '.def':
libfile, deffile = sys.argv[1:]
elif sys.argv[1][-4:] == '.def' and sys.argv[2][-4:] == '.lib':
deffile, libfile = sys.argv[1:]
else:
print("I'm assuming that your first argument is the library")
print("and the second is the DEF file.")
elif len(sys.argv) == 2:
if sys.argv[1][-4:] == '.def':
Reported by Pylint.
Line: 62
Column: 11
deffile = None
return libfile, deffile
def getnm(nm_cmd=['nm', '-Cs', 'python%s.lib' % py_ver], shell=True):
"""Returns the output of nm_cmd via a pipe.
nm_output = getnm(nm_cmd = 'nm -Cs py_lib')"""
p = subprocess.Popen(nm_cmd, shell=shell, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, universal_newlines=True)
Reported by Pylint.
Line: 62
Column: 1
deffile = None
return libfile, deffile
def getnm(nm_cmd=['nm', '-Cs', 'python%s.lib' % py_ver], shell=True):
"""Returns the output of nm_cmd via a pipe.
nm_output = getnm(nm_cmd = 'nm -Cs py_lib')"""
p = subprocess.Popen(nm_cmd, shell=shell, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, universal_newlines=True)
Reported by Pylint.
Line: 68
Column: 5
nm_output = getnm(nm_cmd = 'nm -Cs py_lib')"""
p = subprocess.Popen(nm_cmd, shell=shell, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, universal_newlines=True)
nm_output, nm_err = p.communicate()
if p.returncode != 0:
raise RuntimeError('failed to run "%s": "%s"' % (
' '.join(nm_cmd), nm_err))
return nm_output
Reported by Pylint.
Line: 74
Column: 14
' '.join(nm_cmd), nm_err))
return nm_output
def parse_nm(nm_output):
"""Returns a tuple of lists: dlist for the list of data
symbols and flist for the list of function symbols.
dlist, flist = parse_nm(nm_output)"""
data = DATA_RE.findall(nm_output)
Reported by Pylint.
Line: 82
Column: 5
data = DATA_RE.findall(nm_output)
func = FUNC_RE.findall(nm_output)
flist = []
for sym in data:
if sym in func and (sym[:2] == 'Py' or sym[:3] == '_Py' or sym[:4] == 'init'):
flist.append(sym)
dlist = []
Reported by Pylint.
numpy/matrixlib/tests/test_matrix_linalg.py
16 issues
Line: 36
Column: 1
# No need to make generalized or strided cases for matrices.
class MatrixTestCase(LinalgTestCase):
TEST_CASES = CASES
class TestSolveMatrix(SolveCases, MatrixTestCase):
pass
Reported by Pylint.
Line: 36
Column: 1
# No need to make generalized or strided cases for matrices.
class MatrixTestCase(LinalgTestCase):
TEST_CASES = CASES
class TestSolveMatrix(SolveCases, MatrixTestCase):
pass
Reported by Pylint.
Line: 40
Column: 1
TEST_CASES = CASES
class TestSolveMatrix(SolveCases, MatrixTestCase):
pass
class TestInvMatrix(InvCases, MatrixTestCase):
pass
Reported by Pylint.
Line: 44
Column: 1
pass
class TestInvMatrix(InvCases, MatrixTestCase):
pass
class TestEigvalsMatrix(EigvalsCases, MatrixTestCase):
pass
Reported by Pylint.
Line: 48
Column: 1
pass
class TestEigvalsMatrix(EigvalsCases, MatrixTestCase):
pass
class TestEigMatrix(EigCases, MatrixTestCase):
pass
Reported by Pylint.
Line: 52
Column: 1
pass
class TestEigMatrix(EigCases, MatrixTestCase):
pass
class TestSVDMatrix(SVDCases, MatrixTestCase):
pass
Reported by Pylint.
Line: 56
Column: 1
pass
class TestSVDMatrix(SVDCases, MatrixTestCase):
pass
class TestCondMatrix(CondCases, MatrixTestCase):
pass
Reported by Pylint.
Line: 60
Column: 1
pass
class TestCondMatrix(CondCases, MatrixTestCase):
pass
class TestPinvMatrix(PinvCases, MatrixTestCase):
pass
Reported by Pylint.
Line: 64
Column: 1
pass
class TestPinvMatrix(PinvCases, MatrixTestCase):
pass
class TestDetMatrix(DetCases, MatrixTestCase):
pass
Reported by Pylint.
Line: 64
Column: 1
pass
class TestPinvMatrix(PinvCases, MatrixTestCase):
pass
class TestDetMatrix(DetCases, MatrixTestCase):
pass
Reported by Pylint.