The following issues were found

tools/download-wheels.py
5 issues
Unable to import 'bs4'
Error

Line: 33 Column: 1

              import argparse

import urllib3
from bs4 import BeautifulSoup

__version__ = '0.1'

# Edit these for other projects.
STAGING_URL = 'https://anaconda.org/multibuild-wheels-staging/numpy'

            

Reported by Pylint.

Redefining name 'wheelhouse' from outer scope (line 102)
Error

Line: 62 Column: 30

                  return soup.findAll(text=tmpl)


def download_wheels(version, wheelhouse):
    """Download release wheels.

    The release wheels for the given NumPy version are downloaded
    into the given directory.


            

Reported by Pylint.

Module name "download-wheels" doesn't conform to snake_case naming style
Error

Line: 1 Column: 1

              #!/usr/bin/env python3
# -*- encoding:utf-8 -*-
"""
Script to download NumPy wheels from the Anaconda staging area.

Usage::

    $ ./tools/download-wheels.py <version> -w <optional-wheelhouse>


            

Reported by Pylint.

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

Line: 82 Column: 40

                  for i, wheel_name in enumerate(wheel_names):
        wheel_url = f"{STAGING_URL}/{version}/download/{wheel_name}"
        wheel_path = os.path.join(wheelhouse, wheel_name)
        with open(wheel_path, 'wb') as f:
            with http.request('GET', wheel_url, preload_content=False,) as r:
                print(f"{i + 1:<4}{wheel_name}")
                shutil.copyfileobj(r, f)
    print(f"\nTotal files downloaded: {len(wheel_names)}")


            

Reported by Pylint.

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

Line: 83 Column: 76

                      wheel_url = f"{STAGING_URL}/{version}/download/{wheel_name}"
        wheel_path = os.path.join(wheelhouse, wheel_name)
        with open(wheel_path, 'wb') as f:
            with http.request('GET', wheel_url, preload_content=False,) as r:
                print(f"{i + 1:<4}{wheel_name}")
                shutil.copyfileobj(r, f)
    print(f"\nTotal files downloaded: {len(wheel_names)}")



            

Reported by Pylint.

numpy/core/_add_newdocs.py
5 issues
Too many lines in module (6533/1000)
Error

Line: 1 Column: 1

              """
This is only meant to add docs to objects defined in C-extension modules.
The purpose is to allow easier editing of the docstrings without
requiring a re-compile.

NOTE: Many of the methods of ndarray have corresponding functions.
      If you update these docstrings, please keep also the ones in
      core/fromnumeric.py, core/defmatrix.py up-to-date.


            

Reported by Pylint.

Line too long (128/100)
Error

Line: 154 Column: 1

              
add_newdoc('numpy.core', 'nditer',
    """
    nditer(op, flags=None, op_flags=None, op_dtypes=None, order='K', casting='safe', op_axes=None, itershape=None, buffersize=0)

    Efficient multi-dimensional iterator object to iterate over arrays.
    To get started using this object, see the
    :ref:`introductory guide to array iteration <arrays.nditer>`.


            

Reported by Pylint.

Trailing whitespace
Error

Line: 799 Column: 74

                  object : array_like
        An array, any object exposing the array interface, an object whose
        __array__ method returns an array, or any (nested) sequence.
        If object is a scalar, a 0-dimensional array containing object is 
        returned.
    dtype : data-type, optional
        The desired data-type for the array.  If not given, then the type will
        be determined as the minimum type required to hold the objects in the
        sequence.

            

Reported by Pylint.

Line too long (104/100)
Error

Line: 1804 Column: 1

                         casting='safe')

    *This documentation shadows that of the native python implementation of the `einsum` function,
    except all references and examples related to the `optimize` argument (v 0.12.0) have been removed.*

    Evaluates the Einstein summation convention on the operands.

    Using the Einstein summation convention, many common multi-dimensional,
    linear algebraic array operations can be represented in a simple fashion.

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 6233 Column: 1

              
# Attributes

def refer_to_array_attribute(attr, method=True):
    docstring = """
    Scalar {} identical to the corresponding array attribute.

    Please see `ndarray.{}`.
    """

            

Reported by Pylint.

numpy/distutils/fcompiler/pathf95.py
5 issues
Method 'wrap_unlinkable_objects' is abstract in class 'FCompiler' but is not overridden
Error

Line: 5 Column: 1

              
compilers = ['PathScaleFCompiler']

class PathScaleFCompiler(FCompiler):

    compiler_type = 'pathf95'
    description = 'PathScale Fortran Compiler'
    version_pattern =  r'PathScale\(TM\) Compiler Suite: Version (?P<version>[\d.]+)'


            

Reported by Pylint.

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

Line: 5 Column: 1

              
compilers = ['PathScaleFCompiler']

class PathScaleFCompiler(FCompiler):

    compiler_type = 'pathf95'
    description = 'PathScale Fortran Compiler'
    version_pattern =  r'PathScale\(TM\) Compiler Suite: Version (?P<version>[\d.]+)'


            

Reported by Pylint.

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

Line: 5 Column: 1

              
compilers = ['PathScaleFCompiler']

class PathScaleFCompiler(FCompiler):

    compiler_type = 'pathf95'
    description = 'PathScale Fortran Compiler'
    version_pattern =  r'PathScale\(TM\) Compiler Suite: Version (?P<version>[\d.]+)'


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from numpy.distutils.fcompiler import FCompiler

compilers = ['PathScaleFCompiler']

class PathScaleFCompiler(FCompiler):

    compiler_type = 'pathf95'
    description = 'PathScale Fortran Compiler'
    version_pattern =  r'PathScale\(TM\) Compiler Suite: Version (?P<version>[\d.]+)'

            

Reported by Pylint.

Missing class docstring
Error

Line: 5 Column: 1

              
compilers = ['PathScaleFCompiler']

class PathScaleFCompiler(FCompiler):

    compiler_type = 'pathf95'
    description = 'PathScale Fortran Compiler'
    version_pattern =  r'PathScale\(TM\) Compiler Suite: Version (?P<version>[\d.]+)'


            

Reported by Pylint.

numpy/distutils/fcompiler/none.py
5 issues
Method 'wrap_unlinkable_objects' is abstract in class 'FCompiler' but is not overridden
Error

Line: 6 Column: 1

              
compilers = ['NoneFCompiler']

class NoneFCompiler(FCompiler):

    compiler_type = 'none'
    description = 'Fake Fortran compiler'

    executables = {'compiler_f77': None,

            

Reported by Pylint.

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

Line: 6 Column: 1

              
compilers = ['NoneFCompiler']

class NoneFCompiler(FCompiler):

    compiler_type = 'none'
    description = 'Fake Fortran compiler'

    executables = {'compiler_f77': None,

            

Reported by Pylint.

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

Line: 6 Column: 1

              
compilers = ['NoneFCompiler']

class NoneFCompiler(FCompiler):

    compiler_type = 'none'
    description = 'Fake Fortran compiler'

    executables = {'compiler_f77': None,

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from numpy.distutils.fcompiler import FCompiler
from numpy.distutils import customized_fcompiler

compilers = ['NoneFCompiler']

class NoneFCompiler(FCompiler):

    compiler_type = 'none'
    description = 'Fake Fortran compiler'

            

Reported by Pylint.

Missing class docstring
Error

Line: 6 Column: 1

              
compilers = ['NoneFCompiler']

class NoneFCompiler(FCompiler):

    compiler_type = 'none'
    description = 'Fake Fortran compiler'

    executables = {'compiler_f77': None,

            

Reported by Pylint.

numpy/distutils/command/install_headers.py
5 issues
Missing module docstring
Error

Line: 1 Column: 1

              import os
from distutils.command.install_headers import install_headers as old_install_headers

class install_headers (old_install_headers):

    def run (self):
        headers = self.distribution.headers
        if not headers:
            return

            

Reported by Pylint.

Missing class docstring
Error

Line: 4 Column: 1

              import os
from distutils.command.install_headers import install_headers as old_install_headers

class install_headers (old_install_headers):

    def run (self):
        headers = self.distribution.headers
        if not headers:
            return

            

Reported by Pylint.

Class name "install_headers" doesn't conform to PascalCase naming style
Error

Line: 4 Column: 1

              import os
from distutils.command.install_headers import install_headers as old_install_headers

class install_headers (old_install_headers):

    def run (self):
        headers = self.distribution.headers
        if not headers:
            return

            

Reported by Pylint.

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

Line: 19 Column: 17

                                  header = ('numpy', header[1])
                    if os.path.splitext(header[1])[1] == '.inc':
                        continue
                d = os.path.join(*([prefix]+header[0].split('.')))
                header = header[1]
            else:
                d = self.install_dir
            self.mkpath(d)
            (out, _) = self.copy_file(header, d)

            

Reported by Pylint.

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

Line: 22 Column: 17

                              d = os.path.join(*([prefix]+header[0].split('.')))
                header = header[1]
            else:
                d = self.install_dir
            self.mkpath(d)
            (out, _) = self.copy_file(header, d)
            self.outfiles.append(out)

            

Reported by Pylint.

numpy/typing/tests/test_isfile.py
5 issues
Using deprecated method assert_()
Error

Line: 32 Column: 13

                  def test_isfile(self):
        """Test if all ``.pyi`` files are properly installed."""
        for file in FILES:
            assert_(os.path.isfile(file))

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import os
from pathlib import Path

import numpy as np
from numpy.testing import assert_

ROOT = Path(np.__file__).parents[0]
FILES = [
    ROOT / "py.typed",

            

Reported by Pylint.

Missing class docstring
Error

Line: 28 Column: 1

              ]


class TestIsFile:
    def test_isfile(self):
        """Test if all ``.pyi`` files are properly installed."""
        for file in FILES:
            assert_(os.path.isfile(file))

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 28 Column: 1

              ]


class TestIsFile:
    def test_isfile(self):
        """Test if all ``.pyi`` files are properly installed."""
        for file in FILES:
            assert_(os.path.isfile(file))

            

Reported by Pylint.

Method could be a function
Error

Line: 29 Column: 5

              

class TestIsFile:
    def test_isfile(self):
        """Test if all ``.pyi`` files are properly installed."""
        for file in FILES:
            assert_(os.path.isfile(file))

            

Reported by Pylint.

numpy/core/src/multiarray/dragon4.c
5 issues
char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 163 Column: 5 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 BIGINT_DRAGON4_GROUPSIZE 7
typedef struct {
    BigInt bigints[BIGINT_DRAGON4_GROUPSIZE];
    char repr[16384];
} Dragon4_Scratch;

static int _bigint_static_in_use = 0;
static Dragon4_Scratch _bigint_static;


            

Reported by FlawFinder.

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

Line: 2011 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

              
    /* print the exponent into a local buffer and copy into output buffer */
    if (bufferSize > 1) {
        char exponentBuffer[7];
        npy_int32 digits[5];
        npy_int32 i, exp_size, count;

        if (exp_digits > 5) {
            exp_digits = 5;

            

Reported by FlawFinder.

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

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

                      if (count > (npy_int32)bufferSize - 1) {
            count = (npy_int32)bufferSize - 1;
        }
        memcpy(pCurOut, exponentBuffer, count);
        pCurOut += count;
        bufferSize -= count;
    }



            

Reported by FlawFinder.

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

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

              
        /* copy and make sure the buffer is terminated */
        printLen = (3 < maxPrintLen - pos) ? 3 : maxPrintLen - pos;
        memcpy(buffer + pos, "inf", printLen);
        buffer[pos + printLen] = '\0';
        return pos + printLen;
    }
    else {
        /* copy and make sure the buffer is terminated */

            

Reported by FlawFinder.

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

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

                  else {
        /* copy and make sure the buffer is terminated */
        npy_uint32 printLen = (3 < maxPrintLen - pos) ? 3 : maxPrintLen - pos;
        memcpy(buffer + pos, "nan", printLen);
        buffer[pos + printLen] = '\0';

        /*
         *  For numpy we ignore unusual mantissa values for nan, but keep this
         *  code in case we change our mind later.

            

Reported by FlawFinder.

numpy/distutils/command/egg_info.py
5 issues
Missing module docstring
Error

Line: 1 Column: 1

              import sys

from setuptools.command.egg_info import egg_info as _egg_info

class egg_info(_egg_info):
    def run(self):
        if 'sdist' in sys.argv:
            import warnings
            import textwrap

            

Reported by Pylint.

Class name "egg_info" doesn't conform to PascalCase naming style
Error

Line: 5 Column: 1

              
from setuptools.command.egg_info import egg_info as _egg_info

class egg_info(_egg_info):
    def run(self):
        if 'sdist' in sys.argv:
            import warnings
            import textwrap
            msg = textwrap.dedent("""

            

Reported by Pylint.

Missing class docstring
Error

Line: 5 Column: 1

              
from setuptools.command.egg_info import egg_info as _egg_info

class egg_info(_egg_info):
    def run(self):
        if 'sdist' in sys.argv:
            import warnings
            import textwrap
            msg = textwrap.dedent("""

            

Reported by Pylint.

Import outside toplevel (warnings)
Error

Line: 8 Column: 13

              class egg_info(_egg_info):
    def run(self):
        if 'sdist' in sys.argv:
            import warnings
            import textwrap
            msg = textwrap.dedent("""
                `build_src` is being run, this may lead to missing
                files in your sdist!  You want to use distutils.sdist
                instead of the setuptools version:

            

Reported by Pylint.

Import outside toplevel (textwrap)
Error

Line: 9 Column: 13

                  def run(self):
        if 'sdist' in sys.argv:
            import warnings
            import textwrap
            msg = textwrap.dedent("""
                `build_src` is being run, this may lead to missing
                files in your sdist!  You want to use distutils.sdist
                instead of the setuptools version:


            

Reported by Pylint.

numpy/typing/tests/test_typing_extensions.py
5 issues
Using subprocess.run without explicitly set `check` is not recommended.
Error

Line: 30 Column: 9

                  impossible as it is an indirect hard dependency of pytest.

    """
    p = subprocess.run([sys.executable, '-c', CODE], capture_output=True)
    if p.returncode:
        raise AssertionError(
            f"Non-zero return code: {p.returncode!r}\n\n{p.stderr.decode()}"
        )


            

Reported by Pylint.

Consider possible security implications associated with subprocess module.
Security blacklist

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

              
import sys
import textwrap
import subprocess

CODE = textwrap.dedent(r"""
    import sys
    import importlib


            

Reported by Bandit.

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

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

                  impossible as it is an indirect hard dependency of pytest.

    """
    p = subprocess.run([sys.executable, '-c', CODE], capture_output=True)
    if p.returncode:
        raise AssertionError(
            f"Non-zero return code: {p.returncode!r}\n\n{p.stderr.decode()}"
        )


            

Reported by Bandit.

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

Line: 30 Column: 5

                  impossible as it is an indirect hard dependency of pytest.

    """
    p = subprocess.run([sys.executable, '-c', CODE], capture_output=True)
    if p.returncode:
        raise AssertionError(
            f"Non-zero return code: {p.returncode!r}\n\n{p.stderr.decode()}"
        )


            

Reported by Pylint.

Trailing newlines
Error

Line: 35 Column: 1

                      raise AssertionError(
            f"Non-zero return code: {p.returncode!r}\n\n{p.stderr.decode()}"
        )


            

Reported by Pylint.

numpy/distutils/command/install_clib.py
5 issues
Missing module docstring
Error

Line: 1 Column: 1

              import os
from distutils.core import Command
from distutils.ccompiler import new_compiler
from numpy.distutils.misc_util import get_cmd

class install_clib(Command):
    description = "Command to install installable C libraries"

    user_options = []

            

Reported by Pylint.

Missing class docstring
Error

Line: 6 Column: 1

              from distutils.ccompiler import new_compiler
from numpy.distutils.misc_util import get_cmd

class install_clib(Command):
    description = "Command to install installable C libraries"

    user_options = []

    def initialize_options(self):

            

Reported by Pylint.

Class name "install_clib" doesn't conform to PascalCase naming style
Error

Line: 6 Column: 1

              from distutils.ccompiler import new_compiler
from numpy.distutils.misc_util import get_cmd

class install_clib(Command):
    description = "Command to install installable C libraries"

    user_options = []

    def initialize_options(self):

            

Reported by Pylint.

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

Line: 32 Column: 13

                      else:
            compiler = build_clib_cmd.compiler

        for l in self.distribution.installed_libraries:
            target_dir = os.path.join(self.install_dir, l.target_dir)
            name = compiler.library_filename(l.name)
            source = os.path.join(build_dir, name)
            self.mkpath(target_dir)
            self.outfiles.append(self.copy_file(source, target_dir)[0])

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 39 Column: 5

                          self.mkpath(target_dir)
            self.outfiles.append(self.copy_file(source, target_dir)[0])

    def get_outputs(self):
        return self.outfiles

            

Reported by Pylint.