The following issues were found

PC/layout/support/nuspec.py
14 issues
Attempted relative import beyond top-level package
Error

Line: 8 Column: 1

              import os
import sys

from .constants import *

__all__ = ["get_nuspec_layout"]

PYTHON_NUSPEC_NAME = "python.nuspec"


            

Reported by Pylint.

Undefined variable 'VER_DOT'
Error

Line: 15 Column: 19

              PYTHON_NUSPEC_NAME = "python.nuspec"

NUSPEC_DATA = {
    "PYTHON_TAG": VER_DOT,
    "PYTHON_VERSION": os.getenv("PYTHON_NUSPEC_VERSION"),
    "FILELIST": r'    <file src="**\*" exclude="python.png" target="tools" />',
    "GIT": sys._git,
}


            

Reported by Pylint.

Undefined variable 'VER_SUFFIX'
Error

Line: 31 Column: 56

              
if not NUSPEC_DATA["PYTHON_VERSION"]:
    NUSPEC_DATA["PYTHON_VERSION"] = "{}.{}{}{}".format(
        VER_DOT, VER_MICRO, "-" if VER_SUFFIX else "", VER_SUFFIX
    )

FILELIST_WITH_PROPS = r"""    <file src="**\*" exclude="python.png;python.props" target="tools" />
    <file src="python.props" target="build\native" />"""


            

Reported by Pylint.

Undefined variable 'VER_SUFFIX'
Error

Line: 31 Column: 36

              
if not NUSPEC_DATA["PYTHON_VERSION"]:
    NUSPEC_DATA["PYTHON_VERSION"] = "{}.{}{}{}".format(
        VER_DOT, VER_MICRO, "-" if VER_SUFFIX else "", VER_SUFFIX
    )

FILELIST_WITH_PROPS = r"""    <file src="**\*" exclude="python.png;python.props" target="tools" />
    <file src="python.props" target="build\native" />"""


            

Reported by Pylint.

Undefined variable 'VER_MICRO'
Error

Line: 31 Column: 18

              
if not NUSPEC_DATA["PYTHON_VERSION"]:
    NUSPEC_DATA["PYTHON_VERSION"] = "{}.{}{}{}".format(
        VER_DOT, VER_MICRO, "-" if VER_SUFFIX else "", VER_SUFFIX
    )

FILELIST_WITH_PROPS = r"""    <file src="**\*" exclude="python.png;python.props" target="tools" />
    <file src="python.props" target="build\native" />"""


            

Reported by Pylint.

Undefined variable 'VER_DOT'
Error

Line: 31 Column: 9

              
if not NUSPEC_DATA["PYTHON_VERSION"]:
    NUSPEC_DATA["PYTHON_VERSION"] = "{}.{}{}{}".format(
        VER_DOT, VER_MICRO, "-" if VER_SUFFIX else "", VER_SUFFIX
    )

FILELIST_WITH_PROPS = r"""    <file src="**\*" exclude="python.png;python.props" target="tools" />
    <file src="python.props" target="build\native" />"""


            

Reported by Pylint.

Wildcard import constants
Error

Line: 8 Column: 1

              import os
import sys

from .constants import *

__all__ = ["get_nuspec_layout"]

PYTHON_NUSPEC_NAME = "python.nuspec"


            

Reported by Pylint.

Access to a protected member _git of a client class
Error

Line: 18 Column: 12

                  "PYTHON_TAG": VER_DOT,
    "PYTHON_VERSION": os.getenv("PYTHON_NUSPEC_VERSION"),
    "FILELIST": r'    <file src="**\*" exclude="python.png" target="tools" />',
    "GIT": sys._git,
}

NUSPEC_PLATFORM_DATA = dict(
    _keys=("PYTHON_BITNESS", "PACKAGENAME", "PACKAGETITLE"),
    win32=("32-bit", "pythonx86", "Python (32-bit)"),

            

Reported by Pylint.

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

Line: 60 Column: 1

              """


def _get_nuspec_data_overrides(ns):
    for k, v in zip(NUSPEC_PLATFORM_DATA["_keys"], NUSPEC_PLATFORM_DATA[ns.arch]):
        ev = os.getenv("PYTHON_NUSPEC_" + k)
        if ev:
            yield k, ev
        yield k, v

            

Reported by Pylint.

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

Line: 61 Column: 12

              

def _get_nuspec_data_overrides(ns):
    for k, v in zip(NUSPEC_PLATFORM_DATA["_keys"], NUSPEC_PLATFORM_DATA[ns.arch]):
        ev = os.getenv("PYTHON_NUSPEC_" + k)
        if ev:
            yield k, ev
        yield k, v


            

Reported by Pylint.

Tools/scripts/pysource.py
14 issues
Redefining name 'fullpath' from outer scope (line 126)
Error

Line: 33 Column: 11

                  if debug: print(msg)


def _open(fullpath):
    try:
        size = os.stat(fullpath).st_size
    except OSError as err: # Permission denied - ignore the file
        print_debug("%s: permission denied: %s" % (fullpath, err))
        return None

            

Reported by Pylint.

Redefining name 'fullpath' from outer scope (line 126)
Error

Line: 50 Column: 20

                      print_debug("%s: access denied: %s" % (fullpath, err))
        return None

def has_python_ext(fullpath):
    return fullpath.endswith(".py") or fullpath.endswith(".pyw")

def looks_like_python(fullpath):
    infile = _open(fullpath)
    if infile is None:

            

Reported by Pylint.

Redefining name 'fullpath' from outer scope (line 126)
Error

Line: 53 Column: 23

              def has_python_ext(fullpath):
    return fullpath.endswith(".py") or fullpath.endswith(".pyw")

def looks_like_python(fullpath):
    infile = _open(fullpath)
    if infile is None:
        return False

    with infile:

            

Reported by Pylint.

Redefining name 'fullpath' from outer scope (line 126)
Error

Line: 74 Column: 21

              
    return False

def can_be_compiled(fullpath):
    infile = _open(fullpath)
    if infile is None:
        return False

    with infile:

            

Reported by Pylint.

Catching too general exception Exception
Error

Line: 84 Column: 12

              
    try:
        compile(code, fullpath, "exec")
    except Exception as err:
        print_debug("%s: cannot compile: %s" % (fullpath, err))
        return False

    return True


            

Reported by Pylint.

Redefining name 'fullpath' from outer scope (line 126)
Error

Line: 116 Column: 21

                                  if exclude in dirnames:
                        dirnames.remove(exclude)
                for filename in filenames:
                    fullpath = os.path.join(dirpath, filename)
                    print_debug("testing: %s" % fullpath)
                    if is_python(fullpath):
                        yield fullpath
        else:
            print_debug("    unknown type")

            

Reported by Pylint.

Multiple imports on one line (os, re)
Error

Line: 23 Column: 1

              __all__ = ["has_python_ext", "looks_like_python", "can_be_compiled", "walk_python_files"]


import os, re

binary_re = re.compile(br'[\x00-\x08\x0E-\x1F\x7F]')

debug = False


            

Reported by Pylint.

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

Line: 27 Column: 1

              
binary_re = re.compile(br'[\x00-\x08\x0E-\x1F\x7F]')

debug = False

def print_debug(msg):
    if debug: print(msg)



            

Reported by Pylint.

Missing function or method docstring
Error

Line: 29 Column: 1

              
debug = False

def print_debug(msg):
    if debug: print(msg)


def _open(fullpath):
    try:

            

Reported by Pylint.

More than one statement on a single line
Error

Line: 30 Column: 15

              debug = False

def print_debug(msg):
    if debug: print(msg)


def _open(fullpath):
    try:
        size = os.stat(fullpath).st_size

            

Reported by Pylint.

Lib/pipes.py
14 issues
Starting a process with a shell, possible injection detected, security issue.
Security injection

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

                      if self.steps[-1][1] == SINK:
            raise ValueError('Template.open_r: pipeline ends width SINK')
        cmd = self.makepipeline(file, '')
        return os.popen(cmd, 'r')

    def open_w(self, file):
        if not self.steps:
            return open(file, 'w')
        if self.steps[0][1] == SOURCE:

            

Reported by Bandit.

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

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

                      if self.steps[0][1] == SOURCE:
            raise ValueError('Template.open_w: pipeline begins with SOURCE')
        cmd = self.makepipeline('', file)
        return os.popen(cmd, 'w')

    def copy(self, infile, outfile):
        return os.system(self.makepipeline(infile, outfile))

    def makepipeline(self, infile, outfile):

            

Reported by Bandit.

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

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

                      return os.popen(cmd, 'w')

    def copy(self, infile, outfile):
        return os.system(self.makepipeline(infile, outfile))

    def makepipeline(self, infile, outfile):
        cmd = makepipeline(infile, self.steps, outfile)
        if self.debugging:
            print(cmd)

            

Reported by Bandit.

Attribute 'steps' defined outside __init__
Error

Line: 102 Column: 9

                      """t.clone() returns a new pipeline template with identical
        initial state as the current one."""
        t = Template()
        t.steps = self.steps[:]
        t.debugging = self.debugging
        return t

    def debug(self, flag):
        """t.debug(flag) turns debugging on or off."""

            

Reported by Pylint.

Redefining built-in 'list'
Error

Line: 185 Column: 5

                  # Build a list with for each command:
    # [input filename or '', command string, kind, output filename or '']

    list = []
    for cmd, kind in steps:
        list.append(['', cmd, kind, ''])
    #
    # Make sure there is at least one step
    #

            

Reported by Pylint.

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

Line: 101 Column: 9

                  def clone(self):
        """t.clone() returns a new pipeline template with identical
        initial state as the current one."""
        t = Template()
        t.steps = self.steps[:]
        t.debugging = self.debugging
        return t

    def debug(self, flag):

            

Reported by Pylint.

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

Line: 142 Column: 5

                          raise ValueError('Template.prepend: missing $OUT in cmd')
        self.steps.insert(0, (cmd, kind))

    def open(self, file, rw):
        """t.open(file, rw) returns a pipe or file object open for
        reading or writing; the file is the other end of the pipeline."""
        if rw == 'r':
            return self.open_r(file)
        if rw == 'w':

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 162 Column: 5

                      cmd = self.makepipeline(file, '')
        return os.popen(cmd, 'r')

    def open_w(self, file):
        if not self.steps:
            return open(file, 'w')
        if self.steps[0][1] == SOURCE:
            raise ValueError('Template.open_w: pipeline begins with SOURCE')
        cmd = self.makepipeline('', file)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 170 Column: 5

                      cmd = self.makepipeline('', file)
        return os.popen(cmd, 'w')

    def copy(self, infile, outfile):
        return os.system(self.makepipeline(infile, outfile))

    def makepipeline(self, infile, outfile):
        cmd = makepipeline(infile, self.steps, outfile)
        if self.debugging:

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 173 Column: 5

                  def copy(self, infile, outfile):
        return os.system(self.makepipeline(infile, outfile))

    def makepipeline(self, infile, outfile):
        cmd = makepipeline(infile, self.steps, outfile)
        if self.debugging:
            print(cmd)
            cmd = 'set -x; ' + cmd
        return cmd

            

Reported by Pylint.

Lib/test/fork_wait.py
14 issues
Module 'os' has no 'fork1' member; maybe 'fork'?
Error

Line: 69 Column: 20

                      prefork_lives = self.alive.copy()

        if sys.platform in ['unixware7']:
            cpid = os.fork1()
        else:
            cpid = os.fork()

        if cpid == 0:
            # Child

            

Reported by Pylint.

Redefining built-in 'id'
Error

Line: 39 Column: 17

                      self.threads.clear()
        threading_helper.threading_cleanup(*self._threading_key)

    def f(self, id):
        while not self.stop:
            self.alive[id] = os.getpid()
            try:
                time.sleep(SHORTSLEEP)
            except OSError:

            

Reported by Pylint.

Access to a protected member _exit of a client class
Error

Line: 80 Column: 13

                          for key in self.alive:
                if self.alive[key] != prefork_lives[key]:
                    n += 1
            os._exit(n)
        else:
            # Parent
            self.wait_impl(cpid, exitcode=0)

            

Reported by Pylint.

Multiple imports on one line (os, sys, time, unittest)
Error

Line: 12 Column: 1

              active threads survive in the child after a fork(); this is an error.
"""

import os, sys, time, unittest
import threading
from test import support
from test.support import threading_helper



            

Reported by Pylint.

Missing class docstring
Error

Line: 22 Column: 1

              SHORTSLEEP = 0.5
NUM_THREADS = 4

class ForkWait(unittest.TestCase):

    def setUp(self):
        self._threading_key = threading_helper.threading_setup()
        self.alive = {}
        self.stop = 0

            

Reported by Pylint.

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

Line: 39 Column: 5

                      self.threads.clear()
        threading_helper.threading_cleanup(*self._threading_key)

    def f(self, id):
        while not self.stop:
            self.alive[id] = os.getpid()
            try:
                time.sleep(SHORTSLEEP)
            except OSError:

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 39 Column: 5

                      self.threads.clear()
        threading_helper.threading_cleanup(*self._threading_key)

    def f(self, id):
        while not self.stop:
            self.alive[id] = os.getpid()
            try:
                time.sleep(SHORTSLEEP)
            except OSError:

            

Reported by Pylint.

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

Line: 39 Column: 5

                      self.threads.clear()
        threading_helper.threading_cleanup(*self._threading_key)

    def f(self, id):
        while not self.stop:
            self.alive[id] = os.getpid()
            try:
                time.sleep(SHORTSLEEP)
            except OSError:

            

Reported by Pylint.

Method could be a function
Error

Line: 47 Column: 5

                          except OSError:
                pass

    def wait_impl(self, cpid, *, exitcode):
        support.wait_process(cpid, exitcode=exitcode)

    def test_wait(self):
        for i in range(NUM_THREADS):
            thread = threading.Thread(target=self.f, args=(i,))

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 47 Column: 5

                          except OSError:
                pass

    def wait_impl(self, cpid, *, exitcode):
        support.wait_process(cpid, exitcode=exitcode)

    def test_wait(self):
        for i in range(NUM_THREADS):
            thread = threading.Thread(target=self.f, args=(i,))

            

Reported by Pylint.

Lib/test/test_email/test_pickleable.py
14 issues
Pickle and modules that wrap it can be unsafe when used to deserialize untrusted data, possible security issue.
Security blacklist

Line: 35
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b301-pickle

                      header = self.header_factory(name, value)
        for proto in range(pickle.HIGHEST_PROTOCOL + 1):
            p = pickle.dumps(header, proto)
            h = pickle.loads(p)
            self.assertEqual(str(h), str(header))


@parameterize
class TestPickleCopyMessage(TestEmailBase):

            

Reported by Bandit.

Pickle and modules that wrap it can be unsafe when used to deserialize untrusted data, possible security issue.
Security blacklist

Line: 71
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b301-pickle

                  def msg_as_pickle(self, msg):
        for proto in range(pickle.HIGHEST_PROTOCOL + 1):
            p = pickle.dumps(msg, proto)
            msg2 = pickle.loads(p)
            self.assertEqual(msg2.as_string(), msg.as_string())


if __name__ == '__main__':
    unittest.main()

            

Reported by Bandit.

Missing module docstring
Error

Line: 1 Column: 1

              import unittest
import textwrap
import copy
import pickle
import email
import email.message
from email import policy
from email.headerregistry import HeaderRegistry
from test.test_email import TestEmailBase, parameterize

            

Reported by Pylint.

Consider possible security implications associated with pickle module.
Security blacklist

Line: 4
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_imports.html#b403-import-pickle

              import unittest
import textwrap
import copy
import pickle
import email
import email.message
from email import policy
from email.headerregistry import HeaderRegistry
from test.test_email import TestEmailBase, parameterize

            

Reported by Bandit.

Missing class docstring
Error

Line: 13 Column: 1

              

@parameterize
class TestPickleCopyHeader(TestEmailBase):

    header_factory = HeaderRegistry()

    unstructured = header_factory('subject', 'this is a test')


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 26 Column: 5

                      'date':    ('date',    'Tue, 29 May 2012 09:24:26 +1000'),
        }

    def header_as_deepcopy(self, name, value):
        header = self.header_factory(name, value)
        h = copy.deepcopy(header)
        self.assertEqual(str(h), str(header))

    def header_as_pickle(self, name, value):

            

Reported by Pylint.

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

Line: 28 Column: 9

              
    def header_as_deepcopy(self, name, value):
        header = self.header_factory(name, value)
        h = copy.deepcopy(header)
        self.assertEqual(str(h), str(header))

    def header_as_pickle(self, name, value):
        header = self.header_factory(name, value)
        for proto in range(pickle.HIGHEST_PROTOCOL + 1):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 31 Column: 5

                      h = copy.deepcopy(header)
        self.assertEqual(str(h), str(header))

    def header_as_pickle(self, name, value):
        header = self.header_factory(name, value)
        for proto in range(pickle.HIGHEST_PROTOCOL + 1):
            p = pickle.dumps(header, proto)
            h = pickle.loads(p)
            self.assertEqual(str(h), str(header))

            

Reported by Pylint.

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

Line: 34 Column: 13

                  def header_as_pickle(self, name, value):
        header = self.header_factory(name, value)
        for proto in range(pickle.HIGHEST_PROTOCOL + 1):
            p = pickle.dumps(header, proto)
            h = pickle.loads(p)
            self.assertEqual(str(h), str(header))


@parameterize

            

Reported by Pylint.

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

Line: 35 Column: 13

                      header = self.header_factory(name, value)
        for proto in range(pickle.HIGHEST_PROTOCOL + 1):
            p = pickle.dumps(header, proto)
            h = pickle.loads(p)
            self.assertEqual(str(h), str(header))


@parameterize
class TestPickleCopyMessage(TestEmailBase):

            

Reported by Pylint.

Lib/test/ann_module3.py
14 issues
Undefined variable '__annotations__'
Error

Line: 7 Column: 5

              """

def f_bad_ann():
    __annotations__[1] = 2

class C_OK:
    def __init__(self, x: int) -> None:
        self.x: no_such_name = x  # This one is OK as proposed by Guido


            

Reported by Pylint.

Undefined variable 'no_such_name'
Error

Line: 11 Column: 17

              
class C_OK:
    def __init__(self, x: int) -> None:
        self.x: no_such_name = x  # This one is OK as proposed by Guido

class D_bad_ann:
    def __init__(self, x: int) -> None:
        sfel.y: int = 0


            

Reported by Pylint.

Undefined variable 'sfel'
Error

Line: 15 Column: 9

              
class D_bad_ann:
    def __init__(self, x: int) -> None:
        sfel.y: int = 0

def g_bad_ann():
    no_such_name.attr: int = 0

            

Reported by Pylint.

Undefined variable 'no_such_name'
Error

Line: 18 Column: 5

                      sfel.y: int = 0

def g_bad_ann():
    no_such_name.attr: int = 0

            

Reported by Pylint.

Unused argument 'x'
Error

Line: 14 Column: 24

                      self.x: no_such_name = x  # This one is OK as proposed by Guido

class D_bad_ann:
    def __init__(self, x: int) -> None:
        sfel.y: int = 0

def g_bad_ann():
    no_such_name.attr: int = 0

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 6 Column: 1

              in a certain manner. More examples are in test_grammar and test_parser.
"""

def f_bad_ann():
    __annotations__[1] = 2

class C_OK:
    def __init__(self, x: int) -> None:
        self.x: no_such_name = x  # This one is OK as proposed by Guido

            

Reported by Pylint.

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

Line: 9 Column: 1

              def f_bad_ann():
    __annotations__[1] = 2

class C_OK:
    def __init__(self, x: int) -> None:
        self.x: no_such_name = x  # This one is OK as proposed by Guido

class D_bad_ann:
    def __init__(self, x: int) -> None:

            

Reported by Pylint.

Missing class docstring
Error

Line: 9 Column: 1

              def f_bad_ann():
    __annotations__[1] = 2

class C_OK:
    def __init__(self, x: int) -> None:
        self.x: no_such_name = x  # This one is OK as proposed by Guido

class D_bad_ann:
    def __init__(self, x: int) -> None:

            

Reported by Pylint.

Too few public methods (0/2)
Error

Line: 9 Column: 1

              def f_bad_ann():
    __annotations__[1] = 2

class C_OK:
    def __init__(self, x: int) -> None:
        self.x: no_such_name = x  # This one is OK as proposed by Guido

class D_bad_ann:
    def __init__(self, x: int) -> None:

            

Reported by Pylint.

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

Line: 11 Column: 9

              
class C_OK:
    def __init__(self, x: int) -> None:
        self.x: no_such_name = x  # This one is OK as proposed by Guido

class D_bad_ann:
    def __init__(self, x: int) -> None:
        sfel.y: int = 0


            

Reported by Pylint.

Lib/test/test__opcode.py
14 issues
Access to a protected member _specialization_stats of a client class
Error

Line: 70 Column: 22

              
class SpecializationStatsTests(unittest.TestCase):
    def test_specialization_stats(self):
        stat_names = opcode._specialization_stats

        specialized_opcodes = [
            op[:-len("_ADAPTIVE")].lower() for
            op in opcode._specialized_instructions
            if op.endswith("_ADAPTIVE")]

            

Reported by Pylint.

Access to a protected member _specialized_instructions of a client class
Error

Line: 74 Column: 19

              
        specialized_opcodes = [
            op[:-len("_ADAPTIVE")].lower() for
            op in opcode._specialized_instructions
            if op.endswith("_ADAPTIVE")]
        self.assertIn('load_attr', specialized_opcodes)
        self.assertIn('binary_subscr', specialized_opcodes)

        stats = _opcode.get_specialization_stats()

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import dis
from test.support.import_helper import import_module
import unittest
import opcode

_opcode = import_module("_opcode")
from _opcode import stack_effect



            

Reported by Pylint.

Import "from _opcode import stack_effect" should be placed at the top of the module
Error

Line: 7 Column: 1

              import opcode

_opcode = import_module("_opcode")
from _opcode import stack_effect


class OpcodeTests(unittest.TestCase):

    def test_stack_effect(self):

            

Reported by Pylint.

Missing class docstring
Error

Line: 10 Column: 1

              from _opcode import stack_effect


class OpcodeTests(unittest.TestCase):

    def test_stack_effect(self):
        self.assertEqual(stack_effect(dis.opmap['POP_TOP']), -1)
        self.assertEqual(stack_effect(dis.opmap['DUP_TOP_TWO']), 2)
        self.assertEqual(stack_effect(dis.opmap['BUILD_SLICE'], 0), -1)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 12 Column: 5

              
class OpcodeTests(unittest.TestCase):

    def test_stack_effect(self):
        self.assertEqual(stack_effect(dis.opmap['POP_TOP']), -1)
        self.assertEqual(stack_effect(dis.opmap['DUP_TOP_TWO']), 2)
        self.assertEqual(stack_effect(dis.opmap['BUILD_SLICE'], 0), -1)
        self.assertEqual(stack_effect(dis.opmap['BUILD_SLICE'], 1), -1)
        self.assertEqual(stack_effect(dis.opmap['BUILD_SLICE'], 3), -2)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 36 Column: 5

                              self.assertRaises(ValueError, stack_effect, code)
                self.assertRaises(ValueError, stack_effect, code, 0)

    def test_stack_effect_jump(self):
        JUMP_IF_TRUE_OR_POP = dis.opmap['JUMP_IF_TRUE_OR_POP']
        self.assertEqual(stack_effect(JUMP_IF_TRUE_OR_POP, 0), 0)
        self.assertEqual(stack_effect(JUMP_IF_TRUE_OR_POP, 0, jump=True), 0)
        self.assertEqual(stack_effect(JUMP_IF_TRUE_OR_POP, 0, jump=False), -1)
        FOR_ITER = dis.opmap['FOR_ITER']

            

Reported by Pylint.

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

Line: 37 Column: 9

                              self.assertRaises(ValueError, stack_effect, code, 0)

    def test_stack_effect_jump(self):
        JUMP_IF_TRUE_OR_POP = dis.opmap['JUMP_IF_TRUE_OR_POP']
        self.assertEqual(stack_effect(JUMP_IF_TRUE_OR_POP, 0), 0)
        self.assertEqual(stack_effect(JUMP_IF_TRUE_OR_POP, 0, jump=True), 0)
        self.assertEqual(stack_effect(JUMP_IF_TRUE_OR_POP, 0, jump=False), -1)
        FOR_ITER = dis.opmap['FOR_ITER']
        self.assertEqual(stack_effect(FOR_ITER, 0), 1)

            

Reported by Pylint.

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

Line: 41 Column: 9

                      self.assertEqual(stack_effect(JUMP_IF_TRUE_OR_POP, 0), 0)
        self.assertEqual(stack_effect(JUMP_IF_TRUE_OR_POP, 0, jump=True), 0)
        self.assertEqual(stack_effect(JUMP_IF_TRUE_OR_POP, 0, jump=False), -1)
        FOR_ITER = dis.opmap['FOR_ITER']
        self.assertEqual(stack_effect(FOR_ITER, 0), 1)
        self.assertEqual(stack_effect(FOR_ITER, 0, jump=True), -1)
        self.assertEqual(stack_effect(FOR_ITER, 0, jump=False), 1)
        JUMP_FORWARD = dis.opmap['JUMP_FORWARD']
        self.assertEqual(stack_effect(JUMP_FORWARD, 0), 0)

            

Reported by Pylint.

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

Line: 45 Column: 9

                      self.assertEqual(stack_effect(FOR_ITER, 0), 1)
        self.assertEqual(stack_effect(FOR_ITER, 0, jump=True), -1)
        self.assertEqual(stack_effect(FOR_ITER, 0, jump=False), 1)
        JUMP_FORWARD = dis.opmap['JUMP_FORWARD']
        self.assertEqual(stack_effect(JUMP_FORWARD, 0), 0)
        self.assertEqual(stack_effect(JUMP_FORWARD, 0, jump=True), 0)
        self.assertEqual(stack_effect(JUMP_FORWARD, 0, jump=False), 0)
        # All defined opcodes
        has_jump = dis.hasjabs + dis.hasjrel

            

Reported by Pylint.

Lib/test/mod_generics_cache.py
14 issues
Use of exec
Error

Line: 9 Column: 5

              

if sys.version_info[:2] >= (3, 6):
    exec(dedent("""
    default_a: Optional['A'] = None
    default_b: Optional['B'] = None

    T = TypeVar('T')


            

Reported by Pylint.

Use of exec detected.
Security

Line: 9
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b102_exec_used.html

              

if sys.version_info[:2] >= (3, 6):
    exec(dedent("""
    default_a: Optional['A'] = None
    default_b: Optional['B'] = None

    T = TypeVar('T')


            

Reported by Bandit.

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

Line: 33 Column: 5

                      default_a=Optional['A'],
        default_b=Optional['B'],
    )
    default_a = None
    default_b = None

    T = TypeVar('T')



            

Reported by Pylint.

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

Line: 34 Column: 5

                      default_b=Optional['B'],
    )
    default_a = None
    default_b = None

    T = TypeVar('T')


    class A(Generic[T]):

            

Reported by Pylint.

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

Line: 36 Column: 5

                  default_a = None
    default_b = None

    T = TypeVar('T')


    class A(Generic[T]):
        __annotations__ = dict(
            some_b='B'

            

Reported by Pylint.

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

Line: 39 Column: 5

                  T = TypeVar('T')


    class A(Generic[T]):
        __annotations__ = dict(
            some_b='B'
        )



            

Reported by Pylint.

Too few public methods (0/2)
Error

Line: 39 Column: 5

                  T = TypeVar('T')


    class A(Generic[T]):
        __annotations__ = dict(
            some_b='B'
        )



            

Reported by Pylint.

Missing class docstring
Error

Line: 39 Column: 5

                  T = TypeVar('T')


    class A(Generic[T]):
        __annotations__ = dict(
            some_b='B'
        )



            

Reported by Pylint.

Missing class docstring
Error

Line: 45 Column: 5

                      )


    class B(Generic[T]):
        class A(Generic[T]):
            pass

        __annotations__ = dict(
            my_inner_a1='B.A',

            

Reported by Pylint.

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

Line: 45 Column: 5

                      )


    class B(Generic[T]):
        class A(Generic[T]):
            pass

        __annotations__ = dict(
            my_inner_a1='B.A',

            

Reported by Pylint.

Lib/test/gdb_sample.py
14 issues
Unused argument 'args'
Error

Line: 9 Column: 1

              def bar(a, b, c):
    baz(a, b, c)

def baz(*args):
    id(42)

foo(1, 2, 3)

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # Sample script for use by test_gdb.py

def foo(a, b, c):
    bar(a, b, c)

def bar(a, b, c):
    baz(a, b, c)

def baz(*args):

            

Reported by Pylint.

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

Line: 3 Column: 1

              # Sample script for use by test_gdb.py

def foo(a, b, c):
    bar(a, b, c)

def bar(a, b, c):
    baz(a, b, c)

def baz(*args):

            

Reported by Pylint.

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

Line: 3 Column: 1

              # Sample script for use by test_gdb.py

def foo(a, b, c):
    bar(a, b, c)

def bar(a, b, c):
    baz(a, b, c)

def baz(*args):

            

Reported by Pylint.

Black listed name "foo"
Error

Line: 3 Column: 1

              # Sample script for use by test_gdb.py

def foo(a, b, c):
    bar(a, b, c)

def bar(a, b, c):
    baz(a, b, c)

def baz(*args):

            

Reported by Pylint.

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

Line: 3 Column: 1

              # Sample script for use by test_gdb.py

def foo(a, b, c):
    bar(a, b, c)

def bar(a, b, c):
    baz(a, b, c)

def baz(*args):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 3 Column: 1

              # Sample script for use by test_gdb.py

def foo(a, b, c):
    bar(a, b, c)

def bar(a, b, c):
    baz(a, b, c)

def baz(*args):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 6 Column: 1

              def foo(a, b, c):
    bar(a, b, c)

def bar(a, b, c):
    baz(a, b, c)

def baz(*args):
    id(42)


            

Reported by Pylint.

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

Line: 6 Column: 1

              def foo(a, b, c):
    bar(a, b, c)

def bar(a, b, c):
    baz(a, b, c)

def baz(*args):
    id(42)


            

Reported by Pylint.

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

Line: 6 Column: 1

              def foo(a, b, c):
    bar(a, b, c)

def bar(a, b, c):
    baz(a, b, c)

def baz(*args):
    id(42)


            

Reported by Pylint.

Lib/test/test_asyncio/test_context.py
14 issues
Missing module docstring
Error

Line: 1 Column: 1

              import asyncio
import decimal
import unittest


def tearDownModule():
    asyncio.set_event_loop_policy(None)



            

Reported by Pylint.

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

Line: 6 Column: 1

              import unittest


def tearDownModule():
    asyncio.set_event_loop_policy(None)


@unittest.skipUnless(decimal.HAVE_CONTEXTVAR, "decimal is built with a thread-local context")
class DecimalContextTest(unittest.TestCase):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 6 Column: 1

              import unittest


def tearDownModule():
    asyncio.set_event_loop_policy(None)


@unittest.skipUnless(decimal.HAVE_CONTEXTVAR, "decimal is built with a thread-local context")
class DecimalContextTest(unittest.TestCase):

            

Reported by Pylint.

Missing class docstring
Error

Line: 11 Column: 1

              

@unittest.skipUnless(decimal.HAVE_CONTEXTVAR, "decimal is built with a thread-local context")
class DecimalContextTest(unittest.TestCase):

    def test_asyncio_task_decimal_context(self):
        async def fractions(t, precision, x, y):
            with decimal.localcontext() as ctx:
                ctx.prec = precision

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 13 Column: 5

              @unittest.skipUnless(decimal.HAVE_CONTEXTVAR, "decimal is built with a thread-local context")
class DecimalContextTest(unittest.TestCase):

    def test_asyncio_task_decimal_context(self):
        async def fractions(t, precision, x, y):
            with decimal.localcontext() as ctx:
                ctx.prec = precision
                a = decimal.Decimal(x) / decimal.Decimal(y)
                await asyncio.sleep(t)

            

Reported by Pylint.

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

Line: 14 Column: 9

              class DecimalContextTest(unittest.TestCase):

    def test_asyncio_task_decimal_context(self):
        async def fractions(t, precision, x, y):
            with decimal.localcontext() as ctx:
                ctx.prec = precision
                a = decimal.Decimal(x) / decimal.Decimal(y)
                await asyncio.sleep(t)
                b = decimal.Decimal(x) / decimal.Decimal(y ** 2)

            

Reported by Pylint.

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

Line: 14 Column: 9

              class DecimalContextTest(unittest.TestCase):

    def test_asyncio_task_decimal_context(self):
        async def fractions(t, precision, x, y):
            with decimal.localcontext() as ctx:
                ctx.prec = precision
                a = decimal.Decimal(x) / decimal.Decimal(y)
                await asyncio.sleep(t)
                b = decimal.Decimal(x) / decimal.Decimal(y ** 2)

            

Reported by Pylint.

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

Line: 14 Column: 9

              class DecimalContextTest(unittest.TestCase):

    def test_asyncio_task_decimal_context(self):
        async def fractions(t, precision, x, y):
            with decimal.localcontext() as ctx:
                ctx.prec = precision
                a = decimal.Decimal(x) / decimal.Decimal(y)
                await asyncio.sleep(t)
                b = decimal.Decimal(x) / decimal.Decimal(y ** 2)

            

Reported by Pylint.

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

Line: 17 Column: 17

                      async def fractions(t, precision, x, y):
            with decimal.localcontext() as ctx:
                ctx.prec = precision
                a = decimal.Decimal(x) / decimal.Decimal(y)
                await asyncio.sleep(t)
                b = decimal.Decimal(x) / decimal.Decimal(y ** 2)
                return a, b

        async def main():

            

Reported by Pylint.

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

Line: 19 Column: 17

                              ctx.prec = precision
                a = decimal.Decimal(x) / decimal.Decimal(y)
                await asyncio.sleep(t)
                b = decimal.Decimal(x) / decimal.Decimal(y ** 2)
                return a, b

        async def main():
            r1, r2 = await asyncio.gather(
                fractions(0.1, 3, 1, 3), fractions(0.2, 6, 1, 3))

            

Reported by Pylint.