The following issues were found

Lib/test/test_dbm_gnu.py
34 issues
Statement seems to have no effect
Error

Line: 57 Column: 13

                      self.assertIsNone(self.g.get(b'xxx'))
        self.assertEqual(self.g.get(b'xxx', b'foo'), b'foo')
        with self.assertRaises(KeyError):
            self.g['xxx']
        self.assertEqual(self.g.setdefault(b'xxx', b'foo'), b'foo')
        self.assertEqual(self.g[b'xxx'], b'foo')

    def test_error_conditions(self):
        # Try to open a non-existent database.

            

Reported by Pylint.

Redefining built-in 'all'
Error

Line: 74 Column: 9

              
    def test_flags(self):
        # Test the flag parameter open() by trying all supported flag modes.
        all = set(gdbm.open_flags)
        # Test standard flags (presumably "crwn").
        modes = all - set('fsu')
        for mode in sorted(modes):  # put "c" mode first
            self.g = gdbm.open(filename, mode)
            self.g.close()

            

Reported by Pylint.

Redefining name 'filename' from outer scope (line 9)
Error

Line: 155 Column: 9

                  @unittest.skipUnless(TESTFN_NONASCII,
                         'requires OS support of non-ASCII encodings')
    def test_nonascii_filename(self):
        filename = TESTFN_NONASCII
        self.addCleanup(unlink, filename)
        with gdbm.open(filename, 'c') as db:
            db[b'key'] = b'value'
        self.assertTrue(os.path.exists(filename))
        with gdbm.open(filename, 'r') as db:

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from test import support
from test.support import import_helper, cpython_only
gdbm = import_helper.import_module("dbm.gnu") #skip if not supported
import unittest
import os
from test.support.os_helper import TESTFN, TESTFN_NONASCII, unlink


filename = TESTFN

            

Reported by Pylint.

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

Line: 4 Column: 1

              from test import support
from test.support import import_helper, cpython_only
gdbm = import_helper.import_module("dbm.gnu") #skip if not supported
import unittest
import os
from test.support.os_helper import TESTFN, TESTFN_NONASCII, unlink


filename = TESTFN

            

Reported by Pylint.

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

Line: 5 Column: 1

              from test.support import import_helper, cpython_only
gdbm = import_helper.import_module("dbm.gnu") #skip if not supported
import unittest
import os
from test.support.os_helper import TESTFN, TESTFN_NONASCII, unlink


filename = TESTFN


            

Reported by Pylint.

Imports from package test are not grouped
Error

Line: 6 Column: 1

              gdbm = import_helper.import_module("dbm.gnu") #skip if not supported
import unittest
import os
from test.support.os_helper import TESTFN, TESTFN_NONASCII, unlink


filename = TESTFN

class TestGdbm(unittest.TestCase):

            

Reported by Pylint.

Import "from test.support.os_helper import TESTFN, TESTFN_NONASCII, unlink" should be placed at the top of the module
Error

Line: 6 Column: 1

              gdbm = import_helper.import_module("dbm.gnu") #skip if not supported
import unittest
import os
from test.support.os_helper import TESTFN, TESTFN_NONASCII, unlink


filename = TESTFN

class TestGdbm(unittest.TestCase):

            

Reported by Pylint.

Missing class docstring
Error

Line: 11 Column: 1

              
filename = TESTFN

class TestGdbm(unittest.TestCase):
    @staticmethod
    def setUpClass():
        if support.verbose:
            try:
                from _gdbm import _GDBM_VERSION as version

            

Reported by Pylint.

Import outside toplevel (_gdbm._GDBM_VERSION)
Error

Line: 16 Column: 17

                  def setUpClass():
        if support.verbose:
            try:
                from _gdbm import _GDBM_VERSION as version
            except ImportError:
                pass
            else:
                print(f"gdbm version: {version}")


            

Reported by Pylint.

Lib/test/test_email/test_parser.py
34 issues
Instance of 'TestParserBase' has no 'parsers' member
Error

Line: 42 Column: 23

                      # The unicode line splitter splits on unicode linebreaks, which are
        # more numerous than allowed by the email RFCs; make sure we are only
        # splitting on those two.
        for parser in self.parsers:
            with self.subTest(parser=parser.__name__):
                msg = parser(
                    "Next-Line: not\x85broken\r\n"
                    "Null: not\x00broken\r\n"
                    "Vertical-Tab: not\vbroken\r\n"

            

Reported by Pylint.

Instance of 'TestParserBase' has no 'subTest' member
Error

Line: 43 Column: 18

                      # more numerous than allowed by the email RFCs; make sure we are only
        # splitting on those two.
        for parser in self.parsers:
            with self.subTest(parser=parser.__name__):
                msg = parser(
                    "Next-Line: not\x85broken\r\n"
                    "Null: not\x00broken\r\n"
                    "Vertical-Tab: not\vbroken\r\n"
                    "Form-Feed: not\fbroken\r\n"

            

Reported by Pylint.

Instance of 'TestParserBase' has no 'assertEqual' member
Error

Line: 57 Column: 17

                                  "\r\n",
                    policy=default,
                )
                self.assertEqual(msg.items(), [
                    ("Next-Line", "not\x85broken"),
                    ("Null", "not\x00broken"),
                    ("Vertical-Tab", "not\vbroken"),
                    ("Form-Feed", "not\fbroken"),
                    ("File-Separator", "not\x1Cbroken"),

            

Reported by Pylint.

Instance of 'TestParserBase' has no 'assertEqual' member
Error

Line: 68 Column: 17

                                  ("Line-Separator", "not\u2028broken"),
                    ("Paragraph-Separator", "not\u2029broken"),
                ])
                self.assertEqual(msg.get_payload(), "")

    class MyMessage(EmailMessage):
        pass

    def test_custom_message_factory_on_policy(self):

            

Reported by Pylint.

Instance of 'TestParserBase' has no 'parsers' member
Error

Line: 74 Column: 23

                      pass

    def test_custom_message_factory_on_policy(self):
        for parser in self.parsers:
            with self.subTest(parser=parser.__name__):
                MyPolicy = default.clone(message_factory=self.MyMessage)
                msg = parser("To: foo\n\ntest", policy=MyPolicy)
                self.assertIsInstance(msg, self.MyMessage)


            

Reported by Pylint.

Instance of 'TestParserBase' has no 'subTest' member
Error

Line: 75 Column: 18

              
    def test_custom_message_factory_on_policy(self):
        for parser in self.parsers:
            with self.subTest(parser=parser.__name__):
                MyPolicy = default.clone(message_factory=self.MyMessage)
                msg = parser("To: foo\n\ntest", policy=MyPolicy)
                self.assertIsInstance(msg, self.MyMessage)

    def test_factory_arg_overrides_policy(self):

            

Reported by Pylint.

Instance of 'TestParserBase' has no 'assertIsInstance' member
Error

Line: 78 Column: 17

                          with self.subTest(parser=parser.__name__):
                MyPolicy = default.clone(message_factory=self.MyMessage)
                msg = parser("To: foo\n\ntest", policy=MyPolicy)
                self.assertIsInstance(msg, self.MyMessage)

    def test_factory_arg_overrides_policy(self):
        for parser in self.parsers:
            with self.subTest(parser=parser.__name__):
                MyPolicy = default.clone(message_factory=self.MyMessage)

            

Reported by Pylint.

Instance of 'TestParserBase' has no 'parsers' member
Error

Line: 81 Column: 23

                              self.assertIsInstance(msg, self.MyMessage)

    def test_factory_arg_overrides_policy(self):
        for parser in self.parsers:
            with self.subTest(parser=parser.__name__):
                MyPolicy = default.clone(message_factory=self.MyMessage)
                msg = parser("To: foo\n\ntest", Message, policy=MyPolicy)
                self.assertNotIsInstance(msg, self.MyMessage)
                self.assertIsInstance(msg, Message)

            

Reported by Pylint.

Instance of 'TestParserBase' has no 'subTest' member
Error

Line: 82 Column: 18

              
    def test_factory_arg_overrides_policy(self):
        for parser in self.parsers:
            with self.subTest(parser=parser.__name__):
                MyPolicy = default.clone(message_factory=self.MyMessage)
                msg = parser("To: foo\n\ntest", Message, policy=MyPolicy)
                self.assertNotIsInstance(msg, self.MyMessage)
                self.assertIsInstance(msg, Message)


            

Reported by Pylint.

Instance of 'TestParserBase' has no 'assertNotIsInstance' member
Error

Line: 85 Column: 17

                          with self.subTest(parser=parser.__name__):
                MyPolicy = default.clone(message_factory=self.MyMessage)
                msg = parser("To: foo\n\ntest", Message, policy=MyPolicy)
                self.assertNotIsInstance(msg, self.MyMessage)
                self.assertIsInstance(msg, Message)

# Play some games to get nice output in subTest.  This code could be clearer
# if staticmethod supported __name__.


            

Reported by Pylint.

Tools/demo/markov.py
34 issues
Redefining built-in 'next'
Error

Line: 13 Column: 26

                      self.choice = choice
        self.trans = {}

    def add(self, state, next):
        self.trans.setdefault(state, []).append(next)

    def put(self, seq):
        n = self.histsize
        add = self.add

            

Reported by Pylint.

Redefining built-in 'next'
Error

Line: 32 Column: 13

                      while True:
            subseq = seq[max(0, len(seq)-n):]
            options = trans[subseq]
            next = choice(options)
            if not next:
                break
            seq += next
        return seq


            

Reported by Pylint.

Unused variable 'a'
Error

Line: 62 Column: 12

                  histsize = 2
    do_words = False
    debug = 1
    for o, a in opts:
        if '-0' <= o <= '-9': histsize = int(o[1:])
        if o == '-c': do_words = False
        if o == '-d': debug += 1
        if o == '-q': debug = 0
        if o == '-w': do_words = True

            

Reported by Pylint.

Missing class docstring
Error

Line: 7 Column: 1

              Markov chain simulation of words or characters.
"""

class Markov:
    def __init__(self, histsize, choice):
        self.histsize = histsize
        self.choice = choice
        self.trans = {}


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 13 Column: 5

                      self.choice = choice
        self.trans = {}

    def add(self, state, next):
        self.trans.setdefault(state, []).append(next)

    def put(self, seq):
        n = self.histsize
        add = self.add

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 16 Column: 5

                  def add(self, state, next):
        self.trans.setdefault(state, []).append(next)

    def put(self, seq):
        n = self.histsize
        add = self.add
        add(None, seq[:0])
        for i in range(len(seq)):
            add(seq[max(0, i-n):i], seq[i:i+1])

            

Reported by Pylint.

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

Line: 17 Column: 9

                      self.trans.setdefault(state, []).append(next)

    def put(self, seq):
        n = self.histsize
        add = self.add
        add(None, seq[:0])
        for i in range(len(seq)):
            add(seq[max(0, i-n):i], seq[i:i+1])
        add(seq[len(seq)-n:], None)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 24 Column: 5

                          add(seq[max(0, i-n):i], seq[i:i+1])
        add(seq[len(seq)-n:], None)

    def get(self):
        choice = self.choice
        trans = self.trans
        n = self.histsize
        seq = choice(trans[None])
        while True:

            

Reported by Pylint.

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

Line: 27 Column: 9

                  def get(self):
        choice = self.choice
        trans = self.trans
        n = self.histsize
        seq = choice(trans[None])
        while True:
            subseq = seq[max(0, len(seq)-n):]
            options = trans[subseq]
            next = choice(options)

            

Reported by Pylint.

Too many statements (84/50)
Error

Line: 39 Column: 1

                      return seq


def test():
    import sys, random, getopt
    args = sys.argv[1:]
    try:
        opts, args = getopt.getopt(args, '0123456789cdwq')
    except getopt.error:

            

Reported by Pylint.

Lib/types.py
34 issues
Class 'function' has no '__code__' member
Error

Line: 62 Column: 29

                  tb = None; del tb

# For Jython, the following two types are identical
GetSetDescriptorType = type(FunctionType.__code__)
MemberDescriptorType = type(FunctionType.__globals__)

del sys, _f, _g, _C, _c, _ag  # Not for export



            

Reported by Pylint.

Class 'function' has no '__globals__' member
Error

Line: 63 Column: 29

              
# For Jython, the following two types are identical
GetSetDescriptorType = type(FunctionType.__code__)
MemberDescriptorType = type(FunctionType.__globals__)

del sys, _f, _g, _C, _c, _ag  # Not for export


# Provide a PEP 3115 compliant mechanism for class creation

            

Reported by Pylint.

Value 'list' is unsubscriptable
Error

Line: 300 Column: 21

              
    return wrapped

GenericAlias = type(list[int])
UnionType = type(int | str)

EllipsisType = type(Ellipsis)
NoneType = type(None)
NotImplementedType = type(NotImplemented)

            

Reported by Pylint.

unsupported operand type(s) for |
Error

Line: 301 Column: 18

                  return wrapped

GenericAlias = type(list[int])
UnionType = type(int | str)

EllipsisType = type(Ellipsis)
NoneType = type(None)
NotImplementedType = type(NotImplemented)


            

Reported by Pylint.

Access to a protected member _m of a client class
Error

Line: 41 Column: 19

              
class _C:
    def _m(self): pass
MethodType = type(_C()._m)

BuiltinFunctionType = type(len)
BuiltinMethodType = type([].append)     # Same as BuiltinFunctionType

WrapperDescriptorType = type(object.__init__)

            

Reported by Pylint.

TODO: Implement this in C.
Error

Line: 213 Column: 3

              

class _GeneratorWrapper:
    # TODO: Implement this in C.
    def __init__(self, gen):
        self.__wrapped = gen
        self.__isgen = gen.__class__ is GeneratorType
        self.__name__ = getattr(gen, '__name__', None)
        self.__qualname__ = getattr(gen, '__qualname__', None)

            

Reported by Pylint.

TODO: Implement this in C.
Error

Line: 268 Column: 3

                      # Check if 'func' is a generator function.
        # (0x20 == CO_GENERATOR)
        if co_flags & 0x20:
            # TODO: Implement this in C.
            co = func.__code__
            # 0x100 == CO_ITERABLE_COROUTINE
            func.__code__ = co.replace(co_flags=co.co_flags | 0x100)
            return func


            

Reported by Pylint.

More than one statement on a single line
Error

Line: 11 Column: 11

              # iterator.  Don't check the type!  Use hasattr to check for both
# "__iter__" and "__next__" attributes instead.

def _f(): pass
FunctionType = type(_f)
LambdaType = type(lambda: None)         # Same as FunctionType
CodeType = type(_f.__code__)
MappingProxyType = type(type.__dict__)
SimpleNamespace = type(sys.implementation)

            

Reported by Pylint.

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

Line: 19 Column: 5

              SimpleNamespace = type(sys.implementation)

def _cell_factory():
    a = 1
    def f():
        nonlocal a
    return f.__closure__[0]
CellType = type(_cell_factory())


            

Reported by Pylint.

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

Line: 20 Column: 5

              
def _cell_factory():
    a = 1
    def f():
        nonlocal a
    return f.__closure__[0]
CellType = type(_cell_factory())

def _g():

            

Reported by Pylint.

Lib/test/test_zipimport_support.py
34 issues
Module 'zipimport' has no '_zip_directory_cache' member
Error

Line: 67 Column: 9

                  # just to avoid any bogus errors due to name reuse in the tests
    def setUp(self):
        linecache.clearcache()
        zipimport._zip_directory_cache.clear()
        self.path = sys.path[:]
        self.meta_path = sys.meta_path[:]
        self.path_hooks = sys.path_hooks[:]
        sys.path_importer_cache.clear()


            

Reported by Pylint.

Unable to import 'zip_pkg'
Error

Line: 89 Column: 13

                                                              init_name, name_in_zip)
            os.remove(init_name)
            sys.path.insert(0, zip_name)
            import zip_pkg
            try:
                self.assertEqual(inspect.getsource(zip_pkg.foo), test_src)
            finally:
                del sys.modules["zip_pkg"]


            

Reported by Pylint.

Unable to import 'test_zipped_doctest'
Error

Line: 135 Column: 13

                                  zip_file.printdir()
            os.remove(script_name)
            sys.path.insert(0, zip_name)
            import test_zipped_doctest
            try:
                # Some of the doc tests depend on the colocated text files
                # which aren't available to the zipped version (the doctest
                # module currently requires real filenames for non-embedded
                # tests). So we're forced to be selective about which tests

            

Reported by Pylint.

Access to a protected member _zip_directory_cache of a client class
Error

Line: 67 Column: 9

                  # just to avoid any bogus errors due to name reuse in the tests
    def setUp(self):
        linecache.clearcache()
        zipimport._zip_directory_cache.clear()
        self.path = sys.path[:]
        self.meta_path = sys.meta_path[:]
        self.path_hooks = sys.path_hooks[:]
        sys.path_importer_cache.clear()


            

Reported by Pylint.

Unused variable 'run_name'
Error

Line: 85 Column: 23

                          init_name = make_script(d, '__init__', test_src)
            name_in_zip = os.path.join('zip_pkg',
                                       os.path.basename(init_name))
            zip_name, run_name = make_zip_script(d, 'test_zip',
                                                init_name, name_in_zip)
            os.remove(init_name)
            sys.path.insert(0, zip_name)
            import zip_pkg
            try:

            

Reported by Pylint.

Unused variable 'run_name'
Error

Line: 124 Column: 23

                      with os_helper.temp_dir() as d:
            script_name = make_script(d, 'test_zipped_doctest',
                                            test_src)
            zip_name, run_name = make_zip_script(d, 'test_zip',
                                                script_name)
            with zipfile.ZipFile(zip_name, 'a') as z:
                for mod_name, src in sample_sources.items():
                    z.writestr(mod_name + ".py", src)
            if verbose:

            

Reported by Pylint.

Unused variable 'fail_due_to_missing_data_files'
Error

Line: 175 Column: 17

                              ]
                # These tests are the ones which need access
                # to the data files, so we don't run them
                fail_due_to_missing_data_files = [
                    test_zipped_doctest.test_DocFileSuite,
                    test_zipped_doctest.test_testfile,
                    test_zipped_doctest.test_unittest_reportflags,
                ]


            

Reported by Pylint.

Unused variable 'rc'
Error

Line: 198 Column: 13

                      pattern = 'File "%s", line 2, in %s'
        with os_helper.temp_dir() as d:
            script_name = make_script(d, 'script', test_src)
            rc, out, err = assert_python_ok(script_name)
            expected = pattern % (script_name, "__main__.Test")
            if verbose:
                print ("Expected line", expected)
                print ("Got stdout:")
                print (ascii(out))

            

Reported by Pylint.

Unused variable 'err'
Error

Line: 198 Column: 22

                      pattern = 'File "%s", line 2, in %s'
        with os_helper.temp_dir() as d:
            script_name = make_script(d, 'script', test_src)
            rc, out, err = assert_python_ok(script_name)
            expected = pattern % (script_name, "__main__.Test")
            if verbose:
                print ("Expected line", expected)
                print ("Got stdout:")
                print (ascii(out))

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # This test module covers support in various parts of the standard library
# for working with modules located inside zipfiles
# The tests are centralised in this fashion to make it easy to drop them
# if a platform doesn't support zipimport
import test.support
import os
import os.path
import sys
import textwrap

            

Reported by Pylint.

Lib/idlelib/format.py
34 issues
Unused argument 'event'
Error

Line: 42 Column: 38

                  def close(self):
        self.editwin = None

    def format_paragraph_event(self, event, limit=None):
        """Formats paragraph to a max width specified in idleConf.

        If text is selected, format_paragraph_event will start breaking lines
        at the max width, starting from the beginning selection.


            

Reported by Pylint.

Unused variable 'col'
Error

Line: 89 Column: 13

                  Also returns the comment format string, if any, and paragraph of text
    between the start/stop indices.
    """
    lineno, col = map(int, mark.split("."))
    line = text.get("%d.0" % lineno, "%d.end" % lineno)

    # Look for start of next paragraph if the index passed in is a blank line
    while text.compare("%d.0" % lineno, "<", "end") and is_all_white(line):
        lineno = lineno + 1

            

Reported by Pylint.

XXX Should take double space after period (etc.) into account
Error

Line: 137 Column: 3

                  new = lines[:i]
    partial = indent1
    while i < n and not is_all_white(lines[i]):
        # XXX Should take double space after period (etc.) into account
        words = re.split(r"(\s+)", lines[i])
        for j in range(0, len(words), 2):
            word = words[j]
            if not word:
                continue # Can happen when line ends in whitespace

            

Reported by Pylint.

XXX Should reformat remaining paragraphs as well
Error

Line: 152 Column: 3

                              partial = partial + " "
        i = i+1
    new.append(partial.rstrip())
    # XXX Should reformat remaining paragraphs as well
    new.extend(lines[i:])
    return "\n".join(new)

def reformat_comment(data, limit, comment_header):
    """Return data reformatted to specified width with comment header."""

            

Reported by Pylint.

Unused argument 'event'
Error

Line: 264 Column: 35

                      text.undo_block_stop()
        text.tag_add("sel", head, "insert")

    def indent_region_event(self, event=None):
        "Indent region by indentwidth spaces."
        head, tail, chars, lines = self.get_region()
        for pos in range(len(lines)):
            line = lines[pos]
            if line:

            

Reported by Pylint.

Access to a protected member _make_blanks of a client class
Error

Line: 272 Column: 30

                          if line:
                raw, effective = get_line_indent(line, self.editwin.tabwidth)
                effective = effective + self.editwin.indentwidth
                lines[pos] = self.editwin._make_blanks(effective) + line[raw:]
        self.set_region(head, tail, chars, lines)
        return "break"

    def dedent_region_event(self, event=None):
        "Dedent region by indentwidth spaces."

            

Reported by Pylint.

Unused argument 'event'
Error

Line: 276 Column: 35

                      self.set_region(head, tail, chars, lines)
        return "break"

    def dedent_region_event(self, event=None):
        "Dedent region by indentwidth spaces."
        head, tail, chars, lines = self.get_region()
        for pos in range(len(lines)):
            line = lines[pos]
            if line:

            

Reported by Pylint.

Access to a protected member _make_blanks of a client class
Error

Line: 284 Column: 30

                          if line:
                raw, effective = get_line_indent(line, self.editwin.tabwidth)
                effective = max(effective - self.editwin.indentwidth, 0)
                lines[pos] = self.editwin._make_blanks(effective) + line[raw:]
        self.set_region(head, tail, chars, lines)
        return "break"

    def comment_region_event(self, event=None):
        """Comment out each line in region.

            

Reported by Pylint.

Unused argument 'event'
Error

Line: 288 Column: 36

                      self.set_region(head, tail, chars, lines)
        return "break"

    def comment_region_event(self, event=None):
        """Comment out each line in region.

        ## is appended to the beginning of each line to comment it out.
        """
        head, tail, chars, lines = self.get_region()

            

Reported by Pylint.

Unused argument 'event'
Error

Line: 300 Column: 38

                      self.set_region(head, tail, chars, lines)
        return "break"

    def uncomment_region_event(self, event=None):
        """Uncomment each line in region.

        Remove ## or # in the first positions of a line.  If the comment
        is not in the beginning position, this command will have no effect.
        """

            

Reported by Pylint.

Lib/asyncio/windows_utils.py
34 issues
Unable to import '_winapi'
Error

Line: 8 Column: 1

              if sys.platform != 'win32':  # pragma: no cover
    raise ImportError('win32 only')

import _winapi
import itertools
import msvcrt
import os
import subprocess
import tempfile

            

Reported by Pylint.

Unable to import 'msvcrt'
Error

Line: 10 Column: 1

              
import _winapi
import itertools
import msvcrt
import os
import subprocess
import tempfile
import warnings


            

Reported by Pylint.

Use of insecure and deprecated function (mktemp).
Security blacklist

Line: 34
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b306-mktemp-q

              
def pipe(*, duplex=False, overlapped=(True, True), bufsize=BUFSIZE):
    """Like os.pipe() but with overlapped support and using handles not fds."""
    address = tempfile.mktemp(
        prefix=r'\\.\pipe\python-pipe-{:d}-{:d}-'.format(
            os.getpid(), next(_mmap_counter)))

    if duplex:
        openmode = _winapi.PIPE_ACCESS_DUPLEX

            

Reported by Bandit.

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

Line: 8 Column: 1

              if sys.platform != 'win32':  # pragma: no cover
    raise ImportError('win32 only')

import _winapi
import itertools
import msvcrt
import os
import subprocess
import tempfile

            

Reported by Pylint.

standard import "import itertools" should be placed before "import _winapi"
Error

Line: 9 Column: 1

                  raise ImportError('win32 only')

import _winapi
import itertools
import msvcrt
import os
import subprocess
import tempfile
import warnings

            

Reported by Pylint.

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

Line: 9 Column: 1

                  raise ImportError('win32 only')

import _winapi
import itertools
import msvcrt
import os
import subprocess
import tempfile
import warnings

            

Reported by Pylint.

standard import "import msvcrt" should be placed before "import _winapi"
Error

Line: 10 Column: 1

              
import _winapi
import itertools
import msvcrt
import os
import subprocess
import tempfile
import warnings


            

Reported by Pylint.

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

Line: 10 Column: 1

              
import _winapi
import itertools
import msvcrt
import os
import subprocess
import tempfile
import warnings


            

Reported by Pylint.

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

Line: 11 Column: 1

              import _winapi
import itertools
import msvcrt
import os
import subprocess
import tempfile
import warnings



            

Reported by Pylint.

standard import "import os" should be placed before "import _winapi"
Error

Line: 11 Column: 1

              import _winapi
import itertools
import msvcrt
import os
import subprocess
import tempfile
import warnings



            

Reported by Pylint.

Lib/idlelib/idle_test/test_zzdummy.py
34 issues
Instance of 'Text' has no 'undo_block_start' member
Error

Line: 65 Column: 9

                  def setUp(self):
        text = self.text
        text.insert('1.0', code_sample)
        text.undo_block_start.reset_mock()
        text.undo_block_stop.reset_mock()
        zz = self.zz = zzdummy.ZzDummy(self.editor)
        zzdummy.ZzDummy.ztext = '# ignore #'

    def tearDown(self):

            

Reported by Pylint.

Instance of 'Text' has no 'undo_block_stop' member
Error

Line: 66 Column: 9

                      text = self.text
        text.insert('1.0', code_sample)
        text.undo_block_start.reset_mock()
        text.undo_block_stop.reset_mock()
        zz = self.zz = zzdummy.ZzDummy(self.editor)
        zzdummy.ZzDummy.ztext = '# ignore #'

    def tearDown(self):
        self.text.delete('1.0', 'end')

            

Reported by Pylint.

No value for argument 'line' in method call
Error

Line: 108 Column: 12

                      eq(expected, actual)

        text.tag_add('sel', '2.0', '4.end')
        eq(zz.z_in_event(), 'break')
        expected = [False, True, True, True, False, False, False]
        actual = self.checklines(text, zz.ztext)
        eq(expected, actual)

        text.undo_block_start.assert_called_once()

            

Reported by Pylint.

No value for argument 'line' in method call
Error

Line: 124 Column: 9

              
        # Prepend text.
        text.tag_add('sel', '2.0', '5.end')
        zz.z_in_event()
        text.undo_block_start.reset_mock()
        text.undo_block_stop.reset_mock()

        # Select a few lines to remove text.
        text.tag_remove('sel', '1.0', 'end')

            

Reported by Pylint.

No value for argument 'line' in method call
Error

Line: 131 Column: 12

                      # Select a few lines to remove text.
        text.tag_remove('sel', '1.0', 'end')
        text.tag_add('sel', '3.0', '4.end')
        eq(zz.z_out_event(), 'break')
        expected = [False, True, False, False, True, False, False]
        actual = self.checklines(text, zz.ztext)
        eq(expected, actual)

        text.undo_block_start.assert_called_once()

            

Reported by Pylint.

No value for argument 'line' in method call
Error

Line: 145 Column: 9

                      text = zz.text

        text.tag_add('sel', '1.0', 'end-1c')
        zz.z_in_event()
        zz.z_out_event()

        self.assertEqual(text.get('1.0', 'end-1c'), code_sample)



            

Reported by Pylint.

No value for argument 'line' in method call
Error

Line: 146 Column: 9

              
        text.tag_add('sel', '1.0', 'end-1c')
        zz.z_in_event()
        zz.z_out_event()

        self.assertEqual(text.get('1.0', 'end-1c'), code_sample)


if __name__ == '__main__':

            

Reported by Pylint.

Redefining built-in 'format'
Error

Line: 10 Column: 1

              from unittest import mock
from idlelib import config
from idlelib import editor
from idlelib import format


usercfg = zzdummy.idleConf.userCfg
testcfg = {
    'main': config.IdleUserConfParser(''),

            

Reported by Pylint.

Redefining built-in 'id'
Error

Line: 57 Column: 13

                      zzdummy.idleConf.userCfg = usercfg
        del cls.editor, cls.text
        cls.root.update_idletasks()
        for id in cls.root.tk.call('after', 'info'):
            cls.root.after_cancel(id)  # Need for EditorWindow.
        cls.root.destroy()
        del cls.root

    def setUp(self):

            

Reported by Pylint.

Unused variable 'zz'
Error

Line: 67 Column: 9

                      text.insert('1.0', code_sample)
        text.undo_block_start.reset_mock()
        text.undo_block_stop.reset_mock()
        zz = self.zz = zzdummy.ZzDummy(self.editor)
        zzdummy.ZzDummy.ztext = '# ignore #'

    def tearDown(self):
        self.text.delete('1.0', 'end')
        del self.zz

            

Reported by Pylint.

Lib/importlib/_adapters.py
34 issues
Attempted relative import beyond top-level package
Error

Line: 4 Column: 1

              from contextlib import suppress
from io import TextIOWrapper

from . import abc


class SpecLoaderAdapter:
    """
    Adapt a package spec to adapt the underlying loader.

            

Reported by Pylint.

Unused argument 'name'
Error

Line: 28 Column: 35

                  def __init__(self, spec):
        self.spec = spec

    def get_resource_reader(self, name):
        return CompatibilityFiles(self.spec)._native()


def _io_wrapper(file, mode='r', *args, **kwargs):
    if mode == 'r':

            

Reported by Pylint.

Access to a protected member _native of a client class
Error

Line: 29 Column: 16

                      self.spec = spec

    def get_resource_reader(self, name):
        return CompatibilityFiles(self.spec)._native()


def _io_wrapper(file, mode='r', *args, **kwargs):
    if mode == 'r':
        return TextIOWrapper(file, *args, **kwargs)

            

Reported by Pylint.

Keyword argument before variable positional arguments list in the definition of _io_wrapper function
Error

Line: 32 Column: 1

                      return CompatibilityFiles(self.spec)._native()


def _io_wrapper(file, mode='r', *args, **kwargs):
    if mode == 'r':
        return TextIOWrapper(file, *args, **kwargs)
    elif mode == 'rb':
        return file
    raise ValueError(

            

Reported by Pylint.

Keyword argument before variable positional arguments list in the definition of open function
Error

Line: 80 Column: 9

                      def name(self):
            return self._spec.name

        def open(self, mode='r', *args, **kwargs):
            return _io_wrapper(self._reader.open_resource(None), mode, *args, **kwargs)

    class ChildPath(abc.Traversable):
        """
        Path tied to a resource reader child.

            

Reported by Pylint.

Keyword argument before variable positional arguments list in the definition of open function
Error

Line: 109 Column: 9

                      def name(self):
            return self._name

        def open(self, mode='r', *args, **kwargs):
            return _io_wrapper(
                self._reader.open_resource(self.name), mode, *args, **kwargs
            )

    class OrphanPath(abc.Traversable):

            

Reported by Pylint.

Keyword argument before variable positional arguments list in the definition of open function
Error

Line: 140 Column: 9

                      def name(self):
            return self._path[-1]

        def open(self, mode='r', *args, **kwargs):
            raise FileNotFoundError("Can't open orphan path")

    def __init__(self, spec):
        self.spec = spec


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from contextlib import suppress
from io import TextIOWrapper

from . import abc


class SpecLoaderAdapter:
    """
    Adapt a package spec to adapt the underlying loader.

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 7 Column: 1

              from . import abc


class SpecLoaderAdapter:
    """
    Adapt a package spec to adapt the underlying loader.
    """

    def __init__(self, spec, adapter=lambda spec: spec.loader):

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 20 Column: 1

                      return getattr(self.spec, name)


class TraversableResourcesLoader:
    """
    Adapt a loader to provide TraversableResources.
    """

    def __init__(self, spec):

            

Reported by Pylint.

Lib/idlelib/idle_test/test_tooltip.py
33 issues
Global variable 'root' undefined at the module level
Error

Line: 19 Column: 5

              

def setUpModule():
    global root
    root = Tk()

def tearDownModule():
    global root
    root.update_idletasks()

            

Reported by Pylint.

Global variable 'root' undefined at the module level
Error

Line: 23 Column: 5

                  root = Tk()

def tearDownModule():
    global root
    root.update_idletasks()
    root.destroy()
    del root



            

Reported by Pylint.

Global variable 'root' undefined at the module level
Error

Line: 39 Column: 5

              

def _make_top_and_button(testobj):
    global root
    top = Toplevel(root)
    testobj.addCleanup(top.destroy)
    top.title("Test tooltip")
    button = Button(top, text='ToolTip test button')
    button.pack()

            

Reported by Pylint.

Global variable 'root' undefined at the module level
Error

Line: 55 Column: 9

                      self.top, self.button = _make_top_and_button(self)

    def test_base_class_is_unusable(self):
        global root
        top = Toplevel(root)
        self.addCleanup(top.destroy)

        button = Button(top, text='ToolTip test button')
        button.pack()

            

Reported by Pylint.

standard import "from test.support import requires" should be placed before "from idlelib.tooltip import TooltipBase, Hovertip"
Error

Line: 9 Column: 1

              """

from idlelib.tooltip import TooltipBase, Hovertip
from test.support import requires
requires('gui')

from functools import wraps
import time
from tkinter import Button, Tk, Toplevel

            

Reported by Pylint.

standard import "from functools import wraps" should be placed before "from idlelib.tooltip import TooltipBase, Hovertip"
Error

Line: 12 Column: 1

              from test.support import requires
requires('gui')

from functools import wraps
import time
from tkinter import Button, Tk, Toplevel
import unittest



            

Reported by Pylint.

Import "from functools import wraps" should be placed at the top of the module
Error

Line: 12 Column: 1

              from test.support import requires
requires('gui')

from functools import wraps
import time
from tkinter import Button, Tk, Toplevel
import unittest



            

Reported by Pylint.

standard import "import time" should be placed before "from idlelib.tooltip import TooltipBase, Hovertip"
Error

Line: 13 Column: 1

              requires('gui')

from functools import wraps
import time
from tkinter import Button, Tk, Toplevel
import unittest


def setUpModule():

            

Reported by Pylint.

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

Line: 13 Column: 1

              requires('gui')

from functools import wraps
import time
from tkinter import Button, Tk, Toplevel
import unittest


def setUpModule():

            

Reported by Pylint.

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

Line: 14 Column: 1

              
from functools import wraps
import time
from tkinter import Button, Tk, Toplevel
import unittest


def setUpModule():
    global root

            

Reported by Pylint.