The following issues were found

Lib/lib2to3/pytree.py
101 issues
Attempted relative import beyond top-level package
Error

Line: 24 Column: 9

              def type_repr(type_num):
    global _type_reprs
    if not _type_reprs:
        from .pygram import python_symbols
        # printing tokens is possible but not as useful
        # from .pgen2 import token // token.__dict__.items():
        for name, val in python_symbols.__dict__.items():
            if type(val) == int: _type_reprs[val] = name
    return _type_reprs.setdefault(type_num, type_num)

            

Reported by Pylint.

__str__ does not return str
Error

Line: 204 Column: 9

                      return next_sib.prefix

    if sys.version_info < (3, 0):
        def __str__(self):
            return str(self).encode("ascii")

class Node(Base):

    """Concrete implementation for interior nodes."""

            

Reported by Pylint.

Instance of 'BasePattern' has no '_submatch' member
Error

Line: 471 Column: 20

                          r = None
            if results is not None:
                r = {}
            if not self._submatch(node, r):
                return False
            if r:
                results.update(r)
        if results is not None and self.name:
            results[self.name] = node

            

Reported by Pylint.

Using the global statement
Error

Line: 22 Column: 5

              
_type_reprs = {}
def type_repr(type_num):
    global _type_reprs
    if not _type_reprs:
        from .pygram import python_symbols
        # printing tokens is possible but not as useful
        # from .pgen2 import token // token.__dict__.items():
        for name, val in python_symbols.__dict__.items():

            

Reported by Pylint.

Unused argument 'args'
Error

Line: 49 Column: 1

                  was_changed = False
    was_checked = False

    def __new__(cls, *args, **kwds):
        """Constructor that prevents Base from being instantiated."""
        assert cls is not Base, "Cannot instantiate Base"
        return object.__new__(cls)

    def __eq__(self, other):

            

Reported by Pylint.

Unused argument 'kwds'
Error

Line: 49 Column: 1

                  was_changed = False
    was_checked = False

    def __new__(cls, *args, **kwds):
        """Constructor that prevents Base from being instantiated."""
        assert cls is not Base, "Cannot instantiate Base"
        return object.__new__(cls)

    def __eq__(self, other):

            

Reported by Pylint.

Redefining built-in 'type'
Error

Line: 211 Column: 23

              
    """Concrete implementation for interior nodes."""

    def __init__(self,type, children,
                 context=None,
                 prefix=None,
                 fixers_applied=None):
        """
        Initializer.

            

Reported by Pylint.

Unused argument 'context'
Error

Line: 212 Column: 18

                  """Concrete implementation for interior nodes."""

    def __init__(self,type, children,
                 context=None,
                 prefix=None,
                 fixers_applied=None):
        """
        Initializer.


            

Reported by Pylint.

Dangerous default value [] as argument
Error

Line: 326 Column: 5

                  lineno = 0    # Line where this token starts in the input
    column = 0    # Column where this token tarts in the input

    def __init__(self, type, value,
                 context=None,
                 prefix=None,
                 fixers_applied=[]):
        """
        Initializer.

            

Reported by Pylint.

Redefining built-in 'type'
Error

Line: 326 Column: 24

                  lineno = 0    # Line where this token starts in the input
    column = 0    # Column where this token tarts in the input

    def __init__(self, type, value,
                 context=None,
                 prefix=None,
                 fixers_applied=[]):
        """
        Initializer.

            

Reported by Pylint.

Lib/ctypes/test/test_bytes.py
101 issues
Unused import c_int16 from wildcard import
Error

Line: 4 Column: 1

              """Test where byte objects are accepted"""
import unittest
import sys
from ctypes import *

class BytesTest(unittest.TestCase):
    def test_c_char(self):
        x = c_char(b"x")
        self.assertRaises(TypeError, c_char, "x")

            

Reported by Pylint.

Wildcard import ctypes
Error

Line: 4 Column: 1

              """Test where byte objects are accepted"""
import unittest
import sys
from ctypes import *

class BytesTest(unittest.TestCase):
    def test_c_char(self):
        x = c_char(b"x")
        self.assertRaises(TypeError, c_char, "x")

            

Reported by Pylint.

Unused import LittleEndianStructure from wildcard import
Error

Line: 4 Column: 1

              """Test where byte objects are accepted"""
import unittest
import sys
from ctypes import *

class BytesTest(unittest.TestCase):
    def test_c_char(self):
        x = c_char(b"x")
        self.assertRaises(TypeError, c_char, "x")

            

Reported by Pylint.

Unused import get_last_error from wildcard import
Error

Line: 4 Column: 1

              """Test where byte objects are accepted"""
import unittest
import sys
from ctypes import *

class BytesTest(unittest.TestCase):
    def test_c_char(self):
        x = c_char(b"x")
        self.assertRaises(TypeError, c_char, "x")

            

Reported by Pylint.

Unused import pointer from wildcard import
Error

Line: 4 Column: 1

              """Test where byte objects are accepted"""
import unittest
import sys
from ctypes import *

class BytesTest(unittest.TestCase):
    def test_c_char(self):
        x = c_char(b"x")
        self.assertRaises(TypeError, c_char, "x")

            

Reported by Pylint.

Unused import POINTER from wildcard import
Error

Line: 4 Column: 1

              """Test where byte objects are accepted"""
import unittest
import sys
from ctypes import *

class BytesTest(unittest.TestCase):
    def test_c_char(self):
        x = c_char(b"x")
        self.assertRaises(TypeError, c_char, "x")

            

Reported by Pylint.

Unused import set_errno from wildcard import
Error

Line: 4 Column: 1

              """Test where byte objects are accepted"""
import unittest
import sys
from ctypes import *

class BytesTest(unittest.TestCase):
    def test_c_char(self):
        x = c_char(b"x")
        self.assertRaises(TypeError, c_char, "x")

            

Reported by Pylint.

Unused import get_errno from wildcard import
Error

Line: 4 Column: 1

              """Test where byte objects are accepted"""
import unittest
import sys
from ctypes import *

class BytesTest(unittest.TestCase):
    def test_c_char(self):
        x = c_char(b"x")
        self.assertRaises(TypeError, c_char, "x")

            

Reported by Pylint.

Unused import resize from wildcard import
Error

Line: 4 Column: 1

              """Test where byte objects are accepted"""
import unittest
import sys
from ctypes import *

class BytesTest(unittest.TestCase):
    def test_c_char(self):
        x = c_char(b"x")
        self.assertRaises(TypeError, c_char, "x")

            

Reported by Pylint.

Unused import alignment from wildcard import
Error

Line: 4 Column: 1

              """Test where byte objects are accepted"""
import unittest
import sys
from ctypes import *

class BytesTest(unittest.TestCase):
    def test_c_char(self):
        x = c_char(b"x")
        self.assertRaises(TypeError, c_char, "x")

            

Reported by Pylint.

Lib/distutils/dist.py
100 issues
Non-iterable value self.script_args is used in an iterating context
Error

Line: 285 Column: 24

                      self.want_user_cfg = True

        if self.script_args is not None:
            for arg in self.script_args:
                if not arg.startswith('-'):
                    break
                if arg == '--no-user-cfg':
                    self.want_user_cfg = False
                    break

            

Reported by Pylint.

Instance of 'Distribution' has no 'help_commands' member
Error

Line: 682 Column: 12

                      # User just wants a list of commands -- we'll print it out and stop
        # processing now (ie. if they ran "setup --help-commands foo bar",
        # we ignore "foo bar").
        if self.help_commands:
            self.print_commands()
            print('')
            print(gen_usage(self.script_name))
            return 1


            

Reported by Pylint.

Unused import DistutilsGetoptError from wildcard import
Error

Line: 17 Column: 1

              except ImportError:
    warnings = None

from distutils.errors import *
from distutils.fancy_getopt import FancyGetopt, translate_longopt
from distutils.util import check_environ, strtobool, rfc822_escape
from distutils import log
from distutils.debug import DEBUG


            

Reported by Pylint.

Unused import DistutilsFileError from wildcard import
Error

Line: 17 Column: 1

              except ImportError:
    warnings = None

from distutils.errors import *
from distutils.fancy_getopt import FancyGetopt, translate_longopt
from distutils.util import check_environ, strtobool, rfc822_escape
from distutils import log
from distutils.debug import DEBUG


            

Reported by Pylint.

Unused import DistutilsSetupError from wildcard import
Error

Line: 17 Column: 1

              except ImportError:
    warnings = None

from distutils.errors import *
from distutils.fancy_getopt import FancyGetopt, translate_longopt
from distutils.util import check_environ, strtobool, rfc822_escape
from distutils import log
from distutils.debug import DEBUG


            

Reported by Pylint.

Unused import DistutilsPlatformError from wildcard import
Error

Line: 17 Column: 1

              except ImportError:
    warnings = None

from distutils.errors import *
from distutils.fancy_getopt import FancyGetopt, translate_longopt
from distutils.util import check_environ, strtobool, rfc822_escape
from distutils import log
from distutils.debug import DEBUG


            

Reported by Pylint.

Unused import DistutilsExecError from wildcard import
Error

Line: 17 Column: 1

              except ImportError:
    warnings = None

from distutils.errors import *
from distutils.fancy_getopt import FancyGetopt, translate_longopt
from distutils.util import check_environ, strtobool, rfc822_escape
from distutils import log
from distutils.debug import DEBUG


            

Reported by Pylint.

Unused import DistutilsInternalError from wildcard import
Error

Line: 17 Column: 1

              except ImportError:
    warnings = None

from distutils.errors import *
from distutils.fancy_getopt import FancyGetopt, translate_longopt
from distutils.util import check_environ, strtobool, rfc822_escape
from distutils import log
from distutils.debug import DEBUG


            

Reported by Pylint.

Unused import DistutilsTemplateError from wildcard import
Error

Line: 17 Column: 1

              except ImportError:
    warnings = None

from distutils.errors import *
from distutils.fancy_getopt import FancyGetopt, translate_longopt
from distutils.util import check_environ, strtobool, rfc822_escape
from distutils import log
from distutils.debug import DEBUG


            

Reported by Pylint.

Unused import DistutilsByteCompileError from wildcard import
Error

Line: 17 Column: 1

              except ImportError:
    warnings = None

from distutils.errors import *
from distutils.fancy_getopt import FancyGetopt, translate_longopt
from distutils.util import check_environ, strtobool, rfc822_escape
from distutils import log
from distutils.debug import DEBUG


            

Reported by Pylint.

Lib/test/test_asyncio/test_subprocess.py
100 issues
Module 'subprocess' has no 'create_subprocess_exec' member
Error

Line: 597 Column: 23

                  def test_create_subprocess_exec_text_mode_fails(self):
        async def execute():
            with self.assertRaises(ValueError):
                await subprocess.create_subprocess_exec(sys.executable,
                                                        text=True)

            with self.assertRaises(ValueError):
                await subprocess.create_subprocess_exec(sys.executable,
                                                        encoding="utf-8")

            

Reported by Pylint.

Module 'subprocess' has no 'create_subprocess_exec' member
Error

Line: 601 Column: 23

                                                                      text=True)

            with self.assertRaises(ValueError):
                await subprocess.create_subprocess_exec(sys.executable,
                                                        encoding="utf-8")

            with self.assertRaises(ValueError):
                await subprocess.create_subprocess_exec(sys.executable,
                                                        errors="strict")

            

Reported by Pylint.

Module 'subprocess' has no 'create_subprocess_exec' member
Error

Line: 605 Column: 23

                                                                      encoding="utf-8")

            with self.assertRaises(ValueError):
                await subprocess.create_subprocess_exec(sys.executable,
                                                        errors="strict")

        self.loop.run_until_complete(execute())

    def test_create_subprocess_shell_text_mode_fails(self):

            

Reported by Pylint.

Module 'subprocess' has no 'create_subprocess_shell' member
Error

Line: 614 Column: 23

              
        async def execute():
            with self.assertRaises(ValueError):
                await subprocess.create_subprocess_shell(sys.executable,
                                                         text=True)

            with self.assertRaises(ValueError):
                await subprocess.create_subprocess_shell(sys.executable,
                                                         encoding="utf-8")

            

Reported by Pylint.

Module 'subprocess' has no 'create_subprocess_shell' member
Error

Line: 618 Column: 23

                                                                       text=True)

            with self.assertRaises(ValueError):
                await subprocess.create_subprocess_shell(sys.executable,
                                                         encoding="utf-8")

            with self.assertRaises(ValueError):
                await subprocess.create_subprocess_shell(sys.executable,
                                                         errors="strict")

            

Reported by Pylint.

Module 'subprocess' has no 'create_subprocess_shell' member
Error

Line: 622 Column: 23

                                                                       encoding="utf-8")

            with self.assertRaises(ValueError):
                await subprocess.create_subprocess_shell(sys.executable,
                                                         errors="strict")

        self.loop.run_until_complete(execute())

    def test_create_subprocess_exec_with_path(self):

            

Reported by Pylint.

Module 'subprocess' has no 'create_subprocess_exec' member
Error

Line: 629 Column: 23

              
    def test_create_subprocess_exec_with_path(self):
        async def execute():
            p = await subprocess.create_subprocess_exec(
                os_helper.FakePath(sys.executable), '-c', 'pass')
            await p.wait()
            p = await subprocess.create_subprocess_exec(
                sys.executable, '-c', 'pass', os_helper.FakePath('.'))
            await p.wait()

            

Reported by Pylint.

Module 'subprocess' has no 'create_subprocess_exec' member
Error

Line: 632 Column: 23

                          p = await subprocess.create_subprocess_exec(
                os_helper.FakePath(sys.executable), '-c', 'pass')
            await p.wait()
            p = await subprocess.create_subprocess_exec(
                sys.executable, '-c', 'pass', os_helper.FakePath('.'))
            await p.wait()

        self.assertIsNone(self.loop.run_until_complete(execute()))


            

Reported by Pylint.

self.Watcher is not callable
Error

Line: 651 Column: 23

                          self.loop = policy.new_event_loop()
            self.set_event_loop(self.loop)

            watcher = self.Watcher()
            watcher.attach_loop(self.loop)
            policy.set_child_watcher(watcher)

        def tearDown(self):
            super().tearDown()

            

Reported by Pylint.

Module 'os' has no 'pidfd_open' member
Error

Line: 689 Column: 22

                      if not hasattr(os, 'pidfd_open'):
            return False
        try:
            os.close(os.pidfd_open(os.getpid()))
        except OSError:
            return False
        return True

    @unittest.skipUnless(

            

Reported by Pylint.

Lib/ctypes/test/test_funcptr.py
100 issues
Unused import BigEndianStructure from wildcard import
Error

Line: 2 Column: 1

              import unittest
from ctypes import *

try:
    WINFUNCTYPE
except NameError:
    # fake to enable this test on Linux
    WINFUNCTYPE = CFUNCTYPE


            

Reported by Pylint.

Unused import DllCanUnloadNow from wildcard import
Error

Line: 2 Column: 1

              import unittest
from ctypes import *

try:
    WINFUNCTYPE
except NameError:
    # fake to enable this test on Linux
    WINFUNCTYPE = CFUNCTYPE


            

Reported by Pylint.

Unused import c_int8 from wildcard import
Error

Line: 2 Column: 1

              import unittest
from ctypes import *

try:
    WINFUNCTYPE
except NameError:
    # fake to enable this test on Linux
    WINFUNCTYPE = CFUNCTYPE


            

Reported by Pylint.

Unused import c_uint8 from wildcard import
Error

Line: 2 Column: 1

              import unittest
from ctypes import *

try:
    WINFUNCTYPE
except NameError:
    # fake to enable this test on Linux
    WINFUNCTYPE = CFUNCTYPE


            

Reported by Pylint.

Unused import kind from wildcard import
Error

Line: 2 Column: 1

              import unittest
from ctypes import *

try:
    WINFUNCTYPE
except NameError:
    # fake to enable this test on Linux
    WINFUNCTYPE = CFUNCTYPE


            

Reported by Pylint.

Unused import c_int16 from wildcard import
Error

Line: 2 Column: 1

              import unittest
from ctypes import *

try:
    WINFUNCTYPE
except NameError:
    # fake to enable this test on Linux
    WINFUNCTYPE = CFUNCTYPE


            

Reported by Pylint.

Unused import c_int32 from wildcard import
Error

Line: 2 Column: 1

              import unittest
from ctypes import *

try:
    WINFUNCTYPE
except NameError:
    # fake to enable this test on Linux
    WINFUNCTYPE = CFUNCTYPE


            

Reported by Pylint.

Unused import c_int64 from wildcard import
Error

Line: 2 Column: 1

              import unittest
from ctypes import *

try:
    WINFUNCTYPE
except NameError:
    # fake to enable this test on Linux
    WINFUNCTYPE = CFUNCTYPE


            

Reported by Pylint.

Unused import c_double from wildcard import
Error

Line: 2 Column: 1

              import unittest
from ctypes import *

try:
    WINFUNCTYPE
except NameError:
    # fake to enable this test on Linux
    WINFUNCTYPE = CFUNCTYPE


            

Reported by Pylint.

Unused import c_float from wildcard import
Error

Line: 2 Column: 1

              import unittest
from ctypes import *

try:
    WINFUNCTYPE
except NameError:
    # fake to enable this test on Linux
    WINFUNCTYPE = CFUNCTYPE


            

Reported by Pylint.

Lib/test/test_enumerate.py
100 issues
__iter__ returns non-iterator
Error

Line: 64 Column: 5

                  def __init__(self, seqn):
        self.seqn = seqn
        self.i = 0
    def __iter__(self):
        return self

class PickleTest:
    # Helper to check picklability
    def check_pickle(self, itorg, seq):

            

Reported by Pylint.

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

Line: 73 Column: 13

                      for proto in range(pickle.HIGHEST_PROTOCOL + 1):
            d = pickle.dumps(itorg, proto)
            it = pickle.loads(d)
            self.assertEqual(type(itorg), type(it))
            self.assertEqual(list(it), seq)

            it = pickle.loads(d)
            try:
                next(it)

            

Reported by Pylint.

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

Line: 74 Column: 13

                          d = pickle.dumps(itorg, proto)
            it = pickle.loads(d)
            self.assertEqual(type(itorg), type(it))
            self.assertEqual(list(it), seq)

            it = pickle.loads(d)
            try:
                next(it)
            except StopIteration:

            

Reported by Pylint.

Instance of 'PickleTest' has no 'assertFalse' member
Error

Line: 80 Column: 17

                          try:
                next(it)
            except StopIteration:
                self.assertFalse(seq[1:])
                continue
            d = pickle.dumps(it, proto)
            it = pickle.loads(d)
            self.assertEqual(list(it), seq[1:])


            

Reported by Pylint.

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

Line: 84 Column: 13

                              continue
            d = pickle.dumps(it, proto)
            it = pickle.loads(d)
            self.assertEqual(list(it), seq[1:])

class EnumerateTestCase(unittest.TestCase, PickleTest):

    enum = enumerate
    seq, res = 'abc', [(0,'a'), (1,'b'), (2,'c')]

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 57 Column: 9

                  def __iter__(self):
        return self
    def __next__(self):
        3 // 0

class N:
    'Iterator missing __next__()'
    def __init__(self, seqn):
        self.seqn = seqn

            

Reported by Pylint.

Pickle and modules that wrap it can be unsafe when used to deserialize untrusted data, possible security issue.
Security blacklist

Line: 72
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b301-pickle

                  def check_pickle(self, itorg, seq):
        for proto in range(pickle.HIGHEST_PROTOCOL + 1):
            d = pickle.dumps(itorg, proto)
            it = pickle.loads(d)
            self.assertEqual(type(itorg), type(it))
            self.assertEqual(list(it), seq)

            it = pickle.loads(d)
            try:

            

Reported by Bandit.

Pickle and modules that wrap it can be unsafe when used to deserialize untrusted data, possible security issue.
Security blacklist

Line: 76
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b301-pickle

                          self.assertEqual(type(itorg), type(it))
            self.assertEqual(list(it), seq)

            it = pickle.loads(d)
            try:
                next(it)
            except StopIteration:
                self.assertFalse(seq[1:])
                continue

            

Reported by Bandit.

Pickle and modules that wrap it can be unsafe when used to deserialize untrusted data, possible security issue.
Security blacklist

Line: 83
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b301-pickle

                              self.assertFalse(seq[1:])
                continue
            d = pickle.dumps(it, proto)
            it = pickle.loads(d)
            self.assertEqual(list(it), seq[1:])

class EnumerateTestCase(unittest.TestCase, PickleTest):

    enum = enumerate

            

Reported by Bandit.

Statement seems to have no effect
Error

Line: 96 Column: 9

                      e = self.enum(self.seq)
        self.assertEqual(iter(e), e)
        self.assertEqual(list(self.enum(self.seq)), self.res)
        self.enum.__doc__

    def test_pickle(self):
        self.check_pickle(self.enum(self.seq), self.res)

    def test_getitemseqn(self):

            

Reported by Pylint.

Lib/modulefinder.py
99 issues
Redefining built-in 'str'
Error

Line: 136 Column: 26

                      self.replace_paths = replace_paths if replace_paths is not None else []
        self.processed_paths = []   # Used in debugging only

    def msg(self, level, str, *args):
        if level <= self.debug:
            for i in range(self.indent):
                print("   ", end=' ')
            print(str, end=' ')
            for arg in args:

            

Reported by Pylint.

Unused variable 'i'
Error

Line: 138 Column: 17

              
    def msg(self, level, str, *args):
        if level <= self.debug:
            for i in range(self.indent):
                print("   ", end=' ')
            print(str, end=' ')
            for arg in args:
                print(repr(arg), end=' ')
            print()

            

Reported by Pylint.

Redefining built-in 'dir'
Error

Line: 164 Column: 9

                          self.load_module('__main__', fp, pathname, stuff)

    def load_file(self, pathname):
        dir, name = os.path.split(pathname)
        name, ext = os.path.splitext(name)
        with io.open_code(pathname) as fp:
            stuff = (ext, "rb", _PY_SOURCE)
            self.load_module(name, fp, pathname, stuff)


            

Reported by Pylint.

Unused variable 'dir'
Error

Line: 164 Column: 9

                          self.load_module('__main__', fp, pathname, stuff)

    def load_file(self, pathname):
        dir, name = os.path.split(pathname)
        name, ext = os.path.splitext(name)
        with io.open_code(pathname) as fp:
            stuff = (ext, "rb", _PY_SOURCE)
            self.load_module(name, fp, pathname, stuff)


            

Reported by Pylint.

Redefining built-in 'all'
Error

Line: 263 Column: 21

                      for sub in fromlist:
            if sub == "*":
                if not recursive:
                    all = self.find_all_submodules(m)
                    if all:
                        self.ensure_fromlist(m, all, 1)
            elif not hasattr(m, sub):
                subname = "%s.%s" % (m.__name__, sub)
                submod = self.import_module(sub, subname, m)

            

Reported by Pylint.

Redefining built-in 'dir'
Error

Line: 283 Column: 13

                      suffixes += importlib.machinery.EXTENSION_SUFFIXES[:]
        suffixes += importlib.machinery.SOURCE_SUFFIXES[:]
        suffixes += importlib.machinery.BYTECODE_SUFFIXES[:]
        for dir in m.__path__:
            try:
                names = os.listdir(dir)
            except OSError:
                self.msg(2, "can't list directory", dir)
                continue

            

Reported by Pylint.

Redefining built-in 'type'
Error

Line: 333 Column: 23

                      return m

    def load_module(self, fqname, fp, pathname, file_info):
        suffix, mode, type = file_info
        self.msgin(2, "load_module", fqname, fp and "fp", pathname)
        if type == _PKG_DIRECTORY:
            m = self.load_package(fqname, pathname)
            self.msgout(2, "load_module ->", m)
            return m

            

Reported by Pylint.

Unused variable 'mode'
Error

Line: 333 Column: 17

                      return m

    def load_module(self, fqname, fp, pathname, file_info):
        suffix, mode, type = file_info
        self.msgin(2, "load_module", fqname, fp and "fp", pathname)
        if type == _PKG_DIRECTORY:
            m = self.load_package(fqname, pathname)
            self.msgout(2, "load_module ->", m)
            return m

            

Reported by Pylint.

Unused variable 'suffix'
Error

Line: 333 Column: 9

                      return m

    def load_module(self, fqname, fp, pathname, file_info):
        suffix, mode, type = file_info
        self.msgin(2, "load_module", fqname, fp and "fp", pathname)
        if type == _PKG_DIRECTORY:
            m = self.load_package(fqname, pathname)
            self.msgout(2, "load_module ->", m)
            return m

            

Reported by Pylint.

Access to a protected member _bootstrap_external of a client class
Error

Line: 344 Column: 17

                      elif type == _PY_COMPILED:
            try:
                data = fp.read()
                importlib._bootstrap_external._classify_pyc(data, fqname, {})
            except ImportError as exc:
                self.msgout(2, "raise ImportError: " + str(exc), pathname)
                raise
            co = marshal.loads(memoryview(data)[16:])
        else:

            

Reported by Pylint.

Lib/test/test_support.py
99 issues
Instance of 'Obj' has no 'y' member; maybe 'x'?
Error

Line: 368 Column: 30

                          self.assertEqual(x, 1)
        self.assertEqual(obj.x, 1)
        with support.swap_attr(obj, "y", 5) as y:
            self.assertEqual(obj.y, 5)
            self.assertIsNone(y)
        self.assertFalse(hasattr(obj, 'y'))
        with support.swap_attr(obj, "y", 5):
            del obj.y
        self.assertFalse(hasattr(obj, 'y'))

            

Reported by Pylint.

Instance of 'Obj' has no 'y' member; maybe 'x'?
Error

Line: 372 Column: 17

                          self.assertIsNone(y)
        self.assertFalse(hasattr(obj, 'y'))
        with support.swap_attr(obj, "y", 5):
            del obj.y
        self.assertFalse(hasattr(obj, 'y'))

    def test_swap_item(self):
        D = {"x":1}
        with support.swap_item(D, "x", 5) as x:

            

Reported by Pylint.

Access to a protected member _warn_about_deprecation of a client class
Error

Line: 50 Column: 13

                  def test_ignored_deprecations_are_silent(self):
        """Test support.ignore_deprecations_from() silences warnings"""
        with warnings.catch_warnings(record=True) as warning_objs:
            warnings_helper._warn_about_deprecation()
            warnings.warn("You should NOT be seeing this.", DeprecationWarning)
            messages = [str(w.message) for w in warning_objs]
        self.assertEqual(len(messages), 0, messages)

    def test_import_module(self):

            

Reported by Pylint.

Unused import sched
Error

Line: 73 Column: 9

                      self.assertEqual(support.get_original_stdout(), sys.stdout)

    def test_unload(self):
        import sched
        self.assertIn("sched", sys.modules)
        import_helper.unload("sched")
        self.assertNotIn("sched", sys.modules)

    def test_unlink(self):

            

Reported by Pylint.

Unused variable 'f'
Error

Line: 79 Column: 53

                      self.assertNotIn("sched", sys.modules)

    def test_unlink(self):
        with open(TESTFN, "w", encoding="utf-8") as f:
            pass
        os_helper.unlink(TESTFN)
        self.assertFalse(os.path.exists(TESTFN))
        os_helper.unlink(TESTFN)


            

Reported by Pylint.

Unused variable 'mod'
Error

Line: 116 Column: 13

                      sys.path.insert(0, os.curdir)
        importlib.invalidate_caches()
        try:
            mod = __import__(TESTFN)
            self.assertIn(TESTFN, sys.modules)

            import_helper.forget(TESTFN)
            self.assertNotIn(TESTFN, sys.modules)
        finally:

            

Reported by Pylint.

Unused variable 'temp_path'
Error

Line: 167 Column: 46

                  def test_temp_dir__existing_dir__quiet_default(self):
        """Test passing a directory that already exists."""
        def call_temp_dir(path):
            with os_helper.temp_dir(path) as temp_path:
                raise Exception("should not get here")

        path = tempfile.mkdtemp()
        path = os.path.realpath(path)
        try:

            

Reported by Pylint.

Redefining name 'warnings' from outer scope (line 14)
Error

Line: 189 Column: 17

                          with warnings_helper.check_warnings() as recorder:
                with os_helper.temp_dir(path, quiet=True) as temp_path:
                    self.assertEqual(path, temp_path)
                warnings = [str(w.message) for w in recorder.warnings]
            # Make sure temp_dir did not delete the original directory.
            self.assertTrue(os.path.isdir(path))
        finally:
            shutil.rmtree(path)


            

Reported by Pylint.

Unused variable 'new_cwd'
Error

Line: 243 Column: 48

                      original_cwd = os.getcwd()

        def call_change_cwd(path):
            with os_helper.change_cwd(path) as new_cwd:
                raise Exception("should not get here")

        with os_helper.temp_dir() as parent_dir:
            non_existent_dir = os.path.join(parent_dir, 'does_not_exist')
            self.assertRaises(FileNotFoundError, call_change_cwd,

            

Reported by Pylint.

Redefining name 'warnings' from outer scope (line 14)
Error

Line: 263 Column: 17

                              with os_helper.change_cwd(bad_dir, quiet=True) as new_cwd:
                    self.assertEqual(new_cwd, original_cwd)
                    self.assertEqual(os.getcwd(), new_cwd)
                warnings = [str(w.message) for w in recorder.warnings]

        self.assertEqual(len(warnings), 1, warnings)
        warn = warnings[0]
        self.assertTrue(warn.startswith(f'tests may fail, unable to change '
                                        f'the current working directory '

            

Reported by Pylint.

Lib/http/client.py
98 issues
Class 'HTTPStatus' has no '__members__' member
Error

Line: 103 Column: 18

              

# hack to maintain backwards compatibility
globals().update(http.HTTPStatus.__members__)

# another hack to maintain backwards compatibility
# Mapping status codes to official W3C names
responses = {v: v.phrase for v in http.HTTPStatus.__members__.values()}


            

Reported by Pylint.

Class 'HTTPStatus' has no '__members__' member
Error

Line: 107 Column: 35

              
# another hack to maintain backwards compatibility
# Mapping status codes to official W3C names
responses = {v: v.phrase for v in http.HTTPStatus.__members__.values()}

# maximal line length when calling readline().
_MAXLINE = 65536
_MAXHEADERS = 100


            

Reported by Pylint.

Undefined variable 'CONTINUE'
Error

Line: 318 Column: 26

                      # read until we get a non-100 response
        while True:
            version, status, reason = self._read_status()
            if status != CONTINUE:
                break
            # skip the header from the 100 response
            skipped_headers = _read_headers(self.fp)
            if self.debuglevel > 0:
                print("headers:", skipped_headers)

            

Reported by Pylint.

Undefined variable 'NOT_MODIFIED'
Error

Line: 369 Column: 47

                          self.length = None

        # does the body have a fixed length? (of zero)
        if (status == NO_CONTENT or status == NOT_MODIFIED or
            100 <= status < 200 or      # 1xx codes
            self._method == "HEAD"):
            self.length = 0

        # if the connection remains open, and we aren't using chunked, and

            

Reported by Pylint.

Undefined variable 'NO_CONTENT'
Error

Line: 369 Column: 23

                          self.length = None

        # does the body have a fixed length? (of zero)
        if (status == NO_CONTENT or status == NOT_MODIFIED or
            100 <= status < 200 or      # 1xx codes
            self._method == "HEAD"):
            self.length = 0

        # if the connection remains open, and we aren't using chunked, and

            

Reported by Pylint.

Instance of 'HTTPResponse' has no 'url' member
Error

Line: 779 Column: 16

                      redirected URL.

        '''
        return self.url

    def getcode(self):
        '''Return the HTTP status code that was sent with the response,
        or None if the URL is not an HTTP URL.


            

Reported by Pylint.

XXX The only usage of this method is in
Error

Line: 176 Column: 3

              

class HTTPMessage(email.message.Message):
    # XXX The only usage of this method is in
    # http.server.CGIHTTPRequestHandler.  Maybe move the code there so
    # that it doesn't need to be part of the public API.  The API has
    # never been defined so this could cause backwards compatibility
    # issues.


            

Reported by Pylint.

__init__ method from base class 'BufferedIOBase' is not called
Error

Line: 247 Column: 5

                  # text following RFC 2047.  The basic status line parsing only
    # accepts iso-8859-1.

    def __init__(self, sock, debuglevel=0, method=None, url=None):
        # If the response includes a content-length header, we need to
        # make sure that the client doesn't read more than the
        # specified number of bytes.  If it does, it will block until
        # the server times out and closes the connection.  This will
        # happen if a self.fp.read() is done (without a size) whether

            

Reported by Pylint.

Unused argument 'url'
Error

Line: 247 Column: 57

                  # text following RFC 2047.  The basic status line parsing only
    # accepts iso-8859-1.

    def __init__(self, sock, debuglevel=0, method=None, url=None):
        # If the response includes a content-length header, we need to
        # make sure that the client doesn't read more than the
        # specified number of bytes.  If it does, it will block until
        # the server times out and closes the connection.  This will
        # happen if a self.fp.read() is done (without a size) whether

            

Reported by Pylint.

Consider explicitly re-raising using the 'from' keyword
Error

Line: 307 Column: 13

                          if status < 100 or status > 999:
                raise BadStatusLine(line)
        except ValueError:
            raise BadStatusLine(line)
        return version, status, reason

    def begin(self):
        if self.headers is not None:
            # we've already started reading the response

            

Reported by Pylint.

Lib/test/test_augassign.py
98 issues
Method should have "self" as first argument
Error

Line: 118 Column: 5

                          x += 10


    def testCustomMethods2(test_self):
        output = []

        class testall:
            def __add__(self, val):
                output.append("__add__ called")

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 231 Column: 9

                              return self

        x = testall()
        x + 1
        1 + x
        x += 1

        x - 1
        1 - x

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 232 Column: 9

              
        x = testall()
        x + 1
        1 + x
        x += 1

        x - 1
        1 - x
        x -= 1

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 235 Column: 9

                      1 + x
        x += 1

        x - 1
        1 - x
        x -= 1

        x * 1
        1 * x

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 236 Column: 9

                      x += 1

        x - 1
        1 - x
        x -= 1

        x * 1
        1 * x
        x *= 1

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 239 Column: 9

                      1 - x
        x -= 1

        x * 1
        1 * x
        x *= 1

        x @ 1
        1 @ x

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 240 Column: 9

                      x -= 1

        x * 1
        1 * x
        x *= 1

        x @ 1
        1 @ x
        x @= 1

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 243 Column: 9

                      1 * x
        x *= 1

        x @ 1
        1 @ x
        x @= 1

        x / 1
        1 / x

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 244 Column: 9

                      x *= 1

        x @ 1
        1 @ x
        x @= 1

        x / 1
        1 / x
        x /= 1

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 247 Column: 9

                      1 @ x
        x @= 1

        x / 1
        1 / x
        x /= 1

        x // 1
        1 // x

            

Reported by Pylint.