The following issues were found

Lib/test/test_tools/test_pdeps.py
5 issues
Missing class docstring
Error

Line: 12 Column: 1

              skip_if_missing()


class PdepsTests(unittest.TestCase):

    @classmethod
    def setUpClass(self):
        self.pdeps = import_tool('pdeps')


            

Reported by Pylint.

Class method setUpClass should have 'cls' as first argument
Error

Line: 15 Column: 5

              class PdepsTests(unittest.TestCase):

    @classmethod
    def setUpClass(self):
        self.pdeps = import_tool('pdeps')

    def test_process_errors(self):
        # Issue #14492: m_import.match(line) can be None.
        with tempfile.TemporaryDirectory() as tmpdir:

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 18 Column: 5

                  def setUpClass(self):
        self.pdeps = import_tool('pdeps')

    def test_process_errors(self):
        # Issue #14492: m_import.match(line) can be None.
        with tempfile.TemporaryDirectory() as tmpdir:
            fn = os.path.join(tmpdir, 'foo')
            with open(fn, 'w') as stream:
                stream.write("#!/this/will/fail")

            

Reported by Pylint.

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

Line: 21 Column: 13

                  def test_process_errors(self):
        # Issue #14492: m_import.match(line) can be None.
        with tempfile.TemporaryDirectory() as tmpdir:
            fn = os.path.join(tmpdir, 'foo')
            with open(fn, 'w') as stream:
                stream.write("#!/this/will/fail")
            self.pdeps.process(fn, {})

    def test_inverse_attribute_error(self):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 26 Column: 5

                              stream.write("#!/this/will/fail")
            self.pdeps.process(fn, {})

    def test_inverse_attribute_error(self):
        # Issue #14492: this used to fail with an AttributeError.
        self.pdeps.inverse({'a': []})


if __name__ == '__main__':

            

Reported by Pylint.

Lib/test/test_tools/test_lll.py
5 issues
Redefining built-in 'dir'
Error

Line: 24 Column: 21

                           tempfile.TemporaryDirectory() as dir2:
            fn1 = os.path.join(dir1, 'foo1')
            fn2 = os.path.join(dir2, 'foo2')
            for fn, dir in (fn1, dir1), (fn2, dir2):
                open(fn, 'w').close()
                os.symlink(fn, os.path.join(dir, 'symlink'))

            with support.captured_stdout() as output:
                self.lll.main([dir1, dir2])

            

Reported by Pylint.

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

Line: 13 Column: 1

              skip_if_missing()


class lllTests(unittest.TestCase):

    def setUp(self):
        self.lll = import_tool('lll')

    @os_helper.skip_unless_symlink

            

Reported by Pylint.

Missing class docstring
Error

Line: 13 Column: 1

              skip_if_missing()


class lllTests(unittest.TestCase):

    def setUp(self):
        self.lll = import_tool('lll')

    @os_helper.skip_unless_symlink

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 19 Column: 5

                      self.lll = import_tool('lll')

    @os_helper.skip_unless_symlink
    def test_lll_multiple_dirs(self):
        with tempfile.TemporaryDirectory() as dir1, \
             tempfile.TemporaryDirectory() as dir2:
            fn1 = os.path.join(dir1, 'foo1')
            fn2 = os.path.join(dir2, 'foo2')
            for fn, dir in (fn1, dir1), (fn2, dir2):

            

Reported by Pylint.

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

Line: 24 Column: 17

                           tempfile.TemporaryDirectory() as dir2:
            fn1 = os.path.join(dir1, 'foo1')
            fn2 = os.path.join(dir2, 'foo2')
            for fn, dir in (fn1, dir1), (fn2, dir2):
                open(fn, 'w').close()
                os.symlink(fn, os.path.join(dir, 'symlink'))

            with support.captured_stdout() as output:
                self.lll.main([dir1, dir2])

            

Reported by Pylint.

Lib/test/test_tools/__init__.py
5 issues
Missing function or method docstring
Error

Line: 18 Column: 1

              toolsdir = os.path.join(basepath, 'Tools')
scriptsdir = os.path.join(toolsdir, 'scripts')

def skip_if_missing(tool=None):
    if tool:
        tooldir = os.path.join(toolsdir, tool)
    else:
        tool = 'scripts'
        tooldir = scriptsdir

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 28 Column: 1

                      raise unittest.SkipTest(f'{tool} directory could not be found')

@contextlib.contextmanager
def imports_under_tool(name, *subdirs):
    tooldir = os.path.join(toolsdir, name, *subdirs)
    with import_helper.DirsOnSysPath(tooldir) as cm:
        yield cm

def import_tool(toolname):

            

Reported by Pylint.

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

Line: 30 Column: 50

              @contextlib.contextmanager
def imports_under_tool(name, *subdirs):
    tooldir = os.path.join(toolsdir, name, *subdirs)
    with import_helper.DirsOnSysPath(tooldir) as cm:
        yield cm

def import_tool(toolname):
    with import_helper.DirsOnSysPath(scriptsdir):
        return importlib.import_module(toolname)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 33 Column: 1

                  with import_helper.DirsOnSysPath(tooldir) as cm:
        yield cm

def import_tool(toolname):
    with import_helper.DirsOnSysPath(scriptsdir):
        return importlib.import_module(toolname)

def load_tests(*args):
    return support.load_package_tests(os.path.dirname(__file__), *args)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 37 Column: 1

                  with import_helper.DirsOnSysPath(scriptsdir):
        return importlib.import_module(toolname)

def load_tests(*args):
    return support.load_package_tests(os.path.dirname(__file__), *args)

            

Reported by Pylint.

Tools/peg_generator/data/cprog.py
5 issues
Using a conditional statement with a constant value
Error

Line: 1 Column: 1

              if 1:
    print("Hello " + "world")
    if 0:
        print("then")
        print("clause")
    elif 1:
        pass
    elif 1:
        pass

            

Reported by Pylint.

Using a conditional statement with a constant value
Error

Line: 3 Column: 5

              if 1:
    print("Hello " + "world")
    if 0:
        print("then")
        print("clause")
    elif 1:
        pass
    elif 1:
        pass

            

Reported by Pylint.

Using a conditional statement with a constant value
Error

Line: 6 Column: 5

                  if 0:
        print("then")
        print("clause")
    elif 1:
        pass
    elif 1:
        pass
    else:
        print("else-clause")

            

Reported by Pylint.

Using a conditional statement with a constant value
Error

Line: 8 Column: 5

                      print("clause")
    elif 1:
        pass
    elif 1:
        pass
    else:
        print("else-clause")

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              if 1:
    print("Hello " + "world")
    if 0:
        print("then")
        print("clause")
    elif 1:
        pass
    elif 1:
        pass

            

Reported by Pylint.

Tools/peg_generator/pegen/ast_dump.py
5 issues
Access to a protected member _attributes of a client class
Error

Line: 47 Column: 39

                                  args.append("%s=%s" % (name, value))
                else:
                    args.append(value)
            if include_attributes and node._attributes:
                for name in node._attributes:
                    try:
                        value = getattr(node, name)
                    except AttributeError:
                        continue

            

Reported by Pylint.

Access to a protected member _attributes of a client class
Error

Line: 48 Column: 29

                              else:
                    args.append(value)
            if include_attributes and node._attributes:
                for name in node._attributes:
                    try:
                        value = getattr(node, name)
                    except AttributeError:
                        continue
                    if value is None and getattr(cls, name, ...) is None:

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 12 Column: 1

              from typing import Any, Optional, Tuple


def ast_dump(
    node: Any,
    annotate_fields: bool = True,
    include_attributes: bool = False,
    *,
    indent: Optional[str] = None,

            

Reported by Pylint.

Too many branches (15/12)
Error

Line: 19 Column: 5

                  *,
    indent: Optional[str] = None,
) -> str:
    def _format(node: Any, level: int = 0) -> Tuple[str, bool]:
        if indent is not None:
            level += 1
            prefix = "\n" + indent * level
            sep = ",\n" + indent * level
        else:

            

Reported by Pylint.

Unnecessary "elif" after "return"
Error

Line: 27 Column: 9

                      else:
            prefix = ""
            sep = ", "
        if any(cls.__name__ == "AST" for cls in node.__class__.__mro__):
            cls = type(node)
            args = []
            allsimple = True
            keywords = annotate_fields
            for name in node._fields:

            

Reported by Pylint.

Lib/zoneinfo/__init__.py
5 issues
Undefined variable name 'TZPATH' in __all__
Error

Line: 5 Column: 5

                  "ZoneInfo",
    "reset_tzpath",
    "available_timezones",
    "TZPATH",
    "ZoneInfoNotFoundError",
    "InvalidTZPathWarning",
]

from . import _tzpath

            

Reported by Pylint.

Unable to import '__init__._common'
Error

Line: 11 Column: 1

              ]

from . import _tzpath
from ._common import ZoneInfoNotFoundError

try:
    from _zoneinfo import ZoneInfo
except ImportError:  # pragma: nocover
    from ._zoneinfo import ZoneInfo

            

Reported by Pylint.

Module import itself
Error

Line: 10 Column: 1

                  "InvalidTZPathWarning",
]

from . import _tzpath
from ._common import ZoneInfoNotFoundError

try:
    from _zoneinfo import ZoneInfo
except ImportError:  # pragma: nocover

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              __all__ = [
    "ZoneInfo",
    "reset_tzpath",
    "available_timezones",
    "TZPATH",
    "ZoneInfoNotFoundError",
    "InvalidTZPathWarning",
]


            

Reported by Pylint.

Unnecessary "else" after "return"
Error

Line: 24 Column: 5

              

def __getattr__(name):
    if name == "TZPATH":
        return _tzpath.TZPATH
    else:
        raise AttributeError(f"module {__name__!r} has no attribute {name!r}")



            

Reported by Pylint.

Tools/scripts/eptags.py
5 issues
Multiple imports on one line (sys, re)
Error

Line: 19 Column: 1

                 classes), TAGS files are not very useful for most object-oriented
   python projects.
"""
import sys,re

expr = r'^[ \t]*(def|class)[ \t]+([a-zA-Z_][a-zA-Z0-9_]*)[ \t]*[:\(]'
matcher = re.compile(expr)

def treat_file(filename, outfp):

            

Reported by Pylint.

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

Line: 21 Column: 1

              """
import sys,re

expr = r'^[ \t]*(def|class)[ \t]+([a-zA-Z_][a-zA-Z0-9_]*)[ \t]*[:\(]'
matcher = re.compile(expr)

def treat_file(filename, outfp):
    """Append tags found in file named 'filename' to the open file 'outfp'"""
    try:

            

Reported by Pylint.

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

Line: 27 Column: 9

              def treat_file(filename, outfp):
    """Append tags found in file named 'filename' to the open file 'outfp'"""
    try:
        fp = open(filename, 'r')
    except OSError:
        sys.stderr.write('Cannot open %s\n'%filename)
        return
    with fp:
        charno = 0

            

Reported by Pylint.

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

Line: 41 Column: 13

                          if not line:
                break
            lineno = lineno + 1
            m = matcher.search(line)
            if m:
                tag = m.group(0) + '\177%d,%d\n' % (lineno, charno)
                tags.append(tag)
                size = size + len(tag)
            charno = charno + len(line)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 51 Column: 1

                  for tag in tags:
        outfp.write(tag)

def main():
    with open('TAGS', 'w') as outfp:
        for filename in sys.argv[1:]:
            treat_file(filename, outfp)

if __name__=="__main__":

            

Reported by Pylint.

Tools/scripts/serve.py
5 issues
Redefining built-in 'type'
Error

Line: 18 Column: 5

                  fn = os.path.join(path, environ['PATH_INFO'][1:])
    if '.' not in fn.split(os.path.sep)[-1]:
        fn = os.path.join(fn, 'index.html')
    type = mimetypes.guess_type(fn)[0]

    if os.path.exists(fn):
        respond('200 OK', [('Content-Type', type)])
        return util.FileWrapper(open(fn, "rb"))
    else:

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 13 Column: 1

              import mimetypes
from wsgiref import simple_server, util

def app(environ, respond):

    fn = os.path.join(path, environ['PATH_INFO'][1:])
    if '.' not in fn.split(os.path.sep)[-1]:
        fn = os.path.join(fn, 'index.html')
    type = mimetypes.guess_type(fn)[0]

            

Reported by Pylint.

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

Line: 15 Column: 5

              
def app(environ, respond):

    fn = os.path.join(path, environ['PATH_INFO'][1:])
    if '.' not in fn.split(os.path.sep)[-1]:
        fn = os.path.join(fn, 'index.html')
    type = mimetypes.guess_type(fn)[0]

    if os.path.exists(fn):

            

Reported by Pylint.

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

Line: 17 Column: 9

              
    fn = os.path.join(path, environ['PATH_INFO'][1:])
    if '.' not in fn.split(os.path.sep)[-1]:
        fn = os.path.join(fn, 'index.html')
    type = mimetypes.guess_type(fn)[0]

    if os.path.exists(fn):
        respond('200 OK', [('Content-Type', type)])
        return util.FileWrapper(open(fn, "rb"))

            

Reported by Pylint.

Unnecessary "else" after "return"
Error

Line: 20 Column: 5

                      fn = os.path.join(fn, 'index.html')
    type = mimetypes.guess_type(fn)[0]

    if os.path.exists(fn):
        respond('200 OK', [('Content-Type', type)])
        return util.FileWrapper(open(fn, "rb"))
    else:
        respond('404 Not Found', [('Content-Type', 'text/plain')])
        return [b'not found']

            

Reported by Pylint.

Lib/test/sample_doctest.py
5 issues
Black listed name "foo"
Error

Line: 15 Column: 1

              """


def foo():
    """

    >>> 2+2
    5


            

Reported by Pylint.

Black listed name "bar"
Error

Line: 25 Column: 1

                  4
    """

def bar():
    """

    >>> 2+2
    4
    """

            

Reported by Pylint.

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

Line: 51 Column: 1

                  b
    """

x = 1
def x_is_one():
    """
    >>> x
    1
    """

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 74 Column: 1

                                  """,
           }

def test_suite():
    import doctest
    return doctest.DocTestSuite()

            

Reported by Pylint.

Import outside toplevel (doctest)
Error

Line: 75 Column: 5

                         }

def test_suite():
    import doctest
    return doctest.DocTestSuite()

            

Reported by Pylint.

Lib/lib2to3/tests/support.py
5 issues
Unused variable 'dirnames'
Error

Line: 53 Column: 18

                  return refactor.RefactoringTool(fixers, options, explicit=True)

def all_project_files():
    for dirpath, dirnames, filenames in os.walk(proj_dir):
        for filename in filenames:
            if filename.endswith(".py"):
                yield os.path.join(dirpath, filename)

TestCase = unittest.TestCase

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 26 Column: 1

                  convert=pytree.convert
)

def parse_string(string):
    return driver.parse_string(reformat(string), debug=True)

def run_all_tests(test_mod=None, tests=None):
    if tests is None:
        tests = unittest.TestLoader().loadTestsFromModule(test_mod)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 29 Column: 1

              def parse_string(string):
    return driver.parse_string(reformat(string), debug=True)

def run_all_tests(test_mod=None, tests=None):
    if tests is None:
        tests = unittest.TestLoader().loadTestsFromModule(test_mod)
    unittest.TextTestRunner(verbosity=2).run(tests)

def reformat(string):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 34 Column: 1

                      tests = unittest.TestLoader().loadTestsFromModule(test_mod)
    unittest.TextTestRunner(verbosity=2).run(tests)

def reformat(string):
    return dedent(string) + "\n\n"

def get_refactorer(fixer_pkg="lib2to3", fixers=None, options=None):
    """
    A convenience function for creating a RefactoringTool for tests.

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 52 Column: 1

                  options = options or {}
    return refactor.RefactoringTool(fixers, options, explicit=True)

def all_project_files():
    for dirpath, dirnames, filenames in os.walk(proj_dir):
        for filename in filenames:
            if filename.endswith(".py"):
                yield os.path.join(dirpath, filename)


            

Reported by Pylint.