The following issues were found

Lib/json/scanner.py
6 issues
Missing function or method docstring
Error

Line: 15 Column: 1

                  r'(-?(?:0|[1-9]\d*))(\.\d+)?([eE][-+]?\d+)?',
    (re.VERBOSE | re.MULTILINE | re.DOTALL))

def py_make_scanner(context):
    parse_object = context.parse_object
    parse_array = context.parse_array
    parse_string = context.parse_string
    match_number = NUMBER_RE.match
    strict = context.strict

            

Reported by Pylint.

Too many branches (14/12)
Error

Line: 28 Column: 5

                  object_pairs_hook = context.object_pairs_hook
    memo = context.memo

    def _scan_once(string, idx):
        try:
            nextchar = string[idx]
        except IndexError:
            raise StopIteration(idx) from None


            

Reported by Pylint.

Too many return statements (10/6)
Error

Line: 28 Column: 5

                  object_pairs_hook = context.object_pairs_hook
    memo = context.memo

    def _scan_once(string, idx):
        try:
            nextchar = string[idx]
        except IndexError:
            raise StopIteration(idx) from None


            

Reported by Pylint.

Unnecessary "elif" after "return"
Error

Line: 34 Column: 9

                      except IndexError:
            raise StopIteration(idx) from None

        if nextchar == '"':
            return parse_string(string, idx + 1, strict)
        elif nextchar == '{':
            return parse_object((string, idx + 1), strict,
                _scan_once, object_hook, object_pairs_hook, memo)
        elif nextchar == '[':

            

Reported by Pylint.

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

Line: 48 Column: 9

                      elif nextchar == 'f' and string[idx:idx + 5] == 'false':
            return False, idx + 5

        m = match_number(string, idx)
        if m is not None:
            integer, frac, exp = m.groups()
            if frac or exp:
                res = parse_float(integer + (frac or '') + (exp or ''))
            else:

            

Reported by Pylint.

Unnecessary "elif" after "return"
Error

Line: 49 Column: 9

                          return False, idx + 5

        m = match_number(string, idx)
        if m is not None:
            integer, frac, exp = m.groups()
            if frac or exp:
                res = parse_float(integer + (frac or '') + (exp or ''))
            else:
                res = parse_int(integer)

            

Reported by Pylint.

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

Line: 9 Column: 1

              intern(s) -> sys.intern(s)"""

# Local imports
from .. import fixer_base
from ..fixer_util import ImportAndCall, touch_import


class FixIntern(fixer_base.BaseFix):
    BM_compatible = True

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 10 Column: 1

              
# Local imports
from .. import fixer_base
from ..fixer_util import ImportAndCall, touch_import


class FixIntern(fixer_base.BaseFix):
    BM_compatible = True
    order = "pre"

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 13 Column: 1

              from ..fixer_util import ImportAndCall, touch_import


class FixIntern(fixer_base.BaseFix):
    BM_compatible = True
    order = "pre"

    PATTERN = """
    power< 'intern'

            

Reported by Pylint.

Missing class docstring
Error

Line: 13 Column: 1

              from ..fixer_util import ImportAndCall, touch_import


class FixIntern(fixer_base.BaseFix):
    BM_compatible = True
    order = "pre"

    PATTERN = """
    power< 'intern'

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 27 Column: 5

                  >
    """

    def transform(self, node, results):
        if results:
            # I feel like we should be able to express this logic in the
            # PATTERN above but I don't know how to do it so...
            obj = results['obj']
            if obj:

            

Reported by Pylint.

Either all return statements in a function should return an expression, or none of them should.
Error

Line: 27 Column: 5

                  >
    """

    def transform(self, node, results):
        if results:
            # I feel like we should be able to express this logic in the
            # PATTERN above but I don't know how to do it so...
            obj = results['obj']
            if obj:

            

Reported by Pylint.

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

Line: 12 Column: 1

                     -> isinstance(x, int)
"""

from .. import fixer_base
from ..fixer_util import token


class FixIsinstance(fixer_base.BaseFix):
    BM_compatible = True

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 13 Column: 1

              """

from .. import fixer_base
from ..fixer_util import token


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

            

Reported by Pylint.

Missing class docstring
Error

Line: 16 Column: 1

              from ..fixer_util import token


class FixIsinstance(fixer_base.BaseFix):
    BM_compatible = True
    PATTERN = """
    power<
        'isinstance'
        trailer< '(' arglist< any ',' atom< '('

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 16 Column: 1

              from ..fixer_util import token


class FixIsinstance(fixer_base.BaseFix):
    BM_compatible = True
    PATTERN = """
    power<
        'isinstance'
        trailer< '(' arglist< any ',' atom< '('

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 29 Column: 5

              
    run_order = 6

    def transform(self, node, results):
        names_inserted = set()
        testlist = results["args"]
        args = testlist.children
        new_args = []
        iterator = enumerate(args)

            

Reported by Pylint.

Method could be a function
Error

Line: 29 Column: 5

              
    run_order = 6

    def transform(self, node, results):
        names_inserted = set()
        testlist = results["args"]
        args = testlist.children
        new_args = []
        iterator = enumerate(args)

            

Reported by Pylint.

Doc/includes/sqlite3/adapter_point_1.py
6 issues
Missing module docstring
Error

Line: 1 Column: 1

              import sqlite3

class Point:
    def __init__(self, x, y):
        self.x, self.y = x, y

    def __conform__(self, protocol):
        if protocol is sqlite3.PrepareProtocol:
            return "%f;%f" % (self.x, self.y)

            

Reported by Pylint.

Missing class docstring
Error

Line: 3 Column: 1

              import sqlite3

class Point:
    def __init__(self, x, y):
        self.x, self.y = x, y

    def __conform__(self, protocol):
        if protocol is sqlite3.PrepareProtocol:
            return "%f;%f" % (self.x, self.y)

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 3 Column: 1

              import sqlite3

class Point:
    def __init__(self, x, y):
        self.x, self.y = x, y

    def __conform__(self, protocol):
        if protocol is sqlite3.PrepareProtocol:
            return "%f;%f" % (self.x, self.y)

            

Reported by Pylint.

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

Line: 5 Column: 17

              
class Point:
    def __init__(self, x, y):
        self.x, self.y = x, y

    def __conform__(self, protocol):
        if protocol is sqlite3.PrepareProtocol:
            return "%f;%f" % (self.x, self.y)


            

Reported by Pylint.

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

Line: 5 Column: 9

              
class Point:
    def __init__(self, x, y):
        self.x, self.y = x, y

    def __conform__(self, protocol):
        if protocol is sqlite3.PrepareProtocol:
            return "%f;%f" % (self.x, self.y)


            

Reported by Pylint.

Either all return statements in a function should return an expression, or none of them should.
Error

Line: 7 Column: 5

                  def __init__(self, x, y):
        self.x, self.y = x, y

    def __conform__(self, protocol):
        if protocol is sqlite3.PrepareProtocol:
            return "%f;%f" % (self.x, self.y)

con = sqlite3.connect(":memory:")
cur = con.cursor()

            

Reported by Pylint.

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

Line: 6 Column: 1

              reload(s) -> importlib.reload(s)"""

# Local imports
from .. import fixer_base
from ..fixer_util import ImportAndCall, touch_import


class FixReload(fixer_base.BaseFix):
    BM_compatible = True

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 7 Column: 1

              
# Local imports
from .. import fixer_base
from ..fixer_util import ImportAndCall, touch_import


class FixReload(fixer_base.BaseFix):
    BM_compatible = True
    order = "pre"

            

Reported by Pylint.

Missing class docstring
Error

Line: 10 Column: 1

              from ..fixer_util import ImportAndCall, touch_import


class FixReload(fixer_base.BaseFix):
    BM_compatible = True
    order = "pre"

    PATTERN = """
    power< 'reload'

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 10 Column: 1

              from ..fixer_util import ImportAndCall, touch_import


class FixReload(fixer_base.BaseFix):
    BM_compatible = True
    order = "pre"

    PATTERN = """
    power< 'reload'

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 24 Column: 5

                  >
    """

    def transform(self, node, results):
        if results:
            # I feel like we should be able to express this logic in the
            # PATTERN above but I don't know how to do it so...
            obj = results['obj']
            if obj:

            

Reported by Pylint.

Either all return statements in a function should return an expression, or none of them should.
Error

Line: 24 Column: 5

                  >
    """

    def transform(self, node, results):
        if results:
            # I feel like we should be able to express this logic in the
            # PATTERN above but I don't know how to do it so...
            obj = results['obj']
            if obj:

            

Reported by Pylint.

Doc/includes/email-simple.py
6 issues
Undefined variable 'textfile'
Error

Line: 8 Column: 11

              from email.message import EmailMessage

# Open the plain text file whose name is in textfile for reading.
with open(textfile) as fp:
    # Create a text/plain message
    msg = EmailMessage()
    msg.set_content(fp.read())

# me == the sender's email address

            

Reported by Pylint.

Undefined variable 'textfile'
Error

Line: 15 Column: 37

              
# me == the sender's email address
# you == the recipient's email address
msg['Subject'] = f'The contents of {textfile}'
msg['From'] = me
msg['To'] = you

# Send the message via our own SMTP server.
s = smtplib.SMTP('localhost')

            

Reported by Pylint.

Undefined variable 'me'
Error

Line: 16 Column: 15

              # me == the sender's email address
# you == the recipient's email address
msg['Subject'] = f'The contents of {textfile}'
msg['From'] = me
msg['To'] = you

# Send the message via our own SMTP server.
s = smtplib.SMTP('localhost')
s.send_message(msg)

            

Reported by Pylint.

Undefined variable 'you'
Error

Line: 17 Column: 13

              # you == the recipient's email address
msg['Subject'] = f'The contents of {textfile}'
msg['From'] = me
msg['To'] = you

# Send the message via our own SMTP server.
s = smtplib.SMTP('localhost')
s.send_message(msg)
s.quit()

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # Import smtplib for the actual sending function
import smtplib

# Import the email modules we'll need
from email.message import EmailMessage

# Open the plain text file whose name is in textfile for reading.
with open(textfile) as fp:
    # Create a text/plain message

            

Reported by Pylint.

Module name "email-simple" doesn't conform to snake_case naming style
Error

Line: 1 Column: 1

              # Import smtplib for the actual sending function
import smtplib

# Import the email modules we'll need
from email.message import EmailMessage

# Open the plain text file whose name is in textfile for reading.
with open(textfile) as fp:
    # Create a text/plain message

            

Reported by Pylint.

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

Line: 7 Column: 1

              # Author: Collin Winter

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


class FixXreadlines(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 FixXreadlines(fixer_base.BaseFix):
    BM_compatible = True
    PATTERN = """

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 11 Column: 1

              from ..fixer_util import Name


class FixXreadlines(fixer_base.BaseFix):
    BM_compatible = True
    PATTERN = """
    power< call=any+ trailer< '.' 'xreadlines' > trailer< '(' ')' > >
    |
    power< any+ trailer< '.' no_call='xreadlines' > >

            

Reported by Pylint.

Missing class docstring
Error

Line: 11 Column: 1

              from ..fixer_util import Name


class FixXreadlines(fixer_base.BaseFix):
    BM_compatible = True
    PATTERN = """
    power< call=any+ trailer< '.' 'xreadlines' > trailer< '(' ')' > >
    |
    power< any+ trailer< '.' no_call='xreadlines' > >

            

Reported by Pylint.

Method could be a function
Error

Line: 19 Column: 5

                  power< any+ trailer< '.' no_call='xreadlines' > >
    """

    def transform(self, node, results):
        no_call = results.get("no_call")

        if no_call:
            no_call.replace(Name("__iter__", prefix=no_call.prefix))
        else:

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 19 Column: 5

                  power< any+ trailer< '.' no_call='xreadlines' > >
    """

    def transform(self, node, results):
        no_call = results.get("no_call")

        if no_call:
            no_call.replace(Name("__iter__", prefix=no_call.prefix))
        else:

            

Reported by Pylint.

Lib/importlib/_common.py
5 issues
Attempted relative import beyond top-level package
Error

Line: 10 Column: 1

              import importlib

from typing import Union, Any, Optional
from .abc import ResourceReader, Traversable

from ._adapters import wrap_spec

Package = Union[types.ModuleType, str]
Resource = Union[str, os.PathLike]

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 12 Column: 1

              from typing import Union, Any, Optional
from .abc import ResourceReader, Traversable

from ._adapters import wrap_spec

Package = Union[types.ModuleType, str]
Resource = Union[str, os.PathLike]



            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import os
import pathlib
import tempfile
import functools
import contextlib
import types
import importlib

from typing import Union, Any, Optional

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 56 Column: 1

                  return reader(spec.name)  # type: ignore


def resolve(cand):
    # type: (Package) -> types.ModuleType
    return cand if isinstance(cand, types.ModuleType) else importlib.import_module(cand)


def get_package(package):

            

Reported by Pylint.

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

Line: 88 Column: 5

                  # Not using tempfile.NamedTemporaryFile as it leads to deeper 'try'
    # blocks due to the need to close the temporary file to work on Windows
    # properly.
    fd, raw_path = tempfile.mkstemp(suffix=suffix)
    try:
        try:
            os.write(fd, reader())
        finally:
            os.close(fd)

            

Reported by Pylint.

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

Line: 11 Column: 1

              # By Jeff Balogh and Benjamin Peterson

# Local imports
from .. import fixer_base
from ..fixer_util import Attr, Call, Name, Number, Subscript, Node, syms

class FixSysExc(fixer_base.BaseFix):
    # This order matches the ordering of sys.exc_info().
    exc_info = ["exc_type", "exc_value", "exc_traceback"]

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 12 Column: 1

              
# Local imports
from .. import fixer_base
from ..fixer_util import Attr, Call, Name, Number, Subscript, Node, syms

class FixSysExc(fixer_base.BaseFix):
    # This order matches the ordering of sys.exc_info().
    exc_info = ["exc_type", "exc_value", "exc_traceback"]
    BM_compatible = True

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 14 Column: 1

              from .. import fixer_base
from ..fixer_util import Attr, Call, Name, Number, Subscript, Node, syms

class FixSysExc(fixer_base.BaseFix):
    # This order matches the ordering of sys.exc_info().
    exc_info = ["exc_type", "exc_value", "exc_traceback"]
    BM_compatible = True
    PATTERN = """
              power< 'sys' trailer< dot='.' attribute=(%s) > >

            

Reported by Pylint.

Missing class docstring
Error

Line: 14 Column: 1

              from .. import fixer_base
from ..fixer_util import Attr, Call, Name, Number, Subscript, Node, syms

class FixSysExc(fixer_base.BaseFix):
    # This order matches the ordering of sys.exc_info().
    exc_info = ["exc_type", "exc_value", "exc_traceback"]
    BM_compatible = True
    PATTERN = """
              power< 'sys' trailer< dot='.' attribute=(%s) > >

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 22 Column: 5

                            power< 'sys' trailer< dot='.' attribute=(%s) > >
              """ % '|'.join("'%s'" % e for e in exc_info)

    def transform(self, node, results):
        sys_attr = results["attribute"][0]
        index = Number(self.exc_info.index(sys_attr.value))

        call = Call(Name("exc_info"), prefix=sys_attr.prefix)
        attr = Attr(Name("sys"), call)

            

Reported by Pylint.

Lib/importlib/metadata/_text.py
5 issues
Attempted relative import beyond top-level package
Error

Line: 3 Column: 1

              import re

from ._functools import method_cache


# from jaraco.text 3.5
class FoldedCase(str):
    """
    A case insensitive string class; behaves just like str

            

Reported by Pylint.

Parameters differ from overridden 'index' method
Error

Line: 94 Column: 5

                  def lower(self):
        return super(FoldedCase, self).lower()

    def index(self, sub):
        return self.lower().index(sub.lower())

    def split(self, splitter=' ', maxsplit=0):
        pattern = re.compile(re.escape(splitter), re.I)
        return pattern.split(self, maxsplit)

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import re

from ._functools import method_cache


# from jaraco.text 3.5
class FoldedCase(str):
    """
    A case insensitive string class; behaves just like str

            

Reported by Pylint.

Consider using Python 3 style super() without arguments
Error

Line: 83 Column: 16

                      return hash(self.lower())

    def __contains__(self, other):
        return super(FoldedCase, self).lower().__contains__(other.lower())

    def in_(self, other):
        "Does self appear in other?"
        return self in FoldedCase(other)


            

Reported by Pylint.

Consider using Python 3 style super() without arguments
Error

Line: 92 Column: 16

                  # cache lower since it's likely to be called frequently.
    @method_cache
    def lower(self):
        return super(FoldedCase, self).lower()

    def index(self, sub):
        return self.lower().index(sub.lower())

    def split(self, splitter=' ', maxsplit=0):

            

Reported by Pylint.