The following issues were found

benchmarks/benchmarks/__init__.py
9 issues
Module import itself
Error

Line: 1 Column: 1

              from . import common
import sys
import os

def show_cpu_features():
    from numpy.lib.utils import _opt_info
    info = _opt_info()
    info = "NumPy CPU features: " + (info if info else 'nothing enabled')
    # ASV wrapping stdout & stderr, so we assume having a tty here

            

Reported by Pylint.

FIXME: there's no official way to provide extra information to the test log
Error

Line: 51 Column: 3

                  return False


# FIXME: there's no official way to provide extra information to the test log
if not dirty_lock("print_cpu_features.lock"):
    show_cpu_features()

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from . import common
import sys
import os

def show_cpu_features():
    from numpy.lib.utils import _opt_info
    info = _opt_info()
    info = "NumPy CPU features: " + (info if info else 'nothing enabled')
    # ASV wrapping stdout & stderr, so we assume having a tty here

            

Reported by Pylint.

standard import "import sys" should be placed before "from . import common"
Error

Line: 2 Column: 1

              from . import common
import sys
import os

def show_cpu_features():
    from numpy.lib.utils import _opt_info
    info = _opt_info()
    info = "NumPy CPU features: " + (info if info else 'nothing enabled')
    # ASV wrapping stdout & stderr, so we assume having a tty here

            

Reported by Pylint.

standard import "import os" should be placed before "from . import common"
Error

Line: 3 Column: 1

              from . import common
import sys
import os

def show_cpu_features():
    from numpy.lib.utils import _opt_info
    info = _opt_info()
    info = "NumPy CPU features: " + (info if info else 'nothing enabled')
    # ASV wrapping stdout & stderr, so we assume having a tty here

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 5 Column: 1

              import sys
import os

def show_cpu_features():
    from numpy.lib.utils import _opt_info
    info = _opt_info()
    info = "NumPy CPU features: " + (info if info else 'nothing enabled')
    # ASV wrapping stdout & stderr, so we assume having a tty here
    if 'SHELL' in os.environ and sys.platform != 'win32':

            

Reported by Pylint.

Import outside toplevel (numpy.lib.utils._opt_info)
Error

Line: 6 Column: 5

              import os

def show_cpu_features():
    from numpy.lib.utils import _opt_info
    info = _opt_info()
    info = "NumPy CPU features: " + (info if info else 'nothing enabled')
    # ASV wrapping stdout & stderr, so we assume having a tty here
    if 'SHELL' in os.environ and sys.platform != 'win32':
        # to avoid the red color that imposed by ASV

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 16 Column: 1

                  else:
        print(info)

def dirty_lock(lock_name, lock_on_count=1):
    # this lock occurred before each round to avoid duplicate printing
    if not hasattr(os, "getppid"):
        return False
    ppid = os.getppid()
    if not ppid or ppid == os.getpid():

            

Reported by Pylint.

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

Line: 33 Column: 39

                  # the issue here is ASV doesn't capture any strings from stdout or stderr
    # during this stage so we escape it and lock on the second increment
    try:
        with open(lock_path, 'a+') as f:
            f.seek(0)
            count, _ppid = (f.read().split() + [0, 0])[:2]
            count, _ppid = int(count), int(_ppid)
            if _ppid == ppid:
                if count >= lock_on_count:

            

Reported by Pylint.

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

Line: 6 Column: 1

              
compilers = ['SunFCompiler']

class SunFCompiler(FCompiler):

    compiler_type = 'sun'
    description = 'Sun or Forte Fortran 95 Compiler'
    # ex:
    # f90: Sun WorkShop 6 update 2 Fortran 95 6.2 Patch 111690-10 2003/08/28

            

Reported by Pylint.

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

Line: 6 Column: 1

              
compilers = ['SunFCompiler']

class SunFCompiler(FCompiler):

    compiler_type = 'sun'
    description = 'Sun or Forte Fortran 95 Compiler'
    # ex:
    # f90: Sun WorkShop 6 update 2 Fortran 95 6.2 Patch 111690-10 2003/08/28

            

Reported by Pylint.

Redefining built-in 'dir'
Error

Line: 44 Column: 42

                      opt.extend(['fsu', 'sunmath', 'mvec'])
        return opt

    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.ccompiler import simple_version_match
from numpy.distutils.fcompiler import FCompiler

compilers = ['SunFCompiler']

class SunFCompiler(FCompiler):

    compiler_type = 'sun'
    description = 'Sun or Forte Fortran 95 Compiler'

            

Reported by Pylint.

Missing class docstring
Error

Line: 6 Column: 1

              
compilers = ['SunFCompiler']

class SunFCompiler(FCompiler):

    compiler_type = 'sun'
    description = 'Sun or Forte Fortran 95 Compiler'
    # ex:
    # f90: Sun WorkShop 6 update 2 Fortran 95 6.2 Patch 111690-10 2003/08/28

            

Reported by Pylint.

Method could be a function
Error

Line: 35 Column: 5

                      else:
            ret.append("-fixed")
        return ret
    def get_opt(self):
        return ['-fast', '-dalign']
    def get_arch(self):
        return ['-xtarget=generic']
    def get_libraries(self):
        opt = []

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 35 Column: 5

                      else:
            ret.append("-fixed")
        return ret
    def get_opt(self):
        return ['-fast', '-dalign']
    def get_arch(self):
        return ['-xtarget=generic']
    def get_libraries(self):
        opt = []

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 37 Column: 5

                      return ret
    def get_opt(self):
        return ['-fast', '-dalign']
    def get_arch(self):
        return ['-xtarget=generic']
    def get_libraries(self):
        opt = []
        opt.extend(['fsu', 'sunmath', 'mvec'])
        return opt

            

Reported by Pylint.

Method could be a function
Error

Line: 37 Column: 5

                      return ret
    def get_opt(self):
        return ['-fast', '-dalign']
    def get_arch(self):
        return ['-xtarget=generic']
    def get_libraries(self):
        opt = []
        opt.extend(['fsu', 'sunmath', 'mvec'])
        return opt

            

Reported by Pylint.

tools/commitstats.py
9 issues
Starting a process with a shell, possible injection detected, security issue.
Security injection

Line: 19
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b605_start_process_with_a_shell.html

              
command = 'svn log -l 2300 > output.txt'
os.chdir('..')
os.system(command)

count = get_count('output.txt', 'NumPy')


os.chdir('../scipy')

            

Reported by Bandit.

Starting a process with a shell, possible injection detected, security issue.
Security injection

Line: 25
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b605_start_process_with_a_shell.html

              

os.chdir('../scipy')
os.system(command)

count.extend(get_count('output.txt', 'SciPy'))

os.chdir('../scikits')
os.system(command)

            

Reported by Bandit.

Starting a process with a shell, possible injection detected, security issue.
Security injection

Line: 30
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b605_start_process_with_a_shell.html

              count.extend(get_count('output.txt', 'SciPy'))

os.chdir('../scikits')
os.system(command)
count.extend(get_count('output.txt', 'SciKits'))
count.sort()




            

Reported by Bandit.

Redefining name 'count' from outer scope (line 21)
Error

Line: 13 Column: 5

                  mystr = open(filename).read()
    result = names.findall(mystr)
    u = np.unique(result)
    count = [(x, result.count(x), repo) for x in u]
    return count


command = 'svn log -l 2300 > output.txt'
os.chdir('..')

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # Run svn log -l <some number>

import re
import numpy as np
import os

names = re.compile(r'r\d+\s\|\s(.*)\s\|\s200')

def get_count(filename, repo):

            

Reported by Pylint.

standard import "import os" should be placed before "import numpy as np"
Error

Line: 5 Column: 1

              
import re
import numpy as np
import os

names = re.compile(r'r\d+\s\|\s(.*)\s\|\s200')

def get_count(filename, repo):
    mystr = open(filename).read()

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 9 Column: 1

              
names = re.compile(r'r\d+\s\|\s(.*)\s\|\s200')

def get_count(filename, repo):
    mystr = open(filename).read()
    result = names.findall(mystr)
    u = np.unique(result)
    count = [(x, result.count(x), repo) for x in u]
    return count

            

Reported by Pylint.

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

Line: 12 Column: 5

              def get_count(filename, repo):
    mystr = open(filename).read()
    result = names.findall(mystr)
    u = np.unique(result)
    count = [(x, result.count(x), repo) for x in u]
    return count


command = 'svn log -l 2300 > output.txt'

            

Reported by Pylint.

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

Line: 17 Column: 1

                  return count


command = 'svn log -l 2300 > output.txt'
os.chdir('..')
os.system(command)

count = get_count('output.txt', 'NumPy')


            

Reported by Pylint.

numpy/typing/tests/data/pass/array_constructors.py
9 issues
Unused List imported from typing
Error

Line: 2 Column: 1

              import sys
from typing import List, Any
import numpy as np


class Index:
    def __index__(self) -> int:
        return 0


            

Reported by Pylint.

Unused argument 'kwargs'
Error

Line: 15 Column: 1

                  pass


def func(i: int, j: int, **kwargs: Any) -> SubClass:
    return B


i8 = np.int64(1)


            

Reported by Pylint.

Unused argument 'j'
Error

Line: 15 Column: 18

                  pass


def func(i: int, j: int, **kwargs: Any) -> SubClass:
    return B


i8 = np.int64(1)


            

Reported by Pylint.

Unused argument 'i'
Error

Line: 15 Column: 10

                  pass


def func(i: int, j: int, **kwargs: Any) -> SubClass:
    return B


i8 = np.int64(1)


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import sys
from typing import List, Any
import numpy as np


class Index:
    def __index__(self) -> int:
        return 0


            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 6 Column: 1

              import numpy as np


class Index:
    def __index__(self) -> int:
        return 0


class SubClass(np.ndarray):

            

Reported by Pylint.

Missing class docstring
Error

Line: 6 Column: 1

              import numpy as np


class Index:
    def __index__(self) -> int:
        return 0


class SubClass(np.ndarray):

            

Reported by Pylint.

Missing class docstring
Error

Line: 11 Column: 1

                      return 0


class SubClass(np.ndarray):
    pass


def func(i: int, j: int, **kwargs: Any) -> SubClass:
    return B

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 15 Column: 1

                  pass


def func(i: int, j: int, **kwargs: Any) -> SubClass:
    return B


i8 = np.int64(1)


            

Reported by Pylint.

numpy/core/src/multiarray/arrayobject.c
9 issues
printf - If format strings can be influenced by an attacker, they can be exploited
Security

Line: 526 Column: 9 CWE codes: 134
Suggestion: Use a constant for the format specification

                  printf(" ndim   : %d\n", fobj->nd);
    printf(" shape  :");
    for (i = 0; i < fobj->nd; ++i) {
        printf(" %" NPY_INTP_FMT, fobj->dimensions[i]);
    }
    printf("\n");

    printf(" dtype  : ");
    PyObject_Print((PyObject *)fobj->descr, stdout, 0);

            

Reported by FlawFinder.

printf - If format strings can be influenced by an attacker, they can be exploited
Security

Line: 536 Column: 9 CWE codes: 134
Suggestion: Use a constant for the format specification

                  printf(" data   : %p\n", fobj->data);
    printf(" strides:");
    for (i = 0; i < fobj->nd; ++i) {
        printf(" %" NPY_INTP_FMT, fobj->strides[i]);
    }
    printf("\n");

    printf(" base   : %p\n", fobj->base);


            

Reported by FlawFinder.

memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 685 Column: 9 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

                  if ((npy_intp)s1 % sizeof(npy_ucs4) != 0) {
        size = len1*sizeof(npy_ucs4);
        s1t = malloc(size);
        memcpy(s1t, s1, size);
        s1 = s1t;
    }
    if ((npy_intp)s2 % sizeof(npy_ucs4) != 0) {
        size = len2*sizeof(npy_ucs4);
        s2t = malloc(size);

            

Reported by FlawFinder.

memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 691 Column: 9 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

                  if ((npy_intp)s2 % sizeof(npy_ucs4) != 0) {
        size = len2*sizeof(npy_ucs4);
        s2t = malloc(size);
        memcpy(s2t, s2, size);
        s2 = s1t;
    }

    val = PyArray_CompareUCS4(s1, s2, PyArray_MIN(len1,len2));
    if ((val != 0) || (len1 == len2)) {

            

Reported by FlawFinder.

memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 811 Column: 5 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

                          return NULL;
        }
    }
    memcpy(temp, original, nc);
    _rstripw(temp, nc);
    return temp;
}

static void

            

Reported by FlawFinder.

memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 834 Column: 5 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

                          return NULL;
        }
    }
    memcpy(temp, original, nc*sizeof(npy_ucs4));
    _unistripw((npy_ucs4 *)temp, nc);
    return temp;
}

static void

            

Reported by FlawFinder.

char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 852 Column: 9 CWE codes: 119 120
Suggestion: Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length

              
#define _rstrip_loop(CMP) {                                     \
        void *aptr, *bptr;                                      \
        char atemp[SMALL_STRING], btemp[SMALL_STRING];          \
        while(size--) {                                         \
            aptr = stripfunc(iself->dataptr, atemp, N1);        \
            if (!aptr) return -1;                               \
            bptr = stripfunc(iother->dataptr, btemp, N2);       \
            if (!bptr) {                                        \

            

Reported by FlawFinder.

memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 1098 Column: 25 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

                                  newdims.ptr = dimensions;
                    newdims.len = result_ndim+1;
                    if (result_ndim) {
                        memcpy(dimensions, PyArray_DIMS((PyArrayObject *)temp),
                               sizeof(npy_intp)*result_ndim);
                    }
                    dimensions[result_ndim] = -1;
                    temp2 = PyArray_Newshape((PyArrayObject *)temp,
                                             &newdims, NPY_ANYORDER);

            

Reported by FlawFinder.

equal - Function does not check the second iterator for over-read conditions
Security

Line: 1389 Column: 60 CWE codes: 126
Suggestion: This function is often discouraged by most C++ coding standards in favor of its safer alternatives provided since C++14. Consider using a form of this function that checks the second iterator before potentially overflowing it

                      }

        result = PyArray_GenericBinaryFunction(
                (PyObject *)self, (PyObject *)other, n_ops.equal);
        break;
    case Py_NE:
        RICHCMP_GIVE_UP_IF_NEEDED(obj_self, other);
        /*
         * The ufunc does not support void/structured types, so these

            

Reported by FlawFinder.

numpy/doc/constants.py
9 issues
Redefining name 'doc' from outer scope (line 389)
Error

Line: 21 Column: 30

              
# Maintain same format as in numpy.add_newdocs
constants = []
def add_newdoc(module, name, doc):
    constants.append((name, doc))

add_newdoc('numpy', 'pi',
    """
    ``pi = 3.1415926535897932384626433...``

            

Reported by Pylint.

Unused argument 'module'
Error

Line: 21 Column: 16

              
# Maintain same format as in numpy.add_newdocs
constants = []
def add_newdoc(module, name, doc):
    constants.append((name, doc))

add_newdoc('numpy', 'pi',
    """
    ``pi = 3.1415926535897932384626433...``

            

Reported by Pylint.

Redefining name 'name' from outer scope (line 389)
Error

Line: 21 Column: 24

              
# Maintain same format as in numpy.add_newdocs
constants = []
def add_newdoc(module, name, doc):
    constants.append((name, doc))

add_newdoc('numpy', 'pi',
    """
    ``pi = 3.1415926535897932384626433...``

            

Reported by Pylint.

Using possibly undefined loop variable 'name'
Error

Line: 410 Column: 24

                  constants_str = "\n".join(constants_str)

    __doc__ = __doc__ % dict(constant_list=constants_str)
    del constants_str, name, doc
    del line, lines, new_lines, m, s, prev

del constants, add_newdoc

            

Reported by Pylint.

Using possibly undefined loop variable 'doc'
Error

Line: 410 Column: 30

                  constants_str = "\n".join(constants_str)

    __doc__ = __doc__ % dict(constant_list=constants_str)
    del constants_str, name, doc
    del line, lines, new_lines, m, s, prev

del constants, add_newdoc

            

Reported by Pylint.

Using possibly undefined loop variable 'line'
Error

Line: 411 Column: 9

              
    __doc__ = __doc__ % dict(constant_list=constants_str)
    del constants_str, name, doc
    del line, lines, new_lines, m, s, prev

del constants, add_newdoc

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 21 Column: 1

              
# Maintain same format as in numpy.add_newdocs
constants = []
def add_newdoc(module, name, doc):
    constants.append((name, doc))

add_newdoc('numpy', 'pi',
    """
    ``pi = 3.1415926535897932384626433...``

            

Reported by Pylint.

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

Line: 403 Column: 9

                              new_lines.append('')
            else:
                new_lines.append(line)
        s = "\n".join(new_lines)

        # Done.
        constants_str.append(""".. data:: %s\n    %s""" % (name, s))
    constants_str = "\n".join(constants_str)


            

Reported by Pylint.

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

Line: 407 Column: 5

              
        # Done.
        constants_str.append(""".. data:: %s\n    %s""" % (name, s))
    constants_str = "\n".join(constants_str)

    __doc__ = __doc__ % dict(constant_list=constants_str)
    del constants_str, name, doc
    del line, lines, new_lines, m, s, prev


            

Reported by Pylint.

numpy/core/src/multiarray/multiarraymodule.c
9 issues
memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 284 Column: 9 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

                      *((char ****)ptr) = ptr3;
    }
    if (nd) {
        memcpy(dims, PyArray_DIMS(ap), nd*sizeof(npy_intp));
    }
    *op = (PyObject *)ap;
    return 0;
}


            

Reported by FlawFinder.

memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 398 Column: 5 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

                   * Figure out the final concatenated shape starting from the first
     * array's shape.
     */
    memcpy(shape, PyArray_SHAPE(arrays[0]), ndim * sizeof(shape[0]));
    for (iarrays = 1; iarrays < narrays; ++iarrays) {
        npy_intp *arr_shape;

        if (PyArray_NDIM(arrays[iarrays]) != ndim) {
            PyErr_Format(PyExc_ValueError,

            

Reported by FlawFinder.

memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 1322 Column: 13 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

                      }
        sw2 = op + (length - 1) * os;
        while (sw1 < sw2) {
            memcpy(tmp, sw1, os);
            memcpy(sw1, sw2, os);
            memcpy(sw2, tmp, os);
            sw1 += os;
            sw2 -= os;
        }

            

Reported by FlawFinder.

memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 1323 Column: 13 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

                      sw2 = op + (length - 1) * os;
        while (sw1 < sw2) {
            memcpy(tmp, sw1, os);
            memcpy(sw1, sw2, os);
            memcpy(sw2, tmp, os);
            sw1 += os;
            sw2 -= os;
        }
        PyArray_free(tmp);

            

Reported by FlawFinder.

memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 1324 Column: 13 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

                      while (sw1 < sw2) {
            memcpy(tmp, sw1, os);
            memcpy(sw1, sw2, os);
            memcpy(sw2, tmp, os);
            sw1 += os;
            sw2 -= os;
        }
        PyArray_free(tmp);
    }

            

Reported by FlawFinder.

char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 3045 Column: 9 CWE codes: 119 120
Suggestion: Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length

              {
    const union {
        npy_uint32 i;
        char c[4];
    } bint = {0x01020304};

    if (bint.c[0] == 1) {
        return NPY_CPU_BIG;
    }

            

Reported by FlawFinder.

memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 3164 Column: 17 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

                      npy_intp i; \
        for (i = 0; i < n; i++) { \
            if (*csrc) { \
                memcpy(dst, xsrc, size); \
            } \
            else { \
                memcpy(dst, ysrc, size); \
            } \
            dst += size; \

            

Reported by FlawFinder.

memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 3167 Column: 17 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

                              memcpy(dst, xsrc, size); \
            } \
            else { \
                memcpy(dst, ysrc, size); \
            } \
            dst += size; \
            xsrc += xstride; \
            ysrc += ystride; \
            csrc += cstride; \

            

Reported by FlawFinder.

strlen - Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected)
Security

Line: 2199 Column: 24 CWE codes: 126

                  }

    /* binary mode, condition copied from PyArray_FromString */
    if (sep == NULL || strlen(sep) == 0) {
        /* Numpy 1.14, 2017-10-19 */
        if (DEPRECATE(
                "The binary mode of fromstring is deprecated, as it behaves "
                "surprisingly on unicode inputs. Use frombuffer instead") < 0) {
            Py_XDECREF(descr);

            

Reported by FlawFinder.

numpy/typing/tests/data/reveal/warnings_and_errors.py
9 issues
Undefined variable 'reveal_type'
Error

Line: 5 Column: 1

              
import numpy as np

reveal_type(np.ModuleDeprecationWarning())  # E: numpy.ModuleDeprecationWarning
reveal_type(np.VisibleDeprecationWarning())  # E: numpy.VisibleDeprecationWarning
reveal_type(np.ComplexWarning())  # E: numpy.ComplexWarning
reveal_type(np.RankWarning())  # E: numpy.RankWarning
reveal_type(np.TooHardError())  # E: numpy.TooHardError
reveal_type(np.AxisError("test"))  # E: numpy.AxisError

            

Reported by Pylint.

Undefined variable 'reveal_type'
Error

Line: 6 Column: 1

              import numpy as np

reveal_type(np.ModuleDeprecationWarning())  # E: numpy.ModuleDeprecationWarning
reveal_type(np.VisibleDeprecationWarning())  # E: numpy.VisibleDeprecationWarning
reveal_type(np.ComplexWarning())  # E: numpy.ComplexWarning
reveal_type(np.RankWarning())  # E: numpy.RankWarning
reveal_type(np.TooHardError())  # E: numpy.TooHardError
reveal_type(np.AxisError("test"))  # E: numpy.AxisError
reveal_type(np.AxisError(5, 1))  # E: numpy.AxisError

            

Reported by Pylint.

Undefined variable 'reveal_type'
Error

Line: 7 Column: 1

              
reveal_type(np.ModuleDeprecationWarning())  # E: numpy.ModuleDeprecationWarning
reveal_type(np.VisibleDeprecationWarning())  # E: numpy.VisibleDeprecationWarning
reveal_type(np.ComplexWarning())  # E: numpy.ComplexWarning
reveal_type(np.RankWarning())  # E: numpy.RankWarning
reveal_type(np.TooHardError())  # E: numpy.TooHardError
reveal_type(np.AxisError("test"))  # E: numpy.AxisError
reveal_type(np.AxisError(5, 1))  # E: numpy.AxisError

            

Reported by Pylint.

Undefined variable 'reveal_type'
Error

Line: 8 Column: 1

              reveal_type(np.ModuleDeprecationWarning())  # E: numpy.ModuleDeprecationWarning
reveal_type(np.VisibleDeprecationWarning())  # E: numpy.VisibleDeprecationWarning
reveal_type(np.ComplexWarning())  # E: numpy.ComplexWarning
reveal_type(np.RankWarning())  # E: numpy.RankWarning
reveal_type(np.TooHardError())  # E: numpy.TooHardError
reveal_type(np.AxisError("test"))  # E: numpy.AxisError
reveal_type(np.AxisError(5, 1))  # E: numpy.AxisError

            

Reported by Pylint.

Undefined variable 'reveal_type'
Error

Line: 9 Column: 1

              reveal_type(np.VisibleDeprecationWarning())  # E: numpy.VisibleDeprecationWarning
reveal_type(np.ComplexWarning())  # E: numpy.ComplexWarning
reveal_type(np.RankWarning())  # E: numpy.RankWarning
reveal_type(np.TooHardError())  # E: numpy.TooHardError
reveal_type(np.AxisError("test"))  # E: numpy.AxisError
reveal_type(np.AxisError(5, 1))  # E: numpy.AxisError

            

Reported by Pylint.

Undefined variable 'reveal_type'
Error

Line: 10 Column: 1

              reveal_type(np.ComplexWarning())  # E: numpy.ComplexWarning
reveal_type(np.RankWarning())  # E: numpy.RankWarning
reveal_type(np.TooHardError())  # E: numpy.TooHardError
reveal_type(np.AxisError("test"))  # E: numpy.AxisError
reveal_type(np.AxisError(5, 1))  # E: numpy.AxisError

            

Reported by Pylint.

Undefined variable 'reveal_type'
Error

Line: 11 Column: 1

              reveal_type(np.RankWarning())  # E: numpy.RankWarning
reveal_type(np.TooHardError())  # E: numpy.TooHardError
reveal_type(np.AxisError("test"))  # E: numpy.AxisError
reveal_type(np.AxisError(5, 1))  # E: numpy.AxisError

            

Reported by Pylint.

Unused Type imported from typing
Error

Line: 1 Column: 1

              from typing import Type

import numpy as np

reveal_type(np.ModuleDeprecationWarning())  # E: numpy.ModuleDeprecationWarning
reveal_type(np.VisibleDeprecationWarning())  # E: numpy.VisibleDeprecationWarning
reveal_type(np.ComplexWarning())  # E: numpy.ComplexWarning
reveal_type(np.RankWarning())  # E: numpy.RankWarning
reveal_type(np.TooHardError())  # E: numpy.TooHardError

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from typing import Type

import numpy as np

reveal_type(np.ModuleDeprecationWarning())  # E: numpy.ModuleDeprecationWarning
reveal_type(np.VisibleDeprecationWarning())  # E: numpy.VisibleDeprecationWarning
reveal_type(np.ComplexWarning())  # E: numpy.ComplexWarning
reveal_type(np.RankWarning())  # E: numpy.RankWarning
reveal_type(np.TooHardError())  # E: numpy.TooHardError

            

Reported by Pylint.

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

Line: 5 Column: 1

              
compilers = ['HPUXFCompiler']

class HPUXFCompiler(FCompiler):

    compiler_type = 'hpux'
    description = 'HP Fortran 90 Compiler'
    version_pattern =  r'HP F90 (?P<version>[^\s*,]*)'


            

Reported by Pylint.

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

Line: 5 Column: 1

              
compilers = ['HPUXFCompiler']

class HPUXFCompiler(FCompiler):

    compiler_type = 'hpux'
    description = 'HP Fortran 90 Compiler'
    version_pattern =  r'HP F90 (?P<version>[^\s*,]*)'


            

Reported by Pylint.

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

Line: 5 Column: 1

              
compilers = ['HPUXFCompiler']

class HPUXFCompiler(FCompiler):

    compiler_type = 'hpux'
    description = 'HP Fortran 90 Compiler'
    version_pattern =  r'HP F90 (?P<version>[^\s*,]*)'


            

Reported by Pylint.

XXX: fix me
Error

Line: 20 Column: 2

                      'archiver'     : ["ar", "-cr"],
        'ranlib'       : ["ranlib"]
        }
    module_dir_switch = None #XXX: fix me
    module_include_switch = None #XXX: fix me
    pic_flags = ['+Z']
    def get_flags(self):
        return self.pic_flags + ['+ppu', '+DD64']
    def get_flags_opt(self):

            

Reported by Pylint.

XXX: fix me
Error

Line: 21 Column: 2

                      'ranlib'       : ["ranlib"]
        }
    module_dir_switch = None #XXX: fix me
    module_include_switch = None #XXX: fix me
    pic_flags = ['+Z']
    def get_flags(self):
        return self.pic_flags + ['+ppu', '+DD64']
    def get_flags_opt(self):
        return ['-O3']

            

Reported by Pylint.

Dangerous default value [] as argument
Error

Line: 32 Column: 5

                  def get_library_dirs(self):
        opt = ['/usr/lib/hpux64']
        return opt
    def get_version(self, force=0, ok_status=[256, 0, 1]):
        # XXX status==256 may indicate 'unrecognized option' or
        #     'no input file'. So, version_cmd needs more work.
        return FCompiler.get_version(self, force, ok_status)

if __name__ == '__main__':

            

Reported by Pylint.

XXX status==256 may indicate 'unrecognized option' or
Error

Line: 33 Column: 3

                      opt = ['/usr/lib/hpux64']
        return opt
    def get_version(self, force=0, ok_status=[256, 0, 1]):
        # XXX status==256 may indicate 'unrecognized option' or
        #     'no input file'. So, version_cmd needs more work.
        return FCompiler.get_version(self, force, ok_status)

if __name__ == '__main__':
    from distutils import log

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from numpy.distutils.fcompiler import FCompiler

compilers = ['HPUXFCompiler']

class HPUXFCompiler(FCompiler):

    compiler_type = 'hpux'
    description = 'HP Fortran 90 Compiler'
    version_pattern =  r'HP F90 (?P<version>[^\s*,]*)'

            

Reported by Pylint.

Missing class docstring
Error

Line: 5 Column: 1

              
compilers = ['HPUXFCompiler']

class HPUXFCompiler(FCompiler):

    compiler_type = 'hpux'
    description = 'HP Fortran 90 Compiler'
    version_pattern =  r'HP F90 (?P<version>[^\s*,]*)'


            

Reported by Pylint.

numpy/core/tests/test_hashtable.py
9 issues
Unable to import 'pytest'
Error

Line: 1 Column: 1

              import pytest

import random
from numpy.core._multiarray_tests import identityhash_tester


@pytest.mark.parametrize("key_length", [1, 3, 6])
@pytest.mark.parametrize("length", [1, 16, 2000])
def test_identity_hashtable(key_length, length):

            

Reported by Pylint.

Unable to import 'numpy.core._multiarray_tests'
Error

Line: 4 Column: 1

              import pytest

import random
from numpy.core._multiarray_tests import identityhash_tester


@pytest.mark.parametrize("key_length", [1, 3, 6])
@pytest.mark.parametrize("length", [1, 16, 2000])
def test_identity_hashtable(key_length, length):

            

Reported by Pylint.

Unused variable 'i'
Error

Line: 13 Column: 9

                  # use a 30 object pool for everything (duplicates will happen)
    pool = [object() for i in range(20)]
    keys_vals = []
    for i in range(length):
        keys = tuple(random.choices(pool, k=key_length))
        keys_vals.append((keys, random.choice(pool)))

    dictionary = dict(keys_vals)


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import pytest

import random
from numpy.core._multiarray_tests import identityhash_tester


@pytest.mark.parametrize("key_length", [1, 3, 6])
@pytest.mark.parametrize("length", [1, 16, 2000])
def test_identity_hashtable(key_length, length):

            

Reported by Pylint.

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

Line: 3 Column: 1

              import pytest

import random
from numpy.core._multiarray_tests import identityhash_tester


@pytest.mark.parametrize("key_length", [1, 3, 6])
@pytest.mark.parametrize("length", [1, 16, 2000])
def test_identity_hashtable(key_length, length):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 9 Column: 1

              
@pytest.mark.parametrize("key_length", [1, 3, 6])
@pytest.mark.parametrize("length", [1, 16, 2000])
def test_identity_hashtable(key_length, length):
    # use a 30 object pool for everything (duplicates will happen)
    pool = [object() for i in range(20)]
    keys_vals = []
    for i in range(length):
        keys = tuple(random.choices(pool, k=key_length))

            

Reported by Pylint.

Standard pseudo-random generators are not suitable for security/cryptographic purposes.
Security blacklist

Line: 15
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b311-random

                  keys_vals = []
    for i in range(length):
        keys = tuple(random.choices(pool, k=key_length))
        keys_vals.append((keys, random.choice(pool)))

    dictionary = dict(keys_vals)

    # add a random item at the end:
    keys_vals.append(random.choice(keys_vals))

            

Reported by Bandit.

Standard pseudo-random generators are not suitable for security/cryptographic purposes.
Security blacklist

Line: 20
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b311-random

                  dictionary = dict(keys_vals)

    # add a random item at the end:
    keys_vals.append(random.choice(keys_vals))
    # the expected one could be different with duplicates:
    expected = dictionary[keys_vals[-1][0]]

    res = identityhash_tester(key_length, keys_vals, replace=True)
    assert res is expected

            

Reported by Bandit.

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

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

                  expected = dictionary[keys_vals[-1][0]]

    res = identityhash_tester(key_length, keys_vals, replace=True)
    assert res is expected

    # check that ensuring one duplicate definitely raises:
    keys_vals.insert(0, keys_vals[-2])
    with pytest.raises(RuntimeError):
        identityhash_tester(key_length, keys_vals)

            

Reported by Bandit.