The following issues were found

Lib/test/test_importlib/threaded_import_hangers.py
6 issues
Redefining name 'args' from outer scope (line 30)
Error

Line: 22 Column: 34

              # to do its own imports it will block waiting for this module's import
# to complete.
class Worker(threading.Thread):
    def __init__(self, function, args):
        threading.Thread.__init__(self)
        self.function = function
        self.args = args

    def run(self):

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # This is a helper module for test_threaded_import.  The test imports this
# module, and this module tries to run various Python library functions in
# their own thread, as a side effect of being imported.  If the spawned
# thread doesn't complete in TIMEOUT seconds, an "appeared to hang" message
# is appended to the module-global `errors` list.  That list remains empty
# if (and only if) all functions tested complete.

TIMEOUT = 10


            

Reported by Pylint.

Import "import threading" should be placed at the top of the module
Error

Line: 10 Column: 1

              
TIMEOUT = 10

import threading

import tempfile
import os.path

errors = []

            

Reported by Pylint.

Import "import tempfile" should be placed at the top of the module
Error

Line: 12 Column: 1

              
import threading

import tempfile
import os.path

errors = []

# This class merely runs a function in its own thread T.  The thread importing

            

Reported by Pylint.

Import "import os.path" should be placed at the top of the module
Error

Line: 13 Column: 1

              import threading

import tempfile
import os.path

errors = []

# This class merely runs a function in its own thread T.  The thread importing
# this module holds the import lock, so if the function called by T tries

            

Reported by Pylint.

Missing class docstring
Error

Line: 21 Column: 1

              # this module holds the import lock, so if the function called by T tries
# to do its own imports it will block waiting for this module's import
# to complete.
class Worker(threading.Thread):
    def __init__(self, function, args):
        threading.Thread.__init__(self)
        self.function = function
        self.args = args


            

Reported by Pylint.

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

Line: 13 Column: 1

              import test.support

# Local imports
from . import support


@test.support.requires_resource('cpu')
class Test_all(support.TestCase):


            

Reported by Pylint.

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

Line: 17 Column: 1

              

@test.support.requires_resource('cpu')
class Test_all(support.TestCase):

    def setUp(self):
        self.refactor = support.get_refactorer()

    def test_all_project_files(self):

            

Reported by Pylint.

Missing class docstring
Error

Line: 17 Column: 1

              

@test.support.requires_resource('cpu')
class Test_all(support.TestCase):

    def setUp(self):
        self.refactor = support.get_refactorer()

    def test_all_project_files(self):

            

Reported by Pylint.

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

Line: 19 Column: 5

              @test.support.requires_resource('cpu')
class Test_all(support.TestCase):

    def setUp(self):
        self.refactor = support.get_refactorer()

    def test_all_project_files(self):
        for filepath in support.all_project_files():
            self.refactor.refactor_file(filepath)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 19 Column: 5

              @test.support.requires_resource('cpu')
class Test_all(support.TestCase):

    def setUp(self):
        self.refactor = support.get_refactorer()

    def test_all_project_files(self):
        for filepath in support.all_project_files():
            self.refactor.refactor_file(filepath)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 22 Column: 5

                  def setUp(self):
        self.refactor = support.get_refactorer()

    def test_all_project_files(self):
        for filepath in support.all_project_files():
            self.refactor.refactor_file(filepath)

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

            

Reported by Pylint.

Lib/test/test_crashers.py
6 issues
Missing module docstring
Error

Line: 1 Column: 1

              # Tests that the crashers in the Lib/test/crashers directory actually
# do crash the interpreter as expected
#
# If a crasher is fixed, it should be moved elsewhere in the test suite to
# ensure it continues to work correctly.

import unittest
import glob
import os.path

            

Reported by Pylint.

Missing class docstring
Error

Line: 18 Column: 1

              
infinite_loops = ["infinite_loop_re.py", "nasty_eq_vs_dict.py"]

class CrasherTest(unittest.TestCase):

    @unittest.skip("these tests are too fragile")
    @test.support.cpython_only
    def test_crashers_crash(self):
        for fname in glob.glob(CRASHER_FILES):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 22 Column: 5

              
    @unittest.skip("these tests are too fragile")
    @test.support.cpython_only
    def test_crashers_crash(self):
        for fname in glob.glob(CRASHER_FILES):
            if os.path.basename(fname) in infinite_loops:
                continue
            # Some "crashers" only trigger an exception rather than a
            # segfault. Consider that an acceptable outcome.

            

Reported by Pylint.

Method could be a function
Error

Line: 22 Column: 5

              
    @unittest.skip("these tests are too fragile")
    @test.support.cpython_only
    def test_crashers_crash(self):
        for fname in glob.glob(CRASHER_FILES):
            if os.path.basename(fname) in infinite_loops:
                continue
            # Some "crashers" only trigger an exception rather than a
            # segfault. Consider that an acceptable outcome.

            

Reported by Pylint.

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

Line: 33 Column: 1

                          assert_python_failure(fname)


def tearDownModule():
    test.support.reap_children()

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

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 33 Column: 1

                          assert_python_failure(fname)


def tearDownModule():
    test.support.reap_children()

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

            

Reported by Pylint.

Lib/test/subprocessdata/sigchild_ignore.py
6 issues
Multiple imports on one line (signal, subprocess, sys, time)
Error

Line: 1 Column: 1

              import signal, subprocess, sys, time
# On Linux this causes os.waitpid to fail with OSError as the OS has already
# reaped our child process.  The wait() passing the OSError on to the caller
# and causing us to exit with an error is what we are testing against.
signal.signal(signal.SIGCHLD, signal.SIG_IGN)
subprocess.Popen([sys.executable, '-c', 'print("albatross")']).wait()
# Also ensure poll() handles an errno.ECHILD appropriately.
p = subprocess.Popen([sys.executable, '-c', 'print("albatross")'])
num_polls = 0

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import signal, subprocess, sys, time
# On Linux this causes os.waitpid to fail with OSError as the OS has already
# reaped our child process.  The wait() passing the OSError on to the caller
# and causing us to exit with an error is what we are testing against.
signal.signal(signal.SIGCHLD, signal.SIG_IGN)
subprocess.Popen([sys.executable, '-c', 'print("albatross")']).wait()
# Also ensure poll() handles an errno.ECHILD appropriately.
p = subprocess.Popen([sys.executable, '-c', 'print("albatross")'])
num_polls = 0

            

Reported by Pylint.

Consider possible security implications associated with subprocess module.
Security blacklist

Line: 1
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_imports.html#b404-import-subprocess

              import signal, subprocess, sys, time
# On Linux this causes os.waitpid to fail with OSError as the OS has already
# reaped our child process.  The wait() passing the OSError on to the caller
# and causing us to exit with an error is what we are testing against.
signal.signal(signal.SIGCHLD, signal.SIG_IGN)
subprocess.Popen([sys.executable, '-c', 'print("albatross")']).wait()
# Also ensure poll() handles an errno.ECHILD appropriately.
p = subprocess.Popen([sys.executable, '-c', 'print("albatross")'])
num_polls = 0

            

Reported by Bandit.

subprocess call - check for execution of untrusted input.
Security injection

Line: 6
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b603_subprocess_without_shell_equals_true.html

              # reaped our child process.  The wait() passing the OSError on to the caller
# and causing us to exit with an error is what we are testing against.
signal.signal(signal.SIGCHLD, signal.SIG_IGN)
subprocess.Popen([sys.executable, '-c', 'print("albatross")']).wait()
# Also ensure poll() handles an errno.ECHILD appropriately.
p = subprocess.Popen([sys.executable, '-c', 'print("albatross")'])
num_polls = 0
while p.poll() is None:
    # Waiting for the process to finish.

            

Reported by Bandit.

subprocess call - check for execution of untrusted input.
Security injection

Line: 8
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b603_subprocess_without_shell_equals_true.html

              signal.signal(signal.SIGCHLD, signal.SIG_IGN)
subprocess.Popen([sys.executable, '-c', 'print("albatross")']).wait()
# Also ensure poll() handles an errno.ECHILD appropriately.
p = subprocess.Popen([sys.executable, '-c', 'print("albatross")'])
num_polls = 0
while p.poll() is None:
    # Waiting for the process to finish.
    time.sleep(0.01)  # Avoid being a CPU busy loop.
    num_polls += 1

            

Reported by Bandit.

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

Line: 9 Column: 1

              subprocess.Popen([sys.executable, '-c', 'print("albatross")']).wait()
# Also ensure poll() handles an errno.ECHILD appropriately.
p = subprocess.Popen([sys.executable, '-c', 'print("albatross")'])
num_polls = 0
while p.poll() is None:
    # Waiting for the process to finish.
    time.sleep(0.01)  # Avoid being a CPU busy loop.
    num_polls += 1
    if num_polls > 3000:

            

Reported by Pylint.

Lib/test/badsyntax_future8.py
6 issues
Wildcard import __future__
Error

Line: 3 Column: 1

              """This is a test"""

from __future__ import *

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


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 5 Column: 1

              
from __future__ import *

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

print(f(2)(4))

            

Reported by Pylint.

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

Line: 5 Column: 1

              
from __future__ import *

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

print(f(2)(4))

            

Reported by Pylint.

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

Line: 5 Column: 1

              
from __future__ import *

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

print(f(2)(4))

            

Reported by Pylint.

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

Line: 6 Column: 5

              from __future__ import *

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

print(f(2)(4))

            

Reported by Pylint.

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

Line: 6 Column: 5

              from __future__ import *

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

print(f(2)(4))

            

Reported by Pylint.

Lib/test/test_codecmaps_jp.py
6 issues
Missing module docstring
Error

Line: 1 Column: 1

              #
# test_codecmaps_jp.py
#   Codec mapping tests for Japanese encodings
#

from test import multibytecodec_support
import unittest

class TestCP932Map(multibytecodec_support.TestBase_Mapping,

            

Reported by Pylint.

Missing class docstring
Error

Line: 9 Column: 1

              from test import multibytecodec_support
import unittest

class TestCP932Map(multibytecodec_support.TestBase_Mapping,
                   unittest.TestCase):
    encoding = 'cp932'
    mapfileurl = 'http://www.pythontest.net/unicode/CP932.TXT'
    supmaps = [
        (b'\x80', '\u0080'),

            

Reported by Pylint.

Missing class docstring
Error

Line: 24 Column: 1

                      supmaps.append((bytes([i]), chr(i+0xfec0)))


class TestEUCJPCOMPATMap(multibytecodec_support.TestBase_Mapping,
                         unittest.TestCase):
    encoding = 'euc_jp'
    mapfilename = 'EUC-JP.TXT'
    mapfileurl = 'http://www.pythontest.net/unicode/EUC-JP.TXT'


            

Reported by Pylint.

Missing class docstring
Error

Line: 31 Column: 1

                  mapfileurl = 'http://www.pythontest.net/unicode/EUC-JP.TXT'


class TestSJISCOMPATMap(multibytecodec_support.TestBase_Mapping,
                        unittest.TestCase):
    encoding = 'shift_jis'
    mapfilename = 'SHIFTJIS.TXT'
    mapfileurl = 'http://www.pythontest.net/unicode/SHIFTJIS.TXT'
    pass_enctest = [

            

Reported by Pylint.

Missing class docstring
Error

Line: 45 Column: 1

                      (b'\x81_', '\\'),
    ]

class TestEUCJISX0213Map(multibytecodec_support.TestBase_Mapping,
                         unittest.TestCase):
    encoding = 'euc_jisx0213'
    mapfilename = 'EUC-JISX0213.TXT'
    mapfileurl = 'http://www.pythontest.net/unicode/EUC-JISX0213.TXT'


            

Reported by Pylint.

Missing class docstring
Error

Line: 52 Column: 1

                  mapfileurl = 'http://www.pythontest.net/unicode/EUC-JISX0213.TXT'


class TestSJISX0213Map(multibytecodec_support.TestBase_Mapping,
                       unittest.TestCase):
    encoding = 'shift_jisx0213'
    mapfilename = 'SHIFT_JISX0213.TXT'
    mapfileurl = 'http://www.pythontest.net/unicode/SHIFT_JISX0213.TXT'


            

Reported by Pylint.

Lib/test/dataclass_textanno.py
6 issues
Missing module docstring
Error

Line: 1 Column: 1

              from __future__ import annotations

import dataclasses


class Foo:
    pass



            

Reported by Pylint.

Missing class docstring
Error

Line: 6 Column: 1

              import dataclasses


class Foo:
    pass


@dataclasses.dataclass
class Bar:

            

Reported by Pylint.

Too few public methods (0/2)
Error

Line: 6 Column: 1

              import dataclasses


class Foo:
    pass


@dataclasses.dataclass
class Bar:

            

Reported by Pylint.

Missing class docstring
Error

Line: 11 Column: 1

              

@dataclasses.dataclass
class Bar:
    foo: Foo

            

Reported by Pylint.

Black listed name "foo"
Error

Line: 12 Column: 5

              
@dataclasses.dataclass
class Bar:
    foo: Foo

            

Reported by Pylint.

Black listed name "foo"
Error

Line: 12 Column: 5

              
@dataclasses.dataclass
class Bar:
    foo: Foo

            

Reported by Pylint.

Doc/includes/sqlite3/adapter_point_2.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 adapt_point(point):
    return "%f;%f" % (point.x, point.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 adapt_point(point):
    return "%f;%f" % (point.x, point.y)


            

Reported by Pylint.

Too few public methods (0/2)
Error

Line: 3 Column: 1

              import sqlite3

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

def adapt_point(point):
    return "%f;%f" % (point.x, point.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 adapt_point(point):
    return "%f;%f" % (point.x, point.y)

sqlite3.register_adapter(Point, adapt_point)

            

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 adapt_point(point):
    return "%f;%f" % (point.x, point.y)

sqlite3.register_adapter(Point, adapt_point)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 7 Column: 1

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

def adapt_point(point):
    return "%f;%f" % (point.x, point.y)

sqlite3.register_adapter(Point, adapt_point)

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

            

Reported by Pylint.

Lib/distutils/tests/test_text_file.py
6 issues
Unused argument 'count'
Error

Line: 50 Column: 24

                      # "collapse" joined lines
        result6 = ["line 3 continues on next line"]

        def test_input(count, description, file, expected_result):
            result = file.readlines()
            self.assertEqual(result, expected_result)

        tmpdir = self.mkdtemp()
        filename = os.path.join(tmpdir, "test.txt")

            

Reported by Pylint.

Unused argument 'description'
Error

Line: 50 Column: 31

                      # "collapse" joined lines
        result6 = ["line 3 continues on next line"]

        def test_input(count, description, file, expected_result):
            result = file.readlines()
            self.assertEqual(result, expected_result)

        tmpdir = self.mkdtemp()
        filename = os.path.join(tmpdir, "test.txt")

            

Reported by Pylint.

Missing class docstring
Error

Line: 15 Column: 1

                continues on next line
"""

class TextFileTestCase(support.TempdirManager, unittest.TestCase):

    def test_class(self):
        # old tests moved from text_file.__main__
        # so they are really called by the buildbots


            

Reported by Pylint.

Too many branches (14/12)
Error

Line: 17 Column: 5

              
class TextFileTestCase(support.TempdirManager, unittest.TestCase):

    def test_class(self):
        # old tests moved from text_file.__main__
        # so they are really called by the buildbots

        # result 1: no fancy options
        result1 = ['# test file\n', '\n', 'line 3 \\\n',

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 17 Column: 5

              
class TextFileTestCase(support.TempdirManager, unittest.TestCase):

    def test_class(self):
        # old tests moved from text_file.__main__
        # so they are really called by the buildbots

        # result 1: no fancy options
        result1 = ['# test file\n', '\n', 'line 3 \\\n',

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 103 Column: 1

                      finally:
            in_file.close()

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

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

            

Reported by Pylint.

Lib/idlelib/idle_test/test_debugger.py
6 issues
standard import "import unittest" should be placed before "from idlelib import debugger"
Error

Line: 4 Column: 1

              "Test debugger, coverage 19%"

from idlelib import debugger
import unittest
from test.support import requires
requires('gui')
from tkinter import Tk



            

Reported by Pylint.

standard import "from test.support import requires" should be placed before "from idlelib import debugger"
Error

Line: 5 Column: 1

              
from idlelib import debugger
import unittest
from test.support import requires
requires('gui')
from tkinter import Tk


class NameSpaceTest(unittest.TestCase):

            

Reported by Pylint.

standard import "from tkinter import Tk" should be placed before "from idlelib import debugger"
Error

Line: 7 Column: 1

              import unittest
from test.support import requires
requires('gui')
from tkinter import Tk


class NameSpaceTest(unittest.TestCase):

    @classmethod

            

Reported by Pylint.

Import "from tkinter import Tk" should be placed at the top of the module
Error

Line: 7 Column: 1

              import unittest
from test.support import requires
requires('gui')
from tkinter import Tk


class NameSpaceTest(unittest.TestCase):

    @classmethod

            

Reported by Pylint.

Missing class docstring
Error

Line: 10 Column: 1

              from tkinter import Tk


class NameSpaceTest(unittest.TestCase):

    @classmethod
    def setUpClass(cls):
        cls.root = Tk()
        cls.root.withdraw()

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 22 Column: 5

                      cls.root.destroy()
        del cls.root

    def test_init(self):
        debugger.NamespaceViewer(self.root, 'Test')


# Other classes are Idb, Debugger, and StackViewer.


            

Reported by Pylint.