The following issues were found

Lib/xml/dom/domreg.py
11 issues
Catching too general exception Exception
Error

Line: 75 Column: 16

                  for creator in well_known_implementations.keys():
        try:
            dom = getDOMImplementation(name = creator)
        except Exception: # typically ImportError, or AttributeError
            continue
        if _good_enough(dom, features):
            return dom

    raise ImportError("no suitable DOM implementation found")

            

Reported by Pylint.

Function name "registerDOMImplementation" doesn't conform to snake_case naming style
Error

Line: 21 Column: 1

              
registered = {}

def registerDOMImplementation(name, factory):
    """registerDOMImplementation(name, factory)

    Register the factory function with the name. The factory function
    should return an object which implements the DOMImplementation
    interface. The factory function can either return the same object,

            

Reported by Pylint.

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

Line: 34 Column: 9

              
def _good_enough(dom, features):
    "_good_enough(dom, features) -> Return 1 if the dom offers the features"
    for f,v in features:
        if not dom.hasFeature(f,v):
            return 0
    return 1

def getDOMImplementation(name=None, features=()):

            

Reported by Pylint.

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

Line: 34 Column: 11

              
def _good_enough(dom, features):
    "_good_enough(dom, features) -> Return 1 if the dom offers the features"
    for f,v in features:
        if not dom.hasFeature(f,v):
            return 0
    return 1

def getDOMImplementation(name=None, features=()):

            

Reported by Pylint.

Function name "getDOMImplementation" doesn't conform to snake_case naming style
Error

Line: 39 Column: 1

                          return 0
    return 1

def getDOMImplementation(name=None, features=()):
    """getDOMImplementation(name = None, features = ()) -> DOM implementation.

    Return a suitable DOM implementation. The name is either
    well-known, the module name of a DOM implementation, or None. If
    it is not None, imports the corresponding module and returns

            

Reported by Pylint.

Import outside toplevel (os)
Error

Line: 52 Column: 5

                  be found, raise an ImportError. The features list must be a sequence
    of (feature, version) pairs which are passed to hasFeature."""

    import os
    creator = None
    mod = well_known_implementations.get(name)
    if mod:
        mod = __import__(mod, {}, {}, ['getDOMImplementation'])
        return mod.getDOMImplementation()

            

Reported by Pylint.

Unnecessary "elif" after "return"
Error

Line: 55 Column: 5

                  import os
    creator = None
    mod = well_known_implementations.get(name)
    if mod:
        mod = __import__(mod, {}, {}, ['getDOMImplementation'])
        return mod.getDOMImplementation()
    elif name:
        return registered[name]()
    elif not sys.flags.ignore_environment and "PYTHON_DOM" in os.environ:

            

Reported by Pylint.

Consider iterating the dictionary directly instead of calling .keys()
Error

Line: 72 Column: 20

                      if _good_enough(dom, features):
            return dom

    for creator in well_known_implementations.keys():
        try:
            dom = getDOMImplementation(name = creator)
        except Exception: # typically ImportError, or AttributeError
            continue
        if _good_enough(dom, features):

            

Reported by Pylint.

Try, Except, Continue detected.
Security

Line: 75
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b112_try_except_continue.html

                  for creator in well_known_implementations.keys():
        try:
            dom = getDOMImplementation(name = creator)
        except Exception: # typically ImportError, or AttributeError
            continue
        if _good_enough(dom, features):
            return dom

    raise ImportError("no suitable DOM implementation found")

            

Reported by Bandit.

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

Line: 82 Column: 1

              
    raise ImportError("no suitable DOM implementation found")

def _parse_feature_string(s):
    features = []
    parts = s.split()
    i = 0
    length = len(parts)
    while i < length:

            

Reported by Pylint.

Modules/ossaudiodev.c
11 issues
getenv - Environment variables are untrustable input if they can be set by an attacker. They can have any content and length, and the same variable can be set more than once
Security

Line: 112 Column: 21 CWE codes: 807 20
Suggestion: Check environment variables carefully before using them

                  /* Open the correct device: either the 'device' argument,
       or the AUDIODEV environment variable, or "/dev/dsp". */
    if (devicename == NULL) {              /* called with one arg */
       devicename = getenv("AUDIODEV");
       if (devicename == NULL)             /* $AUDIODEV not set */
          devicename = "/dev/dsp";
    }

    /* Open with O_NONBLOCK to avoid hanging on devices that only allow

            

Reported by FlawFinder.

getenv - Environment variables are untrustable input if they can be set by an attacker. They can have any content and length, and the same variable can be set more than once
Security

Line: 177 Column: 22 CWE codes: 807 20
Suggestion: Check environment variables carefully before using them

                  }

    if (devicename == NULL) {
        devicename = getenv("MIXERDEV");
        if (devicename == NULL)            /* MIXERDEV not set */
            devicename = "/dev/mixer";
    }

    fd = _Py_open(devicename, O_RDWR);

            

Reported by FlawFinder.

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

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

              static PyObject *
_do_ioctl_1(int fd, PyObject *args, char *fname, unsigned long cmd)
{
    char argfmt[33] = "i:";
    int arg;

    assert(strlen(fname) <= 30);
    strncat(argfmt, fname, 30);
    if (!PyArg_ParseTuple(args, argfmt, &arg))

            

Reported by FlawFinder.

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

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

              static PyObject *
_do_ioctl_1_internal(int fd, PyObject *args, char *fname, unsigned long cmd)
{
    char argfmt[32] = ":";
    int arg = 0;

    assert(strlen(fname) <= 30);
    strncat(argfmt, fname, 30);
    if (!PyArg_ParseTuple(args, argfmt, &arg))

            

Reported by FlawFinder.

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

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

              static PyObject *
_do_ioctl_0(int fd, PyObject *args, char *fname, unsigned long cmd)
{
    char argfmt[32] = ":";
    int rv;

    assert(strlen(fname) <= 30);
    strncat(argfmt, fname, 30);
    if (!PyArg_ParseTuple(args, argfmt))

            

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: 248 Column: 12 CWE codes: 126

                  char argfmt[33] = "i:";
    int arg;

    assert(strlen(fname) <= 30);
    strncat(argfmt, fname, 30);
    if (!PyArg_ParseTuple(args, argfmt, &arg))
        return NULL;

    if (ioctl(fd, cmd, &arg) == -1)

            

Reported by FlawFinder.

strncat - Easily used incorrectly (e.g., incorrectly computing the correct maximum size to add) [MS-banned]
Security

Line: 249 Column: 5 CWE codes: 120
Suggestion: Consider strcat_s, strlcat, snprintf, or automatically resizing strings

                  int arg;

    assert(strlen(fname) <= 30);
    strncat(argfmt, fname, 30);
    if (!PyArg_ParseTuple(args, argfmt, &arg))
        return NULL;

    if (ioctl(fd, cmd, &arg) == -1)
        return PyErr_SetFromErrno(PyExc_OSError);

            

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: 273 Column: 12 CWE codes: 126

                  char argfmt[32] = ":";
    int arg = 0;

    assert(strlen(fname) <= 30);
    strncat(argfmt, fname, 30);
    if (!PyArg_ParseTuple(args, argfmt, &arg))
        return NULL;

    if (ioctl(fd, cmd, &arg) == -1)

            

Reported by FlawFinder.

strncat - Easily used incorrectly (e.g., incorrectly computing the correct maximum size to add) [MS-banned]
Security

Line: 274 Column: 5 CWE codes: 120
Suggestion: Consider strcat_s, strlcat, snprintf, or automatically resizing strings

                  int arg = 0;

    assert(strlen(fname) <= 30);
    strncat(argfmt, fname, 30);
    if (!PyArg_ParseTuple(args, argfmt, &arg))
        return NULL;

    if (ioctl(fd, cmd, &arg) == -1)
        return PyErr_SetFromErrno(PyExc_OSError);

            

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: 293 Column: 12 CWE codes: 126

                  char argfmt[32] = ":";
    int rv;

    assert(strlen(fname) <= 30);
    strncat(argfmt, fname, 30);
    if (!PyArg_ParseTuple(args, argfmt))
        return NULL;

    /* According to hannu@opensound.com, all three of the ioctls that

            

Reported by FlawFinder.

Tools/scripts/gprof2html.py
11 issues
Redefining built-in 'input'
Error

Line: 31 Column: 16

                      for line in fp:
            yield html.escape(line)

def gprof2html(input, output, filename):
    output.write(header % filename)
    for line in input:
        output.write(line)
        if line.startswith(" time"):
            break

            

Reported by Pylint.

Redefining built-in 'input'
Error

Line: 81 Column: 5

                  if sys.argv[1:]:
        filename = sys.argv[1]
    outputfilename = filename + ".html"
    input = add_escapes(filename)
    with open(outputfilename, "w") as output:
        gprof2html(input, output, filename)
    webbrowser.open("file:" + os.path.abspath(outputfilename))

if __name__ == '__main__':

            

Reported by Pylint.

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

Line: 11 Column: 1

              import sys
import webbrowser

header = """\
<html>
<head>
  <title>gprof output (%s)</title>
</head>
<body>

            

Reported by Pylint.

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

Line: 20 Column: 1

              <pre>
"""

trailer = """\
</pre>
</body>
</html>
"""


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 26 Column: 1

              </html>
"""

def add_escapes(filename):
    with open(filename) as fp:
        for line in fp:
            yield html.escape(line)

def gprof2html(input, output, filename):

            

Reported by Pylint.

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

Line: 27 Column: 28

              """

def add_escapes(filename):
    with open(filename) as fp:
        for line in fp:
            yield html.escape(line)

def gprof2html(input, output, filename):
    output.write(header % filename)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 31 Column: 1

                      for line in fp:
            yield html.escape(line)

def gprof2html(input, output, filename):
    output.write(header % filename)
    for line in input:
        output.write(line)
        if line.startswith(" time"):
            break

            

Reported by Pylint.

Too many branches (15/12)
Error

Line: 31 Column: 1

                      for line in fp:
            yield html.escape(line)

def gprof2html(input, output, filename):
    output.write(header % filename)
    for line in input:
        output.write(line)
        if line.startswith(" time"):
            break

            

Reported by Pylint.

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

Line: 39 Column: 9

                          break
    labels = {}
    for line in input:
        m = re.match(r"(.*  )(\w+)\n", line)
        if not m:
            output.write(line)
            break
        stuff, fname = m.group(1, 2)
        labels[fname] = fname

            

Reported by Pylint.

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

Line: 52 Column: 9

                      if line.startswith("index % time"):
            break
    for line in input:
        m = re.match(r"(.*  )(\w+)(( &lt;cycle.*&gt;)? \[\d+\])\n", line)
        if not m:
            output.write(line)
            if line.startswith("Index by function name"):
                break
            continue

            

Reported by Pylint.

Tools/scripts/analyze_dxp.py
11 issues
Module 'sys' has no 'getdxp' member
Error

Line: 35 Column: 23

              

_profile_lock = threading.RLock()
_cumulative_profile = sys.getdxp()

# If Python was built with -DDXPAIRS, sys.getdxp() returns a list of
# lists of ints.  Otherwise it returns just a list of ints.
def has_pairs(profile):
    """Returns True if the Python that produced the argument profile

            

Reported by Pylint.

Module 'sys' has no 'getdxp' member
Error

Line: 49 Column: 9

              def reset_profile():
    """Forgets any execution profile that has been gathered so far."""
    with _profile_lock:
        sys.getdxp()  # Resets the internal profile
        global _cumulative_profile
        _cumulative_profile = sys.getdxp()  # 0s out our copy.


def merge_profile():

            

Reported by Pylint.

Module 'sys' has no 'getdxp' member
Error

Line: 51 Column: 31

                  with _profile_lock:
        sys.getdxp()  # Resets the internal profile
        global _cumulative_profile
        _cumulative_profile = sys.getdxp()  # 0s out our copy.


def merge_profile():
    """Reads sys.getdxp() and merges it into this module's cached copy.


            

Reported by Pylint.

Module 'sys' has no 'getdxp' member
Error

Line: 60 Column: 23

                  We need this because sys.getdxp() 0s itself every time it's called."""

    with _profile_lock:
        new_profile = sys.getdxp()
        if has_pairs(new_profile):
            for first_inst in range(len(_cumulative_profile)):
                for second_inst in range(len(_cumulative_profile[first_inst])):
                    _cumulative_profile[first_inst][second_inst] += (
                        new_profile[first_inst][second_inst])

            

Reported by Pylint.

Using the global statement
Error

Line: 50 Column: 9

                  """Forgets any execution profile that has been gathered so far."""
    with _profile_lock:
        sys.getdxp()  # Resets the internal profile
        global _cumulative_profile
        _cumulative_profile = sys.getdxp()  # 0s out our copy.


def merge_profile():
    """Reads sys.getdxp() and merges it into this module's cached copy.

            

Reported by Pylint.

standard import "import operator" should be placed before "import opcode"
Error

Line: 25 Column: 1

              
import copy
import opcode
import operator
import sys
import threading

if not hasattr(sys, "getdxp"):
    raise RuntimeError("Can't import analyze_dxp: Python built without"

            

Reported by Pylint.

standard import "import sys" should be placed before "import opcode"
Error

Line: 26 Column: 1

              import copy
import opcode
import operator
import sys
import threading

if not hasattr(sys, "getdxp"):
    raise RuntimeError("Can't import analyze_dxp: Python built without"
                       " -DDYNAMIC_EXECUTION_PROFILE.")

            

Reported by Pylint.

standard import "import threading" should be placed before "import opcode"
Error

Line: 27 Column: 1

              import opcode
import operator
import sys
import threading

if not hasattr(sys, "getdxp"):
    raise RuntimeError("Can't import analyze_dxp: Python built without"
                       " -DDYNAMIC_EXECUTION_PROFILE.")


            

Reported by Pylint.

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

Line: 50 Column: 9

                  """Forgets any execution profile that has been gathered so far."""
    with _profile_lock:
        sys.getdxp()  # Resets the internal profile
        global _cumulative_profile
        _cumulative_profile = sys.getdxp()  # 0s out our copy.


def merge_profile():
    """Reads sys.getdxp() and merges it into this module's cached copy.

            

Reported by Pylint.

Consider using enumerate instead of iterating with range and len
Error

Line: 62 Column: 13

                  with _profile_lock:
        new_profile = sys.getdxp()
        if has_pairs(new_profile):
            for first_inst in range(len(_cumulative_profile)):
                for second_inst in range(len(_cumulative_profile[first_inst])):
                    _cumulative_profile[first_inst][second_inst] += (
                        new_profile[first_inst][second_inst])
        else:
            for inst in range(len(_cumulative_profile)):

            

Reported by Pylint.

Tools/scripts/linktree.py
11 issues
No exception type(s) specified
Error

Line: 68 Column: 17

                              try:
                    os.mkdir(newname, 0o777)
                    ok = 1
                except:
                    print(newname + \
                          ': warning: cannot mkdir:', msg)
                    ok = 0
                if ok:
                    linkname = os.path.join(os.pardir,

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              #! /usr/bin/env python3

# linktree
#
# Make a copy of a directory tree with symbolic links to all files in the
# original tree.
# All symbolic links go to a special symbolic link at the top, so you
# can easily fix things if the original source tree moves.
# See also "mkreal".

            

Reported by Pylint.

Multiple imports on one line (sys, os)
Error

Line: 13 Column: 1

              #
# usage: mklinks oldtree newtree

import sys, os

LINK = '.LINK' # Name of special symlink at the top.

debug = 0


            

Reported by Pylint.

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

Line: 17 Column: 1

              
LINK = '.LINK' # Name of special symlink at the top.

debug = 0

def main():
    if not 3 <= len(sys.argv) <= 4:
        print('usage:', sys.argv[0], 'oldtree newtree [linkto]')
        return 2

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 19 Column: 1

              
debug = 0

def main():
    if not 3 <= len(sys.argv) <= 4:
        print('usage:', sys.argv[0], 'oldtree newtree [linkto]')
        return 2
    oldtree, newtree = sys.argv[1], sys.argv[2]
    if len(sys.argv) > 3:

            

Reported by Pylint.

Unnecessary "else" after "return"
Error

Line: 42 Column: 9

                  try:
        os.symlink(os.path.join(os.pardir, oldtree), linkname)
    except OSError as msg:
        if not link_may_fail:
            print(linkname + ': cannot symlink:', msg)
            return 1
        else:
            print(linkname + ': warning: cannot symlink:', msg)
    linknames(oldtree, newtree, link)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 50 Column: 1

                  linknames(oldtree, newtree, link)
    return 0

def linknames(old, new, link):
    if debug: print('linknames', (old, new, link))
    try:
        names = os.listdir(old)
    except OSError as msg:
        print(old + ': warning: cannot listdir:', msg)

            

Reported by Pylint.

More than one statement on a single line
Error

Line: 51 Column: 15

                  return 0

def linknames(old, new, link):
    if debug: print('linknames', (old, new, link))
    try:
        names = os.listdir(old)
    except OSError as msg:
        print(old + ': warning: cannot listdir:', msg)
        return

            

Reported by Pylint.

More than one statement on a single line
Error

Line: 62 Column: 27

                          oldname = os.path.join(old, name)
            linkname = os.path.join(link, name)
            newname = os.path.join(new, name)
            if debug > 1: print(oldname, newname, linkname)
            if os.path.isdir(oldname) and \
               not os.path.islink(oldname):
                try:
                    os.mkdir(newname, 0o777)
                    ok = 1

            

Reported by Pylint.

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

Line: 67 Column: 21

                             not os.path.islink(oldname):
                try:
                    os.mkdir(newname, 0o777)
                    ok = 1
                except:
                    print(newname + \
                          ': warning: cannot mkdir:', msg)
                    ok = 0
                if ok:

            

Reported by Pylint.

Tools/peg_generator/scripts/benchmark.py
11 issues
Unable to import 'memory_profiler'
Error

Line: 10 Column: 5

              from time import time

try:
    import memory_profiler
except ModuleNotFoundError:
    print(
        "Please run `make venv` to create a virtual environment and install"
        " all the dependencies, before running this script."
    )

            

Reported by Pylint.

Unexpected keyword argument 'mode' in function call
Error

Line: 76 Column: 9

              def run_benchmark_stdlib(subcommand):
    modes = {"compile": 2, "parse": 1}
    for _ in range(3):
        parse_directory(
            "../../Lib",
            verbose=False,
            excluded_files=[
                "*/bad*",
                "*/lib2to3/tests/data/*",

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              #!/usr/bin/env python3

import argparse
import ast
import sys
import os
from time import time

try:

            

Reported by Pylint.

Import "from scripts.test_parse_directory import parse_directory" should be placed at the top of the module
Error

Line: 19 Column: 1

                  sys.exit(1)

sys.path.insert(0, os.getcwd())
from scripts.test_parse_directory import parse_directory

argparser = argparse.ArgumentParser(
    prog="benchmark", description="Reproduce the various pegen benchmarks"
)
argparser.add_argument(

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 39 Column: 1

              command_parse = subcommands.add_parser("parse", help="Benchmark parsing and generating an ast.AST")


def benchmark(func):
    def wrapper(*args):
        times = list()
        for _ in range(3):
            start = time()
            result = func(*args)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 57 Column: 1

              

@benchmark
def time_compile(source):
    return compile(source, "<string>", "exec")


@benchmark
def time_parse(source):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 62 Column: 1

              

@benchmark
def time_parse(source):
    return ast.parse(source)


def run_benchmark_xxl(subcommand, source):
    if subcommand == "compile":

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 66 Column: 1

                  return ast.parse(source)


def run_benchmark_xxl(subcommand, source):
    if subcommand == "compile":
        time_compile(source)
    elif subcommand == "parse":
        time_parse(source)


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 73 Column: 1

                      time_parse(source)


def run_benchmark_stdlib(subcommand):
    modes = {"compile": 2, "parse": 1}
    for _ in range(3):
        parse_directory(
            "../../Lib",
            verbose=False,

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 88 Column: 1

                      )


def main():
    args = argparser.parse_args()
    subcommand = args.subcommand
    target = args.target

    if subcommand is None:

            

Reported by Pylint.

Tools/peg_generator/scripts/download_pypi_packages.py
11 issues
Audit url open for permitted schemes. Allowing use of file:/ or custom schemes is often unexpected.
Security blacklist

Line: 35
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b310-urllib-urlopen

              
def download_package_json(package_name: str) -> None:
    url = f"https://pypi.org/pypi/{package_name}/json"
    urlretrieve(url, os.path.join("data", f"{package_name}.json"))


def download_package_code(name: str, package_json: Dict[Any, Any]) -> None:
    source_index = -1
    for idx, url_info in enumerate(package_json["urls"]):

            

Reported by Bandit.

Unused argument 'name'
Error

Line: 38 Column: 27

                  urlretrieve(url, os.path.join("data", f"{package_name}.json"))


def download_package_code(name: str, package_json: Dict[Any, Any]) -> None:
    source_index = -1
    for idx, url_info in enumerate(package_json["urls"]):
        if url_info["python_version"] == "source":
            source_index = idx
            break

            

Reported by Pylint.

Audit url open for permitted schemes. Allowing use of file:/ or custom schemes is often unexpected.
Security blacklist

Line: 46
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b310-urllib-urlopen

                          break
    filename = package_json["urls"][source_index]["filename"]
    url = package_json["urls"][source_index]["url"]
    urlretrieve(url, os.path.join("data", "pypi", filename))


def main() -> None:
    args = argparser.parse_args()
    number_packages = args.number

            

Reported by Bandit.

Missing module docstring
Error

Line: 1 Column: 1

              #!/usr/bin/env python3.8

import argparse
import os
import json

from typing import Dict, Any
from urllib.request import urlretrieve


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 22 Column: 1

              )


def load_json(filename: str) -> Dict[Any, Any]:
    with open(os.path.join("data", f"{filename}.json"), "r") as f:
        j = json.loads(f.read())
    return j



            

Reported by Pylint.

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

Line: 23 Column: 65

              

def load_json(filename: str) -> Dict[Any, Any]:
    with open(os.path.join("data", f"{filename}.json"), "r") as f:
        j = json.loads(f.read())
    return j


def remove_json(filename: str) -> None:

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 28 Column: 1

                  return j


def remove_json(filename: str) -> None:
    path = os.path.join("data", f"{filename}.json")
    os.remove(path)


def download_package_json(package_name: str) -> None:

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 33 Column: 1

                  os.remove(path)


def download_package_json(package_name: str) -> None:
    url = f"https://pypi.org/pypi/{package_name}/json"
    urlretrieve(url, os.path.join("data", f"{package_name}.json"))


def download_package_code(name: str, package_json: Dict[Any, Any]) -> None:

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 38 Column: 1

                  urlretrieve(url, os.path.join("data", f"{package_name}.json"))


def download_package_code(name: str, package_json: Dict[Any, Any]) -> None:
    source_index = -1
    for idx, url_info in enumerate(package_json["urls"]):
        if url_info["python_version"] == "source":
            source_index = idx
            break

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 49 Column: 1

                  urlretrieve(url, os.path.join("data", "pypi", filename))


def main() -> None:
    args = argparser.parse_args()
    number_packages = args.number
    all_packages = args.all

    top_pypi_packages = load_json("top-pypi-packages-365-days")

            

Reported by Pylint.

Lib/test/test_json/test_default.py
11 issues
Instance of 'TestDefault' has no 'assertEqual' member
Error

Line: 6 Column: 9

              
class TestDefault:
    def test_default(self):
        self.assertEqual(
            self.dumps(type, default=repr),
            self.dumps(repr(type)))


class TestPyDefault(TestDefault, PyTest): pass

            

Reported by Pylint.

Instance of 'TestDefault' has no 'dumps' member
Error

Line: 7 Column: 13

              class TestDefault:
    def test_default(self):
        self.assertEqual(
            self.dumps(type, default=repr),
            self.dumps(repr(type)))


class TestPyDefault(TestDefault, PyTest): pass
class TestCDefault(TestDefault, CTest): pass

            

Reported by Pylint.

Instance of 'TestDefault' has no 'dumps' member
Error

Line: 8 Column: 13

                  def test_default(self):
        self.assertEqual(
            self.dumps(type, default=repr),
            self.dumps(repr(type)))


class TestPyDefault(TestDefault, PyTest): pass
class TestCDefault(TestDefault, CTest): pass

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from test.test_json import PyTest, CTest


class TestDefault:
    def test_default(self):
        self.assertEqual(
            self.dumps(type, default=repr),
            self.dumps(repr(type)))


            

Reported by Pylint.

Missing class docstring
Error

Line: 4 Column: 1

              from test.test_json import PyTest, CTest


class TestDefault:
    def test_default(self):
        self.assertEqual(
            self.dumps(type, default=repr),
            self.dumps(repr(type)))


            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 4 Column: 1

              from test.test_json import PyTest, CTest


class TestDefault:
    def test_default(self):
        self.assertEqual(
            self.dumps(type, default=repr),
            self.dumps(repr(type)))


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 5 Column: 5

              

class TestDefault:
    def test_default(self):
        self.assertEqual(
            self.dumps(type, default=repr),
            self.dumps(repr(type)))



            

Reported by Pylint.

Missing class docstring
Error

Line: 11 Column: 1

                          self.dumps(repr(type)))


class TestPyDefault(TestDefault, PyTest): pass
class TestCDefault(TestDefault, CTest): pass

            

Reported by Pylint.

More than one statement on a single line
Error

Line: 11 Column: 43

                          self.dumps(repr(type)))


class TestPyDefault(TestDefault, PyTest): pass
class TestCDefault(TestDefault, CTest): pass

            

Reported by Pylint.

Missing class docstring
Error

Line: 12 Column: 1

              

class TestPyDefault(TestDefault, PyTest): pass
class TestCDefault(TestDefault, CTest): pass

            

Reported by Pylint.

Lib/lzma.py
11 issues
Wildcard import _lzma
Error

Line: 27 Column: 1

              import builtins
import io
import os
from _lzma import *
from _lzma import _encode_filter_properties, _decode_filter_properties
import _compression


_MODE_CLOSED   = 0

            

Reported by Pylint.

Unused _encode_filter_properties imported from _lzma
Error

Line: 28 Column: 1

              import io
import os
from _lzma import *
from _lzma import _encode_filter_properties, _decode_filter_properties
import _compression


_MODE_CLOSED   = 0
_MODE_READ     = 1

            

Reported by Pylint.

Unused _decode_filter_properties imported from _lzma
Error

Line: 28 Column: 1

              import io
import os
from _lzma import *
from _lzma import _encode_filter_properties, _decode_filter_properties
import _compression


_MODE_CLOSED   = 0
_MODE_READ     = 1

            

Reported by Pylint.

__init__ method from base class 'BaseStream' is not called
Error

Line: 49 Column: 5

                  is returned as bytes, and data to be written must be given as bytes.
    """

    def __init__(self, filename=None, mode="r", *,
                 format=None, check=-1, preset=None, filters=None):
        """Open an LZMA-compressed file in binary mode.

        filename can be either an actual file name (given as a str,
        bytes, or PathLike object), in which case the named file is

            

Reported by Pylint.

Redefining built-in 'format'
Error

Line: 50 Column: 18

                  """

    def __init__(self, filename=None, mode="r", *,
                 format=None, check=-1, preset=None, filters=None):
        """Open an LZMA-compressed file in binary mode.

        filename can be either an actual file name (given as a str,
        bytes, or PathLike object), in which case the named file is
        opened, or it can be an existing file object to read from or

            

Reported by Pylint.

Redefining built-in 'open'
Error

Line: 275 Column: 1

                      return self._pos


def open(filename, mode="rb", *,
         format=None, check=-1, preset=None, filters=None,
         encoding=None, errors=None, newline=None):
    """Open an LZMA-compressed file in binary or text mode.

    filename can be either an actual file name (given as a str, bytes,

            

Reported by Pylint.

Redefining built-in 'format'
Error

Line: 276 Column: 10

              

def open(filename, mode="rb", *,
         format=None, check=-1, preset=None, filters=None,
         encoding=None, errors=None, newline=None):
    """Open an LZMA-compressed file in binary or text mode.

    filename can be either an actual file name (given as a str, bytes,
    or PathLike object), in which case the named file is opened, or it

            

Reported by Pylint.

Redefining built-in 'format'
Error

Line: 323 Column: 20

                      return binary_file


def compress(data, format=FORMAT_XZ, check=-1, preset=None, filters=None):
    """Compress a block of data.

    Refer to LZMACompressor's docstring for a description of the
    optional arguments *format*, *check*, *preset* and *filters*.


            

Reported by Pylint.

Redefining built-in 'format'
Error

Line: 335 Column: 22

                  return comp.compress(data) + comp.flush()


def decompress(data, format=FORMAT_AUTO, memlimit=None, filters=None):
    """Decompress a block of data.

    Refer to LZMADecompressor's docstring for a description of the
    optional arguments *format*, *check* and *filters*.


            

Reported by Pylint.

Unnecessary "else" after "return"
Error

Line: 316 Column: 5

                  binary_file = LZMAFile(filename, lz_mode, format=format, check=check,
                           preset=preset, filters=filters)

    if "t" in mode:
        encoding = io.text_encoding(encoding)
        return io.TextIOWrapper(binary_file, encoding, errors, newline)
    else:
        return binary_file


            

Reported by Pylint.

Lib/test/badsyntax_future5.py
11 issues
Unable to import 'foo'
Error

Line: 3 Column: 1

              """This is a test"""
from __future__ import nested_scopes
import foo
from __future__ import nested_scopes


def f(x):
    def g(y):
        return x + y

            

Reported by Pylint.

Unused import foo
Error

Line: 3 Column: 1

              """This is a test"""
from __future__ import nested_scopes
import foo
from __future__ import nested_scopes


def f(x):
    def g(y):
        return x + y

            

Reported by Pylint.

__future__ import is not the first non docstring statement
Error

Line: 4 Column: 1

              """This is a test"""
from __future__ import nested_scopes
import foo
from __future__ import nested_scopes


def f(x):
    def g(y):
        return x + y

            

Reported by Pylint.

Reimport 'nested_scopes' (imported line 2)
Error

Line: 4 Column: 1

              """This is a test"""
from __future__ import nested_scopes
import foo
from __future__ import nested_scopes


def f(x):
    def g(y):
        return x + y

            

Reported by Pylint.

standard import "from __future__ import nested_scopes" should be placed before "import foo"
Error

Line: 4 Column: 1

              """This is a test"""
from __future__ import nested_scopes
import foo
from __future__ import nested_scopes


def f(x):
    def g(y):
        return x + y

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 7 Column: 1

              from __future__ import nested_scopes


def f(x):
    def g(y):
        return x + y
    return g

result = f(2)(4)

            

Reported by Pylint.

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

Line: 7 Column: 1

              from __future__ import nested_scopes


def f(x):
    def g(y):
        return x + y
    return g

result = f(2)(4)

            

Reported by Pylint.

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

Line: 7 Column: 1

              from __future__ import nested_scopes


def f(x):
    def g(y):
        return x + y
    return g

result = f(2)(4)

            

Reported by Pylint.

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

Line: 8 Column: 5

              

def f(x):
    def g(y):
        return x + y
    return g

result = f(2)(4)

            

Reported by Pylint.

Function name "g" doesn't conform to snake_case naming style
Error

Line: 8 Column: 5

              

def f(x):
    def g(y):
        return x + y
    return g

result = f(2)(4)

            

Reported by Pylint.