The following issues were found

Lib/email/_encoded_words.py
7 issues
Missing function or method docstring
Error

Line: 67 Column: 1

              _q_byte_subber = functools.partial(re.compile(br'=([a-fA-F0-9]{2})').sub,
        lambda m: bytes.fromhex(m.group(1).decode()))

def decode_q(encoded):
    encoded = encoded.replace(b'_', b' ')
    return _q_byte_subber(encoded), []


# dict mapping bytes to their encoded form

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 89 Column: 1

              # In headers spaces are mapped to '_'.
_q_byte_map[ord(' ')] = '_'

def encode_q(bstring):
    return ''.join(_q_byte_map[x] for x in bstring)

def len_q(bstring):
    return sum(len(_q_byte_map[x]) for x in bstring)


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 92 Column: 1

              def encode_q(bstring):
    return ''.join(_q_byte_map[x] for x in bstring)

def len_q(bstring):
    return sum(len(_q_byte_map[x]) for x in bstring)


#
# Base64

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 100 Column: 1

              # Base64
#

def decode_b(encoded):
    # First try encoding with validate=True, fixing the padding if needed.
    # This will succeed only if encoded includes no invalid characters.
    pad_err = len(encoded) % 4
    missing_padding = b'==='[:4-pad_err] if pad_err else b''
    try:

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 138 Column: 1

                              # way to decode.
                return encoded, [errors.InvalidBase64LengthDefect()]

def encode_b(bstring):
    return base64.b64encode(bstring).decode('ascii')

def len_b(bstring):
    groups_of_3, leftover = divmod(len(bstring), 3)
    # 4 bytes out for each 3 bytes (or nonzero fraction thereof) in.

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 141 Column: 1

              def encode_b(bstring):
    return base64.b64encode(bstring).decode('ascii')

def len_b(bstring):
    groups_of_3, leftover = divmod(len(bstring), 3)
    # 4 bytes out for each 3 bytes (or nonzero fraction thereof) in.
    return groups_of_3 * 4 + (4 if leftover else 0)



            

Reported by Pylint.

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

Line: 152 Column: 1

                  'b': decode_b,
    }

def decode(ew):
    """Decode encoded word and return (string, charset, lang, defects) tuple.

    An RFC 2047/2243 encoded word has the form:

        =?charset*lang?cte?encoded_string?=

            

Reported by Pylint.

Lib/distutils/tests/test_bdist_msi.py
7 issues
Cannot import 'distutils.command.bdist_msi' due to syntax error 'expected an indented block (<unknown>, line 353)'
Error

Line: 16 Column: 1

              
    def test_minimal(self):
        # minimal test XXX need more tests
        from distutils.command.bdist_msi import bdist_msi
        project_dir, dist = self.create_dist()
        with check_warnings(("", DeprecationWarning)):
            cmd = bdist_msi(dist)
        cmd.ensure_finalized()


            

Reported by Pylint.

No name 'bdist_msi' in module 'distutils.command'
Error

Line: 16 Column: 9

              
    def test_minimal(self):
        # minimal test XXX need more tests
        from distutils.command.bdist_msi import bdist_msi
        project_dir, dist = self.create_dist()
        with check_warnings(("", DeprecationWarning)):
            cmd = bdist_msi(dist)
        cmd.ensure_finalized()


            

Reported by Pylint.

Unused variable 'project_dir'
Error

Line: 17 Column: 9

                  def test_minimal(self):
        # minimal test XXX need more tests
        from distutils.command.bdist_msi import bdist_msi
        project_dir, dist = self.create_dist()
        with check_warnings(("", DeprecationWarning)):
            cmd = bdist_msi(dist)
        cmd.ensure_finalized()



            

Reported by Pylint.

Missing class docstring
Error

Line: 10 Column: 1

              

@unittest.skipUnless(sys.platform == 'win32', 'these tests require Windows')
class BDistMSITestCase(support.TempdirManager,
                       support.LoggingSilencer,
                       unittest.TestCase):

    def test_minimal(self):
        # minimal test XXX need more tests

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 14 Column: 5

                                     support.LoggingSilencer,
                       unittest.TestCase):

    def test_minimal(self):
        # minimal test XXX need more tests
        from distutils.command.bdist_msi import bdist_msi
        project_dir, dist = self.create_dist()
        with check_warnings(("", DeprecationWarning)):
            cmd = bdist_msi(dist)

            

Reported by Pylint.

Import outside toplevel (distutils.command.bdist_msi.bdist_msi)
Error

Line: 16 Column: 9

              
    def test_minimal(self):
        # minimal test XXX need more tests
        from distutils.command.bdist_msi import bdist_msi
        project_dir, dist = self.create_dist()
        with check_warnings(("", DeprecationWarning)):
            cmd = bdist_msi(dist)
        cmd.ensure_finalized()


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 23 Column: 1

                      cmd.ensure_finalized()


def test_suite():
    return unittest.makeSuite(BDistMSITestCase)

if __name__ == '__main__':
    run_unittest(test_suite())

            

Reported by Pylint.

Lib/codeop.py
7 issues
Unused variable 'code2'
Error

Line: 96 Column: 13

                          err1 = e

        try:
            code2 = compiler(source + "\n\n", filename, symbol)
        except SyntaxError as e:
            err2 = e

    try:
        if not code1 and _is_syntax_error(err1, err2):

            

Reported by Pylint.

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

Line: 67 Column: 1

              
__all__ = ["compile_command", "Compile", "CommandCompiler"]

PyCF_DONT_IMPLY_DEDENT = 0x200          # Matches pythonrun.h.

def _maybe_compile(compiler, source, filename, symbol):
    # Check for source consisting of only blank lines and comments.
    for line in source.split("\n"):
        line = line.strip()

            

Reported by Pylint.

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

Line: 92 Column: 9

                      code1 = err1 = err2 = None
        try:
            code1 = compiler(source + "\n", filename, symbol)
        except SyntaxError as e:
            err1 = e

        try:
            code2 = compiler(source + "\n\n", filename, symbol)
        except SyntaxError as e:

            

Reported by Pylint.

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

Line: 97 Column: 9

              
        try:
            code2 = compiler(source + "\n\n", filename, symbol)
        except SyntaxError as e:
            err2 = e

    try:
        if not code1 and _is_syntax_error(err1, err2):
            raise err1

            

Reported by Pylint.

Unnecessary "else" after "raise"
Error

Line: 101 Column: 9

                          err2 = e

    try:
        if not code1 and _is_syntax_error(err1, err2):
            raise err1
        else:
            return None
    finally:
        err1 = err2 = None

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 141 Column: 1

                  """
    return _maybe_compile(_compile, source, filename, symbol)

class Compile:
    """Instances of this class behave much like the built-in compile
    function, but if one is used to compile text containing a future
    statement, it "remembers" and compiles all subsequent program texts
    with the statement in force."""
    def __init__(self):

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 156 Column: 1

                              self.flags |= feature.compiler_flag
        return codeob

class CommandCompiler:
    """Instances of this class have __call__ methods identical in
    signature to compile_command; the difference is that if the
    instance compiles program text containing a __future__ statement,
    the instance 'remembers' and compiles all subsequent program texts
    with the statement in force."""

            

Reported by Pylint.

Lib/lib2to3/fixes/fix_standarderror.py
7 issues
Attempted relative import beyond top-level package
Error

Line: 7 Column: 1

              """Fixer for StandardError -> Exception."""

# Local imports
from .. import fixer_base
from ..fixer_util import Name


class FixStandarderror(fixer_base.BaseFix):
    BM_compatible = True

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 8 Column: 1

              
# Local imports
from .. import fixer_base
from ..fixer_util import Name


class FixStandarderror(fixer_base.BaseFix):
    BM_compatible = True
    PATTERN = """

            

Reported by Pylint.

Unused argument 'results'
Error

Line: 17 Column: 31

                            'StandardError'
              """

    def transform(self, node, results):
        return Name("Exception", prefix=node.prefix)

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 11 Column: 1

              from ..fixer_util import Name


class FixStandarderror(fixer_base.BaseFix):
    BM_compatible = True
    PATTERN = """
              'StandardError'
              """


            

Reported by Pylint.

Missing class docstring
Error

Line: 11 Column: 1

              from ..fixer_util import Name


class FixStandarderror(fixer_base.BaseFix):
    BM_compatible = True
    PATTERN = """
              'StandardError'
              """


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 17 Column: 5

                            'StandardError'
              """

    def transform(self, node, results):
        return Name("Exception", prefix=node.prefix)

            

Reported by Pylint.

Method could be a function
Error

Line: 17 Column: 5

                            'StandardError'
              """

    def transform(self, node, results):
        return Name("Exception", prefix=node.prefix)

            

Reported by Pylint.

Lib/lib2to3/fixes/fix_getcwdu.py
7 issues
Attempted relative import beyond top-level package
Error

Line: 7 Column: 1

              # Author: Victor Stinner

# Local imports
from .. import fixer_base
from ..fixer_util import Name

class FixGetcwdu(fixer_base.BaseFix):
    BM_compatible = True


            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 8 Column: 1

              
# Local imports
from .. import fixer_base
from ..fixer_util import Name

class FixGetcwdu(fixer_base.BaseFix):
    BM_compatible = True

    PATTERN = """

            

Reported by Pylint.

Unused argument 'node'
Error

Line: 17 Column: 25

                            power< 'os' trailer< dot='.' name='getcwdu' > any* >
              """

    def transform(self, node, results):
        name = results["name"]
        name.replace(Name("getcwd", prefix=name.prefix))

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 10 Column: 1

              from .. import fixer_base
from ..fixer_util import Name

class FixGetcwdu(fixer_base.BaseFix):
    BM_compatible = True

    PATTERN = """
              power< 'os' trailer< dot='.' name='getcwdu' > any* >
              """

            

Reported by Pylint.

Missing class docstring
Error

Line: 10 Column: 1

              from .. import fixer_base
from ..fixer_util import Name

class FixGetcwdu(fixer_base.BaseFix):
    BM_compatible = True

    PATTERN = """
              power< 'os' trailer< dot='.' name='getcwdu' > any* >
              """

            

Reported by Pylint.

Method could be a function
Error

Line: 17 Column: 5

                            power< 'os' trailer< dot='.' name='getcwdu' > any* >
              """

    def transform(self, node, results):
        name = results["name"]
        name.replace(Name("getcwd", prefix=name.prefix))

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 17 Column: 5

                            power< 'os' trailer< dot='.' name='getcwdu' > any* >
              """

    def transform(self, node, results):
        name = results["name"]
        name.replace(Name("getcwd", prefix=name.prefix))

            

Reported by Pylint.

Lib/lib2to3/fixes/fix_ws_comma.py
7 issues
Attempted relative import beyond top-level package
Error

Line: 8 Column: 1

              
"""

from .. import pytree
from ..pgen2 import token
from .. import fixer_base

class FixWsComma(fixer_base.BaseFix):


            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 9 Column: 1

              """

from .. import pytree
from ..pgen2 import token
from .. import fixer_base

class FixWsComma(fixer_base.BaseFix):

    explicit = True # The user must ask for this fixers

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 10 Column: 1

              
from .. import pytree
from ..pgen2 import token
from .. import fixer_base

class FixWsComma(fixer_base.BaseFix):

    explicit = True # The user must ask for this fixers


            

Reported by Pylint.

Unused argument 'results'
Error

Line: 24 Column: 31

                  COLON = pytree.Leaf(token.COLON, ":")
    SEPS = (COMMA, COLON)

    def transform(self, node, results):
        new = node.clone()
        comma = False
        for child in new.children:
            if child in self.SEPS:
                prefix = child.prefix

            

Reported by Pylint.

Missing class docstring
Error

Line: 12 Column: 1

              from ..pgen2 import token
from .. import fixer_base

class FixWsComma(fixer_base.BaseFix):

    explicit = True # The user must ask for this fixers

    PATTERN = """
    any<(not(',') any)+ ',' ((not(',') any)+ ',')* [not(',') any]>

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 12 Column: 1

              from ..pgen2 import token
from .. import fixer_base

class FixWsComma(fixer_base.BaseFix):

    explicit = True # The user must ask for this fixers

    PATTERN = """
    any<(not(',') any)+ ',' ((not(',') any)+ ',')* [not(',') any]>

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 24 Column: 5

                  COLON = pytree.Leaf(token.COLON, ":")
    SEPS = (COMMA, COLON)

    def transform(self, node, results):
        new = node.clone()
        comma = False
        for child in new.children:
            if child in self.SEPS:
                prefix = child.prefix

            

Reported by Pylint.

Lib/html/__init__.py
7 issues
Else clause on loop without a break statement
Error

Line: 114 Column: 9

                      for x in range(len(s)-1, 1, -1):
            if s[:x] in _html5:
                return _html5[s[:x]] + s[x:]
        else:
            return '&' + s


_charref = _re.compile(r'&(#[0-9]+;?'
                       r'|#[xX][0-9a-fA-F]+;?'

            

Reported by Pylint.

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

Line: 12 Column: 1

              __all__ = ['escape', 'unescape']


def escape(s, quote=True):
    """
    Replace special characters "&", "<" and ">" to HTML-safe sequences.
    If the optional flag quote is true (the default), the quotation mark
    characters, both double quote (") and single quote (') characters are also
    translated.

            

Reported by Pylint.

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

Line: 91 Column: 1

              }


def _replace_charref(s):
    s = s.group(1)
    if s[0] == '#':
        # numeric charref
        if s[1] in 'xX':
            num = int(s[2:].rstrip(';'), 16)

            

Reported by Pylint.

Too many return statements (7/6)
Error

Line: 91 Column: 1

              }


def _replace_charref(s):
    s = s.group(1)
    if s[0] == '#':
        # numeric charref
        if s[1] in 'xX':
            num = int(s[2:].rstrip(';'), 16)

            

Reported by Pylint.

Unnecessary "else" after "return"
Error

Line: 93 Column: 5

              
def _replace_charref(s):
    s = s.group(1)
    if s[0] == '#':
        # numeric charref
        if s[1] in 'xX':
            num = int(s[2:].rstrip(';'), 16)
        else:
            num = int(s[1:].rstrip(';'))

            

Reported by Pylint.

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

Line: 111 Column: 13

                      if s in _html5:
            return _html5[s]
        # find the longest matching name (as defined by the standard)
        for x in range(len(s)-1, 1, -1):
            if s[:x] in _html5:
                return _html5[s[:x]] + s[x:]
        else:
            return '&' + s


            

Reported by Pylint.

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

Line: 122 Column: 1

                                     r'|#[xX][0-9a-fA-F]+;?'
                       r'|[^\t\n\f <&#;]{1,32};?)')

def unescape(s):
    """
    Convert all named and numeric character references (e.g. &gt;, &#62;,
    &x3e;) in the string s to the corresponding unicode characters.
    This function uses the rules defined by the HTML 5 standard
    for both valid and invalid character references, and the list of

            

Reported by Pylint.

Lib/graphlib.py
7 issues
Unnecessary pass statement
Error

Line: 36 Column: 5

                  the same, to make it clear that it is cyclic.
    """

    pass


class TopologicalSorter:
    """Provides functionality to topologically sort a graph of hashable nodes"""


            

Reported by Pylint.

Using an f-string that does not have any interpolated variables
Error

Line: 104 Column: 30

                      # nodes as possible before cycles block more progress
        cycle = self._find_cycle()
        if cycle:
            raise CycleError(f"nodes are in a cycle", cycle)

    def get_ready(self):
        """Return a tuple of all the nodes that are ready.

        Initially it returns all nodes with no predecessors; once those are marked

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              __all__ = ["TopologicalSorter", "CycleError"]

_NODE_OUT = -1
_NODE_DONE = -2


class _NodeInfo:
    __slots__ = "node", "npredecessors", "successors"


            

Reported by Pylint.

Too few public methods (0/2)
Error

Line: 7 Column: 1

              _NODE_DONE = -2


class _NodeInfo:
    __slots__ = "node", "npredecessors", "successors"

    def __init__(self, node):
        # The node this class is augmenting.
        self.node = node

            

Reported by Pylint.

Unnecessary "elif" after "raise"
Error

Line: 175 Column: 17

                          # If the node has not being returned (marked as ready) previously, inform the user.
            stat = nodeinfo.npredecessors
            if stat != _NODE_OUT:
                if stat >= 0:
                    raise ValueError(
                        f"node {node!r} was not passed out (still not ready)"
                    )
                elif stat == _NODE_DONE:
                    raise ValueError(f"node {node!r} was already marked done")

            

Reported by Pylint.

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

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

                              elif stat == _NODE_DONE:
                    raise ValueError(f"node {node!r} was already marked done")
                else:
                    assert False, f"node {node!r}: unknown status {stat}"

            # Mark the node as processed
            nodeinfo.npredecessors = _NODE_DONE

            # Go to all the successors and reduce the number of predecessors, collecting all the ones

            

Reported by Bandit.

Line too long (101/100)
Error

Line: 187 Column: 1

                          # Mark the node as processed
            nodeinfo.npredecessors = _NODE_DONE

            # Go to all the successors and reduce the number of predecessors, collecting all the ones
            # that are ready to be returned in the next get_ready() call.
            for successor in nodeinfo.successors:
                successor_info = n2i[successor]
                successor_info.npredecessors -= 1
                if successor_info.npredecessors == 0:

            

Reported by Pylint.

Lib/distutils/command/install_data.py
7 issues
Redefining built-in 'dir'
Error

Line: 56 Column: 17

                              self.outfiles.append(out)
            else:
                # it's a tuple with path to install to and a list of files
                dir = convert_path(f[0])
                if not os.path.isabs(dir):
                    dir = os.path.join(self.install_dir, dir)
                elif self.root:
                    dir = change_root(self.root, dir)
                self.mkpath(dir)

            

Reported by Pylint.

Missing class docstring
Error

Line: 12 Column: 1

              from distutils.core import Command
from distutils.util import change_root, convert_path

class install_data(Command):

    description = "install data files"

    user_options = [
        ('install-dir=', 'd',

            

Reported by Pylint.

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

Line: 12 Column: 1

              from distutils.core import Command
from distutils.util import change_root, convert_path

class install_data(Command):

    description = "install data files"

    user_options = [
        ('install-dir=', 'd',

            

Reported by Pylint.

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

Line: 44 Column: 13

              
    def run(self):
        self.mkpath(self.install_dir)
        for f in self.data_files:
            if isinstance(f, str):
                # it's a simple file, so copy it
                f = convert_path(f)
                if self.warn_dir:
                    self.warn("setup script did not provide a directory for "

            

Reported by Pylint.

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

Line: 47 Column: 17

                      for f in self.data_files:
            if isinstance(f, str):
                # it's a simple file, so copy it
                f = convert_path(f)
                if self.warn_dir:
                    self.warn("setup script did not provide a directory for "
                              "'%s' -- installing right in '%s'" %
                              (f, self.install_dir))
                (out, _) = self.copy_file(f, self.install_dir)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 75 Column: 5

                                      (out, _) = self.copy_file(data, dir)
                        self.outfiles.append(out)

    def get_inputs(self):
        return self.data_files or []

    def get_outputs(self):
        return self.outfiles

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 78 Column: 5

                  def get_inputs(self):
        return self.data_files or []

    def get_outputs(self):
        return self.outfiles

            

Reported by Pylint.

Lib/lib2to3/fixes/fix_future.py
7 issues
Attempted relative import beyond top-level package
Error

Line: 8 Column: 1

              # Author: Christian Heimes

# Local imports
from .. import fixer_base
from ..fixer_util import BlankLine

class FixFuture(fixer_base.BaseFix):
    BM_compatible = True


            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 9 Column: 1

              
# Local imports
from .. import fixer_base
from ..fixer_util import BlankLine

class FixFuture(fixer_base.BaseFix):
    BM_compatible = True

    PATTERN = """import_from< 'from' module_name="__future__" 'import' any >"""

            

Reported by Pylint.

Unused argument 'results'
Error

Line: 19 Column: 31

                  # This should be run last -- some things check for the import
    run_order = 10

    def transform(self, node, results):
        new = BlankLine()
        new.prefix = node.prefix
        return new

            

Reported by Pylint.

Missing class docstring
Error

Line: 11 Column: 1

              from .. import fixer_base
from ..fixer_util import BlankLine

class FixFuture(fixer_base.BaseFix):
    BM_compatible = True

    PATTERN = """import_from< 'from' module_name="__future__" 'import' any >"""

    # This should be run last -- some things check for the import

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 11 Column: 1

              from .. import fixer_base
from ..fixer_util import BlankLine

class FixFuture(fixer_base.BaseFix):
    BM_compatible = True

    PATTERN = """import_from< 'from' module_name="__future__" 'import' any >"""

    # This should be run last -- some things check for the import

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 19 Column: 5

                  # This should be run last -- some things check for the import
    run_order = 10

    def transform(self, node, results):
        new = BlankLine()
        new.prefix = node.prefix
        return new

            

Reported by Pylint.

Method could be a function
Error

Line: 19 Column: 5

                  # This should be run last -- some things check for the import
    run_order = 10

    def transform(self, node, results):
        new = BlankLine()
        new.prefix = node.prefix
        return new

            

Reported by Pylint.