The following issues were found

Lib/test/test_imp.py
68 issues
Unused variable 'i'
Error

Line: 42 Column: 13

                      lock_held_at_start = imp.lock_held()
        self.verify_lock_state(lock_held_at_start)

        for i in range(LOOPS):
            imp.acquire_lock()
            self.verify_lock_state(True)

        for i in range(LOOPS):
            imp.release_lock()

            

Reported by Pylint.

Unused variable 'encoding'
Error

Line: 68 Column: 22

                      self.test_path = mod.__path__

    def test_import_encoded_module(self):
        for modname, encoding, teststr in self.test_strings:
            mod = importlib.import_module('test.encoded_modules.'
                                          'module_' + modname)
            self.assertEqual(teststr, mod.test)

    def test_find_module_encoding(self):

            

Reported by Pylint.

Unused variable 'info'
Error

Line: 84 Column: 27

              
    def test_issue1267(self):
        for mod, encoding, _ in self.test_strings:
            fp, filename, info  = imp.find_module('module_' + mod,
                                                  self.test_path)
            with fp:
                self.assertNotEqual(fp, None)
                self.assertEqual(fp.encoding, encoding)
                self.assertEqual(fp.tell(), 0)

            

Reported by Pylint.

Unused variable 'filename'
Error

Line: 84 Column: 17

              
    def test_issue1267(self):
        for mod, encoding, _ in self.test_strings:
            fp, filename, info  = imp.find_module('module_' + mod,
                                                  self.test_path)
            with fp:
                self.assertNotEqual(fp, None)
                self.assertEqual(fp.encoding, encoding)
                self.assertEqual(fp.tell(), 0)

            

Reported by Pylint.

Unused variable 'info'
Error

Line: 107 Column: 29

                      try:
            with open(temp_mod_name + '.py', 'w', encoding="latin-1") as file:
                file.write("# coding: cp1252\nu = 'test.test_imp'\n")
            file, filename, info = imp.find_module(temp_mod_name)
            file.close()
            self.assertEqual(file.encoding, 'cp1252')
        finally:
            del sys.path[0]
            os_helper.unlink(temp_mod_name + '.py')

            

Reported by Pylint.

Unused variable 'filename'
Error

Line: 107 Column: 19

                      try:
            with open(temp_mod_name + '.py', 'w', encoding="latin-1") as file:
                file.write("# coding: cp1252\nu = 'test.test_imp'\n")
            file, filename, info = imp.find_module(temp_mod_name)
            file.close()
            self.assertEqual(file.encoding, 'cp1252')
        finally:
            del sys.path[0]
            os_helper.unlink(temp_mod_name + '.py')

            

Reported by Pylint.

XXX (ncoghlan): It would be nice to use import_helper.CleanImport
Error

Line: 209 Column: 3

              
    def test_load_from_source(self):
        # Verify that the imp module can correctly load and find .py files
        # XXX (ncoghlan): It would be nice to use import_helper.CleanImport
        # here, but that breaks because the os module registers some
        # handlers in copy_reg on import. Since CleanImport doesn't
        # revert that registration, the module is left in a broken
        # state after reversion. Reinitialising the module contents
        # and just reverting os.environ to its previous state is an OK

            

Reported by Pylint.

Unused variable 'description'
Error

Line: 242 Column: 28

                  def test_issue16421_multiple_modules_in_one_dll(self):
        # Issue 16421: loading several modules from the same compiled file fails
        m = '_testimportmultiple'
        fileobj, pathname, description = imp.find_module(m)
        fileobj.close()
        mod0 = imp.load_dynamic(m, pathname)
        mod1 = imp.load_dynamic('_testimportmultiple_foo', pathname)
        mod2 = imp.load_dynamic('_testimportmultiple_bar', pathname)
        self.assertEqual(mod0.__name__, m)

            

Reported by Pylint.

Access to a protected member _LoadSourceCompatibility of a client class
Error

Line: 312 Column: 18

              
    def test_multiple_calls_to_get_data(self):
        # Issue #18755: make sure multiple calls to get_data() can succeed.
        loader = imp._LoadSourceCompatibility('imp', imp.__file__,
                                              open(imp.__file__, encoding="utf-8"))
        loader.get_data(imp.__file__)  # File should be closed
        loader.get_data(imp.__file__)  # Will need to create a newly opened file

    def test_load_source(self):

            

Reported by Pylint.

XXX (ncoghlan): It would be nice to use test.import_helper.CleanImport
Error

Line: 388 Column: 3

                  reload()."""

    def test_source(self):
        # XXX (ncoghlan): It would be nice to use test.import_helper.CleanImport
        # here, but that breaks because the os module registers some
        # handlers in copy_reg on import. Since CleanImport doesn't
        # revert that registration, the module is left in a broken
        # state after reversion. Reinitialising the module contents
        # and just reverting os.environ to its previous state is an OK

            

Reported by Pylint.

Lib/binhex.py
67 issues
Redefining built-in 'dir'
Error

Line: 68 Column: 5

                          finfo.Type = 'TEXT'
        fp.seek(0, 2)
        dsize = fp.tell()
    dir, file = os.path.split(name)
    file = file.replace(':', '-', 1)
    return file, finfo, dsize, 0

class openrsrc:
    def __init__(self, *args):

            

Reported by Pylint.

Unused variable 'dir'
Error

Line: 68 Column: 5

                          finfo.Type = 'TEXT'
        fp.seek(0, 2)
        dsize = fp.tell()
    dir, file = os.path.split(name)
    file = file.replace(':', '-', 1)
    return file, finfo, dsize, 0

class openrsrc:
    def __init__(self, *args):

            

Reported by Pylint.

Unused argument 'args'
Error

Line: 76 Column: 1

                  def __init__(self, *args):
        pass

    def read(self, *args):
        return b''

    def write(self, *args):
        pass


            

Reported by Pylint.

Redefining built-in 'len'
Error

Line: 396 Column: 21

                      self.crc = 0
        self._readheader()

    def _read(self, len):
        data = self.ifp.read(len)
        self.crc = binascii.crc_hqx(data, self.crc)
        return data

    def _checkcrc(self):

            

Reported by Pylint.

Redefining built-in 'len'
Error

Line: 412 Column: 9

                      self.crc = 0

    def _readheader(self):
        len = self._read(1)
        fname = self._read(ord(len))
        rest = self._read(1 + 4 + 4 + 2 + 4 + 4)
        self._checkcrc()

        type = rest[1:5]

            

Reported by Pylint.

Redefining built-in 'type'
Error

Line: 417 Column: 9

                      rest = self._read(1 + 4 + 4 + 2 + 4 + 4)
        self._checkcrc()

        type = rest[1:5]
        creator = rest[5:9]
        flags = struct.unpack('>h', rest[9:11])[0]
        self.dlen = struct.unpack('>l', rest[11:15])[0]
        self.rlen = struct.unpack('>l', rest[15:19])[0]


            

Reported by Pylint.

Attribute 'dlen' defined outside __init__
Error

Line: 442 Column: 9

                      rv = b''
        while len(rv) < n:
            rv = rv + self._read(n-len(rv))
        self.dlen = self.dlen - n
        return rv

    def close_data(self):
        if self.state != _DID_HEADER:
            raise Error('close_data at wrong time')

            

Reported by Pylint.

Attribute 'state' defined outside __init__
Error

Line: 451 Column: 9

                      if self.dlen:
            dummy = self._read(self.dlen)
        self._checkcrc()
        self.state = _DID_DATA

    def read_rsrc(self, *n):
        if self.state == _DID_HEADER:
            self.close_data()
        if self.state != _DID_DATA:

            

Reported by Pylint.

Attribute 'rlen' defined outside __init__
Error

Line: 463 Column: 9

                          n = min(n, self.rlen)
        else:
            n = self.rlen
        self.rlen = self.rlen - n
        return self._read(n)

    def close(self):
        if self.state is None:
            return

            

Reported by Pylint.

Attribute 'state' defined outside __init__
Error

Line: 474 Column: 13

                              dummy = self.read_rsrc(self.rlen)
            self._checkcrc()
        finally:
            self.state = None
            self.ifp.close()

def hexbin(inp, out):
    """hexbin(infilename, outfilename) - Decode binhexed file"""
    ifp = HexBin(inp)

            

Reported by Pylint.

Lib/test/test_doctest2.py
67 issues
Attribute '_x' defined outside __init__
Error

Line: 77 Column: 9

                      >>> print(c.x)   # 12
        -12
        """
        self._x = value

    x = property(getx, setx, doc="""\
        >>> c = C()    # 13
        >>> c.x = 12   # 14
        >>> print(c.x)  # 15

            

Reported by Pylint.

Unused variable 'f'
Error

Line: 113 Column: 5

              def test_main():
    from test import test_doctest2
    EXPECTED = 19
    f, t = support.run_doctest(test_doctest2)
    if t != EXPECTED:
        raise support.TestFailed("expected %d tests to run, not %d" %
                                      (EXPECTED, t))

# Pollute the namespace with a bunch of imported functions and classes,

            

Reported by Pylint.

Unused import traceback from wildcard import
Error

Line: 120 Column: 1

              
# Pollute the namespace with a bunch of imported functions and classes,
# to make sure they don't get tested.
from doctest import *

if __name__ == '__main__':
    test_main()

            

Reported by Pylint.

Unused import TestResults from wildcard import
Error

Line: 120 Column: 1

              
# Pollute the namespace with a bunch of imported functions and classes,
# to make sure they don't get tested.
from doctest import *

if __name__ == '__main__':
    test_main()

            

Reported by Pylint.

Unused import OPTIONFLAGS_BY_NAME from wildcard import
Error

Line: 120 Column: 1

              
# Pollute the namespace with a bunch of imported functions and classes,
# to make sure they don't get tested.
from doctest import *

if __name__ == '__main__':
    test_main()

            

Reported by Pylint.

Unused import register_optionflag from wildcard import
Error

Line: 120 Column: 1

              
# Pollute the namespace with a bunch of imported functions and classes,
# to make sure they don't get tested.
from doctest import *

if __name__ == '__main__':
    test_main()

            

Reported by Pylint.

Unused import DONT_ACCEPT_TRUE_FOR_1 from wildcard import
Error

Line: 120 Column: 1

              
# Pollute the namespace with a bunch of imported functions and classes,
# to make sure they don't get tested.
from doctest import *

if __name__ == '__main__':
    test_main()

            

Reported by Pylint.

Unused import DONT_ACCEPT_BLANKLINE from wildcard import
Error

Line: 120 Column: 1

              
# Pollute the namespace with a bunch of imported functions and classes,
# to make sure they don't get tested.
from doctest import *

if __name__ == '__main__':
    test_main()

            

Reported by Pylint.

Unused import difflib from wildcard import
Error

Line: 120 Column: 1

              
# Pollute the namespace with a bunch of imported functions and classes,
# to make sure they don't get tested.
from doctest import *

if __name__ == '__main__':
    test_main()

            

Reported by Pylint.

Unused import inspect from wildcard import
Error

Line: 120 Column: 1

              
# Pollute the namespace with a bunch of imported functions and classes,
# to make sure they don't get tested.
from doctest import *

if __name__ == '__main__':
    test_main()

            

Reported by Pylint.

Lib/test/test_sysconfig.py
67 issues
Access to a protected member _HAS_USER_BASE of a client class
Error

Line: 22 Column: 17

              import _osx_support


HAS_USER_BASE = sysconfig._HAS_USER_BASE


class TestSysConfig(unittest.TestCase):

    def setUp(self):

            

Reported by Pylint.

Access to a protected member _CONFIG_VARS of a client class
Error

Line: 46 Column: 58

                      self.join = os.path.join
        self.isabs = os.path.isabs
        self.splitdrive = os.path.splitdrive
        self._config_vars = sysconfig._CONFIG_VARS, copy(sysconfig._CONFIG_VARS)
        self._added_envvars = []
        self._changed_envvars = []
        for var in ('MACOSX_DEPLOYMENT_TARGET', 'PATH'):
            if var in os.environ:
                self._changed_envvars.append((var, os.environ[var]))

            

Reported by Pylint.

Access to a protected member _CONFIG_VARS of a client class
Error

Line: 46 Column: 29

                      self.join = os.path.join
        self.isabs = os.path.isabs
        self.splitdrive = os.path.splitdrive
        self._config_vars = sysconfig._CONFIG_VARS, copy(sysconfig._CONFIG_VARS)
        self._added_envvars = []
        self._changed_envvars = []
        for var in ('MACOSX_DEPLOYMENT_TARGET', 'PATH'):
            if var in os.environ:
                self._changed_envvars.append((var, os.environ[var]))

            

Reported by Pylint.

Access to a protected member _CONFIG_VARS of a client class
Error

Line: 69 Column: 9

                      os.path.join = self.join
        os.path.isabs = self.isabs
        os.path.splitdrive = self.splitdrive
        sysconfig._CONFIG_VARS = self._config_vars[0]
        sysconfig._CONFIG_VARS.clear()
        sysconfig._CONFIG_VARS.update(self._config_vars[1])
        for var, value in self._changed_envvars:
            os.environ[var] = value
        for var in self._added_envvars:

            

Reported by Pylint.

Access to a protected member _CONFIG_VARS of a client class
Error

Line: 70 Column: 9

                      os.path.isabs = self.isabs
        os.path.splitdrive = self.splitdrive
        sysconfig._CONFIG_VARS = self._config_vars[0]
        sysconfig._CONFIG_VARS.clear()
        sysconfig._CONFIG_VARS.update(self._config_vars[1])
        for var, value in self._changed_envvars:
            os.environ[var] = value
        for var in self._added_envvars:
            os.environ.pop(var, None)

            

Reported by Pylint.

Access to a protected member _CONFIG_VARS of a client class
Error

Line: 71 Column: 9

                      os.path.splitdrive = self.splitdrive
        sysconfig._CONFIG_VARS = self._config_vars[0]
        sysconfig._CONFIG_VARS.clear()
        sysconfig._CONFIG_VARS.update(self._config_vars[1])
        for var, value in self._changed_envvars:
            os.environ[var] = value
        for var in self._added_envvars:
            os.environ.pop(var, None)


            

Reported by Pylint.

Access to a protected member _SCHEME_KEYS of a client class
Error

Line: 93 Column: 44

                          shutil.rmtree(path)

    def test_get_path_names(self):
        self.assertEqual(get_path_names(), sysconfig._SCHEME_KEYS)

    def test_get_paths(self):
        scheme = get_paths()
        default_scheme = get_default_scheme()
        wanted = _expand_vars(default_scheme, None)

            

Reported by Pylint.

Access to a protected member _framework of a client class
Error

Line: 134 Column: 9

                      # Mac, framework build.
        os.name = 'posix'
        sys.platform = 'darwin'
        sys._framework = True
        self.assertIsInstance(schemes, dict)
        self.assertEqual(set(schemes), expected_schemes)

    def test_get_config_vars(self):
        cvars = get_config_vars()

            

Reported by Pylint.

Access to a protected member _remove_original_values of a client class
Error

Line: 167 Column: 9

                                 ('Darwin Kernel Version 8.11.1: '
                    'Wed Oct 10 18:23:28 PDT 2007; '
                    'root:xnu-792.25.20~1/RELEASE_I386'), 'PowerPC'))
        _osx_support._remove_original_values(get_config_vars())
        get_config_vars()['MACOSX_DEPLOYMENT_TARGET'] = '10.3'

        get_config_vars()['CFLAGS'] = ('-fno-strict-aliasing -DNDEBUG -g '
                                       '-fwrapv -O3 -Wall -Wstrict-prototypes')


            

Reported by Pylint.

Access to a protected member _remove_original_values of a client class
Error

Line: 186 Column: 9

                                 ('Darwin Kernel Version 8.11.1: '
                    'Wed Oct 10 18:23:28 PDT 2007; '
                    'root:xnu-792.25.20~1/RELEASE_I386'), 'i386'))
        _osx_support._remove_original_values(get_config_vars())
        get_config_vars()['MACOSX_DEPLOYMENT_TARGET'] = '10.3'

        get_config_vars()['CFLAGS'] = ('-fno-strict-aliasing -DNDEBUG -g '
                                       '-fwrapv -O3 -Wall -Wstrict-prototypes')
        maxint = sys.maxsize

            

Reported by Pylint.

Tools/pynche/PyncheWidget.py
67 issues
Unable to import 'tkinter'
Error

Line: 9 Column: 1

              
import sys
import os
from tkinter import *
from tkinter import messagebox, filedialog
import ColorDB

# Milliseconds between interrupt checks
KEEPALIVE_TIMER = 500

            

Reported by Pylint.

Unable to import 'tkinter'
Error

Line: 10 Column: 1

              import sys
import os
from tkinter import *
from tkinter import messagebox, filedialog
import ColorDB

# Milliseconds between interrupt checks
KEEPALIVE_TIMER = 500


            

Reported by Pylint.

Unable to import 'ColorDB'
Error

Line: 11 Column: 1

              import os
from tkinter import *
from tkinter import messagebox, filedialog
import ColorDB

# Milliseconds between interrupt checks
KEEPALIVE_TIMER = 500



            

Reported by Pylint.

Undefined variable 'Toplevel'
Error

Line: 33 Column: 38

                      # no File menu and we get `Okay' and `Cancel' buttons), and we do a
        # grab_set() to make ourselves modal
        if modal:
            self.__tkroot = tkroot = Toplevel(master, class_='Pynche')
            tkroot.grab_set()
            tkroot.withdraw()
        else:
            # Is there already a default root for Tk, say because we're
            # running under Guido's IDE? :-) Two conditions say no, either the

            

Reported by Pylint.

Undefined variable 'tkinter'
Error

Line: 40 Column: 30

                          # Is there already a default root for Tk, say because we're
            # running under Guido's IDE? :-) Two conditions say no, either the
            # _default_root is None or it is unset.
            tkroot = getattr(tkinter, '_default_root', None)
            if not tkroot:
                tkroot = Tk(className='Pynche')
            self.__tkroot = tkroot
            # but this isn't our top level widget, so make it invisible
            tkroot.withdraw()

            

Reported by Pylint.

Undefined variable 'Tk'
Error

Line: 42 Column: 26

                          # _default_root is None or it is unset.
            tkroot = getattr(tkinter, '_default_root', None)
            if not tkroot:
                tkroot = Tk(className='Pynche')
            self.__tkroot = tkroot
            # but this isn't our top level widget, so make it invisible
            tkroot.withdraw()
        # create the menubar
        menubar = self.__menubar = Menu(tkroot)

            

Reported by Pylint.

Undefined variable 'Menu'
Error

Line: 47 Column: 36

                          # but this isn't our top level widget, so make it invisible
            tkroot.withdraw()
        # create the menubar
        menubar = self.__menubar = Menu(tkroot)
        #
        # File menu
        #
        filemenu = self.__filemenu = Menu(menubar, tearoff=0)
        filemenu.add_command(label='Load palette...',

            

Reported by Pylint.

Undefined variable 'Menu'
Error

Line: 51 Column: 38

                      #
        # File menu
        #
        filemenu = self.__filemenu = Menu(menubar, tearoff=0)
        filemenu.add_command(label='Load palette...',
                             command=self.__load,
                             underline=0)
        if not modal:
            filemenu.add_command(label='Quit',

            

Reported by Pylint.

Undefined variable 'Menu'
Error

Line: 64 Column: 20

                      # View menu
        #
        views = make_view_popups(self.__sb, self.__tkroot, extrapath)
        viewmenu = Menu(menubar, tearoff=0)
        for v in views:
            viewmenu.add_command(label=v.menutext(),
                                 command=v.popup,
                                 underline=v.underline())
        #

            

Reported by Pylint.

Undefined variable 'Menu'
Error

Line: 72 Column: 20

                      #
        # Help menu
        #
        helpmenu = Menu(menubar, name='help', tearoff=0)
        helpmenu.add_command(label='About Pynche...',
                             command=self.__popup_about,
                             underline=0)
        helpmenu.add_command(label='Help...',
                             command=self.__popup_usage,

            

Reported by Pylint.

Lib/distutils/util.py
67 issues
XXX what about the architecture? NT is Intel or Alpha,
Error

Line: 53 Column: 3

                      return os.environ["_PYTHON_HOST_PLATFORM"]

    if os.name != "posix" or not hasattr(os, 'uname'):
        # XXX what about the architecture? NT is Intel or Alpha,
        # Mac OS is M68k or PPC, etc.
        return sys.platform

    # Try to distinguish various flavours of Unix


            

Reported by Pylint.

Unused variable 'version'
Error

Line: 59 Column: 29

              
    # Try to distinguish various flavours of Unix

    (osname, host, release, version, machine) = os.uname()

    # Convert the OS name to lowercase, remove '/' characters, and translate
    # spaces (for "Power Macintosh")
    osname = osname.lower().replace('/', '')
    machine = machine.replace(' ', '_')

            

Reported by Pylint.

Unused variable 'host'
Error

Line: 59 Column: 14

              
    # Try to distinguish various flavours of Unix

    (osname, host, release, version, machine) = os.uname()

    # Convert the OS name to lowercase, remove '/' characters, and translate
    # spaces (for "Power Macintosh")
    osname = osname.lower().replace('/', '')
    machine = machine.replace(' ', '_')

            

Reported by Pylint.

XXX what about Alpha, SPARC, etc?
Error

Line: 70 Column: 3

                  if osname[:5] == "linux":
        # At least on Linux/Intel, 'machine' is the processor --
        # i386, etc.
        # XXX what about Alpha, SPARC, etc?
        return  "%s-%s" % (osname, machine)
    elif osname[:5] == "sunos":
        if release[0] >= "5":           # SunOS 5 == Solaris 2
            osname = "solaris"
            release = "%d.%s" % (int(release[0]) - 3, release[2:])

            

Reported by Pylint.

Redefining name 'distutils' from outer scope (line 12)
Error

Line: 92 Column: 9

                      if m:
            release = m.group()
    elif osname[:6] == "darwin":
        import _osx_support, distutils.sysconfig
        osname, release, machine = _osx_support.get_platform_osx(
                                        distutils.sysconfig.get_config_vars(),
                                        osname, release, machine)

    return "%s-%s-%s" % (osname, release, machine)

            

Reported by Pylint.

Unused variable 'drive'
Error

Line: 151 Column: 10

                          return os.path.join(new_root, pathname[1:])

    elif os.name == 'nt':
        (drive, path) = os.path.splitdrive(pathname)
        if path[0] == '\\':
            path = path[1:]
        return os.path.join(new_root, path)

    else:

            

Reported by Pylint.

Using the global statement
Error

Line: 169 Column: 5

                    PLAT - description of the current platform, including hardware
             and OS (see 'get_platform()')
    """
    global _environ_checked
    if _environ_checked:
        return

    if os.name == 'posix' and 'HOME' not in os.environ:
        try:

            

Reported by Pylint.

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

Line: 208 Column: 9

                  try:
        return re.sub(r'\$([a-zA-Z_][a-zA-Z_0-9]*)', _subst, s)
    except KeyError as var:
        raise ValueError("invalid variable '$%s'" % var)

# subst_vars ()


def grok_environment_error (exc, prefix="error: "):

            

Reported by Pylint.

Using the global statement
Error

Line: 223 Column: 5

              # Needed by 'split_quoted()'
_wordchars_re = _squote_re = _dquote_re = None
def _init_regex():
    global _wordchars_re, _squote_re, _dquote_re
    _wordchars_re = re.compile(r'[^\\\'\"%s ]*' % string.whitespace)
    _squote_re = re.compile(r"'(?:[^'\\]|\\.)*'")
    _dquote_re = re.compile(r'"(?:[^"\\]|\\.)*"')

def split_quoted (s):

            

Reported by Pylint.

Unused argument 'verbose'
Error

Line: 289 Column: 36

              # split_quoted ()


def execute (func, args, msg=None, verbose=0, dry_run=0):
    """Perform some action that affects the outside world (eg.  by
    writing to the filesystem).  Such actions are special because they
    are disabled by the 'dry_run' flag.  This method takes care of all
    that bureaucracy for you; all you have to do is supply the
    function to call and an argument tuple for it (to embody the

            

Reported by Pylint.

Lib/test/test_importlib/import_/test_fromlist.py
67 issues
Attempted relative import beyond top-level package
Error

Line: 2 Column: 1

              """Test that the semantics relating to the 'fromlist' argument are correct."""
from .. import util
import warnings
import unittest


class ReturnValue:

    """The use of fromlist influences what import returns.

            

Reported by Pylint.

Instance of 'ReturnValue' has no '__import__' member
Error

Line: 22 Column: 26

                      # [import return]
        with util.mock_spec('pkg.__init__', 'pkg.module') as importer:
            with util.import_state(meta_path=[importer]):
                module = self.__import__('pkg.module')
                self.assertEqual(module.__name__, 'pkg')

    def test_return_from_from_import(self):
        # [from return]
        with util.mock_spec('pkg.__init__', 'pkg.module')as importer:

            

Reported by Pylint.

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

Line: 23 Column: 17

                      with util.mock_spec('pkg.__init__', 'pkg.module') as importer:
            with util.import_state(meta_path=[importer]):
                module = self.__import__('pkg.module')
                self.assertEqual(module.__name__, 'pkg')

    def test_return_from_from_import(self):
        # [from return]
        with util.mock_spec('pkg.__init__', 'pkg.module')as importer:
            with util.import_state(meta_path=[importer]):

            

Reported by Pylint.

Instance of 'ReturnValue' has no '__import__' member
Error

Line: 29 Column: 26

                      # [from return]
        with util.mock_spec('pkg.__init__', 'pkg.module')as importer:
            with util.import_state(meta_path=[importer]):
                module = self.__import__('pkg.module', fromlist=['attr'])
                self.assertEqual(module.__name__, 'pkg.module')


(Frozen_ReturnValue,
 Source_ReturnValue

            

Reported by Pylint.

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

Line: 30 Column: 17

                      with util.mock_spec('pkg.__init__', 'pkg.module')as importer:
            with util.import_state(meta_path=[importer]):
                module = self.__import__('pkg.module', fromlist=['attr'])
                self.assertEqual(module.__name__, 'pkg.module')


(Frozen_ReturnValue,
 Source_ReturnValue
 ) = util.test_both(ReturnValue, __import__=util.__import__)

            

Reported by Pylint.

Instance of 'HandlingFromlist' has no '__import__' member
Error

Line: 57 Column: 26

                      # [object case]
        with util.mock_spec('module') as importer:
            with util.import_state(meta_path=[importer]):
                module = self.__import__('module', fromlist=['attr'])
                self.assertEqual(module.__name__, 'module')

    def test_nonexistent_object(self):
        # [bad object]
        with util.mock_spec('module') as importer:

            

Reported by Pylint.

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

Line: 58 Column: 17

                      with util.mock_spec('module') as importer:
            with util.import_state(meta_path=[importer]):
                module = self.__import__('module', fromlist=['attr'])
                self.assertEqual(module.__name__, 'module')

    def test_nonexistent_object(self):
        # [bad object]
        with util.mock_spec('module') as importer:
            with util.import_state(meta_path=[importer]):

            

Reported by Pylint.

Instance of 'HandlingFromlist' has no '__import__' member
Error

Line: 64 Column: 26

                      # [bad object]
        with util.mock_spec('module') as importer:
            with util.import_state(meta_path=[importer]):
                module = self.__import__('module', fromlist=['non_existent'])
                self.assertEqual(module.__name__, 'module')
                self.assertFalse(hasattr(module, 'non_existent'))

    def test_module_from_package(self):
        # [module]

            

Reported by Pylint.

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

Line: 65 Column: 17

                      with util.mock_spec('module') as importer:
            with util.import_state(meta_path=[importer]):
                module = self.__import__('module', fromlist=['non_existent'])
                self.assertEqual(module.__name__, 'module')
                self.assertFalse(hasattr(module, 'non_existent'))

    def test_module_from_package(self):
        # [module]
        with util.mock_spec('pkg.__init__', 'pkg.module') as importer:

            

Reported by Pylint.

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

Line: 66 Column: 17

                          with util.import_state(meta_path=[importer]):
                module = self.__import__('module', fromlist=['non_existent'])
                self.assertEqual(module.__name__, 'module')
                self.assertFalse(hasattr(module, 'non_existent'))

    def test_module_from_package(self):
        # [module]
        with util.mock_spec('pkg.__init__', 'pkg.module') as importer:
            with util.import_state(meta_path=[importer]):

            

Reported by Pylint.

Lib/tracemalloc.py
67 issues
bad operand type for unary -: NoneType
Error

Line: 240 Column: 36

                      lines = []
        if limit is not None:
            if limit > 0:
                frame_slice = self[-limit:]
            else:
                frame_slice = self[:limit]
        else:
            frame_slice = self


            

Reported by Pylint.

Unused import start from wildcard import
Error

Line: 9 Column: 1

              import pickle

# Import types and functions implemented in C
from _tracemalloc import *
from _tracemalloc import _get_object_traceback, _get_traces


def _format_size(size, sign):
    for unit in ('B', 'KiB', 'MiB', 'GiB', 'TiB'):

            

Reported by Pylint.

Unused import clear_traces from wildcard import
Error

Line: 9 Column: 1

              import pickle

# Import types and functions implemented in C
from _tracemalloc import *
from _tracemalloc import _get_object_traceback, _get_traces


def _format_size(size, sign):
    for unit in ('B', 'KiB', 'MiB', 'GiB', 'TiB'):

            

Reported by Pylint.

Wildcard import _tracemalloc
Error

Line: 9 Column: 1

              import pickle

# Import types and functions implemented in C
from _tracemalloc import *
from _tracemalloc import _get_object_traceback, _get_traces


def _format_size(size, sign):
    for unit in ('B', 'KiB', 'MiB', 'GiB', 'TiB'):

            

Reported by Pylint.

Unused import get_traced_memory from wildcard import
Error

Line: 9 Column: 1

              import pickle

# Import types and functions implemented in C
from _tracemalloc import *
from _tracemalloc import _get_object_traceback, _get_traces


def _format_size(size, sign):
    for unit in ('B', 'KiB', 'MiB', 'GiB', 'TiB'):

            

Reported by Pylint.

Unused import get_tracemalloc_memory from wildcard import
Error

Line: 9 Column: 1

              import pickle

# Import types and functions implemented in C
from _tracemalloc import *
from _tracemalloc import _get_object_traceback, _get_traces


def _format_size(size, sign):
    for unit in ('B', 'KiB', 'MiB', 'GiB', 'TiB'):

            

Reported by Pylint.

Unused import stop from wildcard import
Error

Line: 9 Column: 1

              import pickle

# Import types and functions implemented in C
from _tracemalloc import *
from _tracemalloc import _get_object_traceback, _get_traces


def _format_size(size, sign):
    for unit in ('B', 'KiB', 'MiB', 'GiB', 'TiB'):

            

Reported by Pylint.

Unused variable 'total_nframe'
Error

Line: 391 Column: 34

                          return self._match_frame(filename, lineno)

    def _match(self, trace):
        domain, size, traceback, total_nframe = trace
        res = self._match_traceback(traceback)
        if self.domain is not None:
            if self.inclusive:
                return res and (domain == self.domain)
            else:

            

Reported by Pylint.

Unused variable 'size'
Error

Line: 391 Column: 17

                          return self._match_frame(filename, lineno)

    def _match(self, trace):
        domain, size, traceback, total_nframe = trace
        res = self._match_traceback(traceback)
        if self.domain is not None:
            if self.inclusive:
                return res and (domain == self.domain)
            else:

            

Reported by Pylint.

Unused variable 'total_nframe'
Error

Line: 411 Column: 34

                      return self._domain

    def _match(self, trace):
        domain, size, traceback, total_nframe = trace
        return (domain == self.domain) ^ (not self.inclusive)


class Snapshot:
    """

            

Reported by Pylint.

Tools/peg_generator/pegen/parser.py
67 issues
Access to a protected member _verbose of a client class
Error

Line: 25 Column: 16

                  method_name = method.__name__

    def logger_wrapper(self: P, *args: object) -> T:
        if not self._verbose:
            return method(self, *args)
        argsr = ",".join(repr(arg) for arg in args)
        fill = "  " * self._level
        print(f"{fill}{method_name}({argsr}) .... (looking at {self.showpeek()})")
        self._level += 1

            

Reported by Pylint.

Access to a protected member _level of a client class
Error

Line: 28 Column: 23

                      if not self._verbose:
            return method(self, *args)
        argsr = ",".join(repr(arg) for arg in args)
        fill = "  " * self._level
        print(f"{fill}{method_name}({argsr}) .... (looking at {self.showpeek()})")
        self._level += 1
        tree = method(self, *args)
        self._level -= 1
        print(f"{fill}... {method_name}({argsr}) --> {tree!s:.200}")

            

Reported by Pylint.

Access to a protected member _mark of a client class
Error

Line: 45 Column: 16

                  method_name = method.__name__

    def memoize_wrapper(self: P, *args: object) -> T:
        mark = self._mark()
        key = mark, method_name, args
        # Fast path: cache hit, and not verbose.
        if key in self._cache and not self._verbose:
            tree, endmark = self._cache[key]
            self._reset(endmark)

            

Reported by Pylint.

Access to a protected member _verbose of a client class
Error

Line: 48 Column: 39

                      mark = self._mark()
        key = mark, method_name, args
        # Fast path: cache hit, and not verbose.
        if key in self._cache and not self._verbose:
            tree, endmark = self._cache[key]
            self._reset(endmark)
            return tree
        # Slow path: no cache hit, or verbose.
        verbose = self._verbose

            

Reported by Pylint.

Access to a protected member _cache of a client class
Error

Line: 48 Column: 19

                      mark = self._mark()
        key = mark, method_name, args
        # Fast path: cache hit, and not verbose.
        if key in self._cache and not self._verbose:
            tree, endmark = self._cache[key]
            self._reset(endmark)
            return tree
        # Slow path: no cache hit, or verbose.
        verbose = self._verbose

            

Reported by Pylint.

Access to a protected member _cache of a client class
Error

Line: 49 Column: 29

                      key = mark, method_name, args
        # Fast path: cache hit, and not verbose.
        if key in self._cache and not self._verbose:
            tree, endmark = self._cache[key]
            self._reset(endmark)
            return tree
        # Slow path: no cache hit, or verbose.
        verbose = self._verbose
        argsr = ",".join(repr(arg) for arg in args)

            

Reported by Pylint.

Access to a protected member _reset of a client class
Error

Line: 50 Column: 13

                      # Fast path: cache hit, and not verbose.
        if key in self._cache and not self._verbose:
            tree, endmark = self._cache[key]
            self._reset(endmark)
            return tree
        # Slow path: no cache hit, or verbose.
        verbose = self._verbose
        argsr = ",".join(repr(arg) for arg in args)
        fill = "  " * self._level

            

Reported by Pylint.

Access to a protected member _verbose of a client class
Error

Line: 53 Column: 19

                          self._reset(endmark)
            return tree
        # Slow path: no cache hit, or verbose.
        verbose = self._verbose
        argsr = ",".join(repr(arg) for arg in args)
        fill = "  " * self._level
        if key not in self._cache:
            if verbose:
                print(f"{fill}{method_name}({argsr}) ... (looking at {self.showpeek()})")

            

Reported by Pylint.

Access to a protected member _level of a client class
Error

Line: 55 Column: 23

                      # Slow path: no cache hit, or verbose.
        verbose = self._verbose
        argsr = ",".join(repr(arg) for arg in args)
        fill = "  " * self._level
        if key not in self._cache:
            if verbose:
                print(f"{fill}{method_name}({argsr}) ... (looking at {self.showpeek()})")
            self._level += 1
            tree = method(self, *args)

            

Reported by Pylint.

Access to a protected member _cache of a client class
Error

Line: 56 Column: 23

                      verbose = self._verbose
        argsr = ",".join(repr(arg) for arg in args)
        fill = "  " * self._level
        if key not in self._cache:
            if verbose:
                print(f"{fill}{method_name}({argsr}) ... (looking at {self.showpeek()})")
            self._level += 1
            tree = method(self, *args)
            self._level -= 1

            

Reported by Pylint.

Lib/unittest/test/testmock/testwith.py
67 issues
Statement seems to have no effect
Error

Line: 84 Column: 17

              
        with self.assertRaises(TypeError):
            with mock:
                'foo' + 3
        mock.__enter__.assert_called_with()
        self.assertTrue(mock.__exit__.called)


    def test_with_statement_same_attribute(self):

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import unittest
from warnings import catch_warnings

from unittest.test.testmock.support import is_instance
from unittest.mock import MagicMock, Mock, patch, sentinel, mock_open, call



something  = sentinel.Something

            

Reported by Pylint.

Missing class docstring
Error

Line: 13 Column: 1

              something_else  = sentinel.SomethingElse


class SampleException(Exception): pass


class WithTest(unittest.TestCase):

    def test_with_statement(self):

            

Reported by Pylint.

More than one statement on a single line
Error

Line: 13 Column: 35

              something_else  = sentinel.SomethingElse


class SampleException(Exception): pass


class WithTest(unittest.TestCase):

    def test_with_statement(self):

            

Reported by Pylint.

Missing class docstring
Error

Line: 16 Column: 1

              class SampleException(Exception): pass


class WithTest(unittest.TestCase):

    def test_with_statement(self):
        with patch('%s.something' % __name__, sentinel.Something2):
            self.assertEqual(something, sentinel.Something2, "unpatched")
        self.assertEqual(something, sentinel.Something)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 18 Column: 5

              
class WithTest(unittest.TestCase):

    def test_with_statement(self):
        with patch('%s.something' % __name__, sentinel.Something2):
            self.assertEqual(something, sentinel.Something2, "unpatched")
        self.assertEqual(something, sentinel.Something)



            

Reported by Pylint.

Missing function or method docstring
Error

Line: 24 Column: 5

                      self.assertEqual(something, sentinel.Something)


    def test_with_statement_exception(self):
        with self.assertRaises(SampleException):
            with patch('%s.something' % __name__, sentinel.Something2):
                self.assertEqual(something, sentinel.Something2, "unpatched")
                raise SampleException()
        self.assertEqual(something, sentinel.Something)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 32 Column: 5

                      self.assertEqual(something, sentinel.Something)


    def test_with_statement_as(self):
        with patch('%s.something' % __name__) as mock_something:
            self.assertEqual(something, mock_something, "unpatched")
            self.assertTrue(is_instance(mock_something, MagicMock),
                            "patching wrong type")
        self.assertEqual(something, sentinel.Something)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 40 Column: 5

                      self.assertEqual(something, sentinel.Something)


    def test_patch_object_with_statement(self):
        class Foo(object):
            something = 'foo'
        original = Foo.something
        with patch.object(Foo, 'something'):
            self.assertNotEqual(Foo.something, original, "unpatched")

            

Reported by Pylint.

Missing class docstring
Error

Line: 41 Column: 9

              

    def test_patch_object_with_statement(self):
        class Foo(object):
            something = 'foo'
        original = Foo.something
        with patch.object(Foo, 'something'):
            self.assertNotEqual(Foo.something, original, "unpatched")
        self.assertEqual(Foo.something, original)

            

Reported by Pylint.