The following issues were found

Lib/operator.py
110 issues
Redefining built-in 'abs'
Error

Line: 71 Column: 1

              
# Mathematical/Bitwise Operations *********************************************#

def abs(a):
    "Same as abs(a)."
    return _abs(a)

def add(a, b):
    "Same as a + b."

            

Reported by Pylint.

Redefining built-in 'pow'
Error

Line: 124 Column: 1

                  "Same as +a."
    return +a

def pow(a, b):
    "Same as a ** b."
    return a ** b

def rshift(a, b):
    "Same as a >> b."

            

Reported by Pylint.

Else clause on loop without a break statement
Error

Line: 178 Column: 5

                  for i, j in enumerate(a):
        if j is b or j == b:
            return i
    else:
        raise ValueError('sequence.index(x): x not in sequence')

def setitem(a, b, c):
    "Same as a[b] = c."
    a[b] = c

            

Reported by Pylint.

Wildcard import _operator
Error

Line: 408 Column: 5

              

try:
    from _operator import *
except ImportError:
    pass
else:
    from _operator import __doc__


            

Reported by Pylint.

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

Line: 27 Column: 1

              
# Comparison Operations *******************************************************#

def lt(a, b):
    "Same as a < b."
    return a < b

def le(a, b):
    "Same as a <= b."

            

Reported by Pylint.

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

Line: 27 Column: 1

              
# Comparison Operations *******************************************************#

def lt(a, b):
    "Same as a < b."
    return a < b

def le(a, b):
    "Same as a <= b."

            

Reported by Pylint.

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

Line: 27 Column: 1

              
# Comparison Operations *******************************************************#

def lt(a, b):
    "Same as a < b."
    return a < b

def le(a, b):
    "Same as a <= b."

            

Reported by Pylint.

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

Line: 31 Column: 1

                  "Same as a < b."
    return a < b

def le(a, b):
    "Same as a <= b."
    return a <= b

def eq(a, b):
    "Same as a == b."

            

Reported by Pylint.

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

Line: 31 Column: 1

                  "Same as a < b."
    return a < b

def le(a, b):
    "Same as a <= b."
    return a <= b

def eq(a, b):
    "Same as a == b."

            

Reported by Pylint.

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

Line: 31 Column: 1

                  "Same as a < b."
    return a < b

def le(a, b):
    "Same as a <= b."
    return a <= b

def eq(a, b):
    "Same as a == b."

            

Reported by Pylint.

Lib/test/test_ntpath.py
110 issues
Unexpected keyword argument 'strict' in function call
Error

Line: 420 Column: 30

                      self.assertRaises(OSError, ntpath.realpath, ABSTFN + "1\\x", strict=True)
        # Windows eliminates '..' components before resolving links, so the
        # following call is not expected to raise.
        self.assertPathEqual(ntpath.realpath(ABSTFN + "1\\..", strict=True),
                             ntpath.dirname(ABSTFN))
        self.assertRaises(OSError, ntpath.realpath, ABSTFN + "1\\..\\x", strict=True)
        os.symlink(ABSTFN + "x", ABSTFN + "y")
        self.assertRaises(OSError, ntpath.realpath, ABSTFN + "1\\..\\"
                                             + ntpath.basename(ABSTFN) + "y",

            

Reported by Pylint.

Access to a protected member _getfinalpathname of a client class
Error

Line: 21 Column: 5

                  nt = None

try:
    ntpath._getfinalpathname
except AttributeError:
    HAVE_GETFINALPATHNAME = False
else:
    HAVE_GETFINALPATHNAME = True


            

Reported by Pylint.

Use of possibly insecure function - consider using safer ast.literal_eval.
Security blacklist

Line: 55
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b307-eval

              
def tester(fn, wantResult):
    fn = fn.replace("\\", "\\\\")
    gotResult = eval(fn)
    if wantResult != gotResult and _norm(wantResult) != _norm(gotResult):
        raise TestFailed("%s should return: %s but returned: %s" \
              %(str(fn), str(wantResult), str(gotResult)))

    # then with bytes

            

Reported by Bandit.

Use of eval
Error

Line: 55 Column: 17

              
def tester(fn, wantResult):
    fn = fn.replace("\\", "\\\\")
    gotResult = eval(fn)
    if wantResult != gotResult and _norm(wantResult) != _norm(gotResult):
        raise TestFailed("%s should return: %s but returned: %s" \
              %(str(fn), str(wantResult), str(gotResult)))

    # then with bytes

            

Reported by Pylint.

Use of eval
Error

Line: 71 Column: 21

                  fn = fn.encode('ascii', 'backslashreplace').decode('ascii')
    with warnings.catch_warnings():
        warnings.simplefilter("ignore", DeprecationWarning)
        gotResult = eval(fn)
    if _norm(wantResult) != _norm(gotResult):
        raise TestFailed("%s should return: %s but returned: %s" \
              %(str(fn), str(wantResult), repr(gotResult)))



            

Reported by Pylint.

Use of possibly insecure function - consider using safer ast.literal_eval.
Security blacklist

Line: 71
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b307-eval

                  fn = fn.encode('ascii', 'backslashreplace').decode('ascii')
    with warnings.catch_warnings():
        warnings.simplefilter("ignore", DeprecationWarning)
        gotResult = eval(fn)
    if _norm(wantResult) != _norm(gotResult):
        raise TestFailed("%s should return: %s but returned: %s" \
              %(str(fn), str(wantResult), repr(gotResult)))



            

Reported by Bandit.

Unused variable 'path'
Error

Line: 744 Column: 20

                          # (or any other volume root). The drive-relative
            # locations below cannot then refer to mount points
            #
            drive, path = ntpath.splitdrive(sys.executable)
            with os_helper.change_cwd(ntpath.dirname(sys.executable)):
                self.assertFalse(ntpath.ismount(drive.lower()))
                self.assertFalse(ntpath.ismount(drive.upper()))

            self.assertTrue(ntpath.ismount("\\\\localhost\\c$"))

            

Reported by Pylint.

Access to a protected member _getfinalpathname of a client class
Error

Line: 764 Column: 22

                      # Trivial validation that the helpers do not break, and support both
        # unicode and bytes (UTF-8) paths

        executable = nt._getfinalpathname(sys.executable)

        for path in executable, os.fsencode(executable):
            volume_path = nt._getvolumepathname(path)
            path_drive = ntpath.splitdrive(path)[0]
            volume_path_drive = ntpath.splitdrive(volume_path)[0]

            

Reported by Pylint.

Access to a protected member _getvolumepathname of a client class
Error

Line: 767 Column: 27

                      executable = nt._getfinalpathname(sys.executable)

        for path in executable, os.fsencode(executable):
            volume_path = nt._getvolumepathname(path)
            path_drive = ntpath.splitdrive(path)[0]
            volume_path_drive = ntpath.splitdrive(volume_path)[0]
            self.assertEqualCI(path_drive, volume_path_drive)

        cap, free = nt._getdiskusage(sys.exec_prefix)

            

Reported by Pylint.

Access to a protected member _getdiskusage of a client class
Error

Line: 772 Column: 21

                          volume_path_drive = ntpath.splitdrive(volume_path)[0]
            self.assertEqualCI(path_drive, volume_path_drive)

        cap, free = nt._getdiskusage(sys.exec_prefix)
        self.assertGreater(cap, 0)
        self.assertGreater(free, 0)
        b_cap, b_free = nt._getdiskusage(sys.exec_prefix.encode())
        # Free space may change, so only test the capacity is equal
        self.assertEqual(b_cap, cap)

            

Reported by Pylint.

Lib/zipimport.py
110 issues
No name '_unpack_uint16' in module '_frozen_importlib_external'
Error

Line: 18 Column: 1

              #from importlib import _bootstrap_external
#from importlib import _bootstrap  # for _verbose_message
import _frozen_importlib_external as _bootstrap_external
from _frozen_importlib_external import _unpack_uint16, _unpack_uint32
import _frozen_importlib as _bootstrap  # for _verbose_message
import _imp  # for check_hash_based_pycs
import _io  # for open
import marshal  # for loads
import sys  # for modules

            

Reported by Pylint.

No name '_unpack_uint32' in module '_frozen_importlib_external'
Error

Line: 18 Column: 1

              #from importlib import _bootstrap_external
#from importlib import _bootstrap  # for _verbose_message
import _frozen_importlib_external as _bootstrap_external
from _frozen_importlib_external import _unpack_uint16, _unpack_uint32
import _frozen_importlib as _bootstrap  # for _verbose_message
import _imp  # for check_hash_based_pycs
import _io  # for open
import marshal  # for loads
import sys  # for modules

            

Reported by Pylint.

Module '_frozen_importlib_external' has no 'path_sep' member
Error

Line: 30 Column: 12

              __all__ = ['ZipImportError', 'zipimporter']


path_sep = _bootstrap_external.path_sep
alt_path_sep = _bootstrap_external.path_separators[1:]


class ZipImportError(ImportError):
    pass

            

Reported by Pylint.

Module '_frozen_importlib_external' has no 'path_separators' member
Error

Line: 31 Column: 16

              

path_sep = _bootstrap_external.path_sep
alt_path_sep = _bootstrap_external.path_separators[1:]


class ZipImportError(ImportError):
    pass


            

Reported by Pylint.

Module '_frozen_importlib_external' has no '_LoaderBasics' member
Error

Line: 46 Column: 19

              STRING_END_ARCHIVE = b'PK\x05\x06'
MAX_COMMENT_LEN = (1 << 16) - 1

class zipimporter(_bootstrap_external._LoaderBasics):
    """zipimporter(archivepath) -> zipimporter object

    Create a new zipimporter instance. 'archivepath' must be a path to
    a zipfile, or to a specific path inside a zipfile. For example, it can be
    '/tmp/myimport.zip', or '/tmp/myimport.zip/mydirectory', if mydirectory is a

            

Reported by Pylint.

Module '_frozen_importlib_external' has no '_path_stat' member
Error

Line: 76 Column: 22

                      prefix = []
        while True:
            try:
                st = _bootstrap_external._path_stat(path)
            except (OSError, ValueError):
                # On Windows a ValueError is raised for too long paths.
                # Back up one path element.
                dirname, basename = _bootstrap_external._path_split(path)
                if dirname == path:

            

Reported by Pylint.

Module '_frozen_importlib_external' has no '_path_split' member
Error

Line: 80 Column: 37

                          except (OSError, ValueError):
                # On Windows a ValueError is raised for too long paths.
                # Back up one path element.
                dirname, basename = _bootstrap_external._path_split(path)
                if dirname == path:
                    raise ZipImportError('not a Zip file', path=path)
                path = dirname
                prefix.append(basename)
            else:

            

Reported by Pylint.

Module '_frozen_importlib_external' has no '_path_join' member
Error

Line: 100 Column: 23

                      self._files = files
        self.archive = path
        # a prefix directory following the ZIP file path.
        self.prefix = _bootstrap_external._path_join(*prefix[::-1])
        if self.prefix:
            self.prefix += path_sep


    # Check whether we can satisfy the import of the module named by

            

Reported by Pylint.

Module '_frozen_importlib' has no 'spec_from_loader' member
Error

Line: 170 Column: 20

                      """
        module_info = _get_module_info(self, fullname)
        if module_info is not None:
            return _bootstrap.spec_from_loader(fullname, self, is_package=module_info)
        else:
            # Not a module or regular package. See if this is a directory, and
            # therefore possibly a portion of a namespace package.

            # We're only interested in the last path component of fullname

            

Reported by Pylint.

Module '_frozen_importlib' has no 'ModuleSpec' member
Error

Line: 183 Column: 24

                              # package. Return the string representing its path,
                # without a trailing separator.
                path = f'{self.archive}{path_sep}{modpath}'
                spec = _bootstrap.ModuleSpec(name=fullname, loader=None,
                                             is_package=True)
                spec.submodule_search_locations.append(path)
                return spec
            else:
                return None

            

Reported by Pylint.

Lib/test/test_asyncio/test_queues.py
109 issues
self.q_class is not callable
Error

Line: 606 Column: 13

                  q_class = None

    def test_task_done_underflow(self):
        q = self.q_class()
        self.assertRaises(ValueError, q.task_done)

    def test_task_done(self):
        q = self.q_class()
        for i in range(100):

            

Reported by Pylint.

self.q_class is not callable
Error

Line: 610 Column: 13

                      self.assertRaises(ValueError, q.task_done)

    def test_task_done(self):
        q = self.q_class()
        for i in range(100):
            q.put_nowait(i)

        accumulator = 0


            

Reported by Pylint.

self.q_class is not callable
Error

Line: 645 Column: 13

                      self.loop.run_until_complete(asyncio.wait(tasks))

    def test_join_empty_queue(self):
        q = self.q_class()

        # Test that a queue join()s successfully, and before anything else
        # (done twice for insurance).

        async def join():

            

Reported by Pylint.

self.q_class is not callable
Error

Line: 657 Column: 13

                      self.loop.run_until_complete(join())

    def test_format(self):
        q = self.q_class()
        self.assertEqual(q._format(), 'maxsize=0')

        q._unfinished_tasks = 2
        self.assertEqual(q._format(), 'maxsize=0 tasks=2')


            

Reported by Pylint.

Unused mock imported from unittest
Error

Line: 4 Column: 1

              """Tests for queues.py"""

import unittest
from unittest import mock

import asyncio
from test.test_asyncio import utils as test_utils



            

Reported by Pylint.

Access to a protected member _putters of a client class
Error

Line: 160 Column: 9

                      q.put_nowait(1)

        waiter = self.loop.create_future()
        q._putters.append(waiter)

        res = self.loop.run_until_complete(q.get())
        self.assertEqual(1, res)
        self.assertTrue(waiter.done())
        self.assertIsNone(waiter.result())

            

Reported by Pylint.

Access to a protected member _get_loop of a client class
Error

Line: 273 Column: 13

              
        async def create_queue():
            queue = asyncio.Queue(queue_size)
            queue._get_loop()
            return queue

        async def test():
            q = await create_queue()
            await asyncio.gather(producer(q, producer_num_items),

            

Reported by Pylint.

Unused variable 'item'
Error

Line: 292 Column: 17

              
        async def consumer(queue):
            try:
                item = await asyncio.wait_for(queue.get(), 0.1)
            except asyncio.TimeoutError:
                pass

        queue = asyncio.Queue(maxsize=5)
        self.loop.run_until_complete(self.loop.create_task(consumer(queue)))

            

Reported by Pylint.

Access to a protected member _getters of a client class
Error

Line: 298 Column: 30

              
        queue = asyncio.Queue(maxsize=5)
        self.loop.run_until_complete(self.loop.create_task(consumer(queue)))
        self.assertEqual(len(queue._getters), 0)


class QueuePutTests(_QueueTestBase):

    def test_blocking_put(self):

            

Reported by Pylint.

Access to a protected member _get_loop of a client class
Error

Line: 505 Column: 13

              
        async def create_queue():
            q = asyncio.Queue(2)
            q._get_loop()
            return q

        queue = self.loop.run_until_complete(create_queue())

        async def putter(item):

            

Reported by Pylint.

Lib/test/test_site.py
109 issues
Module 'sys' has no 'platlibdir' member
Error

Line: 286 Column: 16

                      dirs = site.getsitepackages()
        if os.sep == '/':
            # OS X, Linux, FreeBSD, etc
            if sys.platlibdir != "lib":
                self.assertEqual(len(dirs), 2)
                wanted = os.path.join('xoxo', sys.platlibdir,
                                      'python%d.%d' % sys.version_info[:2],
                                      'site-packages')
                self.assertEqual(dirs[0], wanted)

            

Reported by Pylint.

Module 'sys' has no 'platlibdir' member
Error

Line: 288 Column: 47

                          # OS X, Linux, FreeBSD, etc
            if sys.platlibdir != "lib":
                self.assertEqual(len(dirs), 2)
                wanted = os.path.join('xoxo', sys.platlibdir,
                                      'python%d.%d' % sys.version_info[:2],
                                      'site-packages')
                self.assertEqual(dirs[0], wanted)
            else:
                self.assertEqual(len(dirs), 1)

            

Reported by Pylint.

Instance of '_Printer' has no '_Printer__data' member
Error

Line: 483 Column: 15

                  def test_license_exists_at_url(self):
        # This test is a bit fragile since it depends on the format of the
        # string displayed by license in the absence of a LICENSE file.
        url = license._Printer__data.split()[1]
        req = urllib.request.Request(url, method='HEAD')
        # Reset global urllib.request._opener
        self.addCleanup(urllib.request.urlcleanup)
        try:
            with socket_helper.transient_internet(url):

            

Reported by Pylint.

Unable to import '_winapi'
Error

Line: 567 Column: 9

              class _pthFileTests(unittest.TestCase):

    def _create_underpth_exe(self, lines, exe_pth=True):
        import _winapi
        temp_dir = tempfile.mkdtemp()
        self.addCleanup(os_helper.rmtree, temp_dir)
        exe_file = os.path.join(temp_dir, os.path.split(sys.executable)[1])
        dll_src_file = _winapi.GetModuleFileName(sys.dllhandle)
        dll_file = os.path.join(temp_dir, os.path.split(dll_src_file)[1])

            

Reported by Pylint.

Module 'sys' has no 'dllhandle' member
Error

Line: 571 Column: 50

                      temp_dir = tempfile.mkdtemp()
        self.addCleanup(os_helper.rmtree, temp_dir)
        exe_file = os.path.join(temp_dir, os.path.split(sys.executable)[1])
        dll_src_file = _winapi.GetModuleFileName(sys.dllhandle)
        dll_file = os.path.join(temp_dir, os.path.split(dll_src_file)[1])
        shutil.copy(sys.executable, exe_file)
        shutil.copy(dll_src_file, dll_file)
        if exe_pth:
            _pth_file = os.path.splitext(exe_file)[0] + '._pth'

            

Reported by Pylint.

Reimport 'support' (imported line 8)
Error

Line: 9 Column: 1

              """
import unittest
import test.support
from test import support
from test.support import os_helper
from test.support import socket_helper
from test.support import captured_stderr
from test.support.os_helper import TESTFN, EnvironmentVarGuard, change_cwd
import builtins

            

Reported by Pylint.

Unused change_cwd imported from test.support.os_helper
Error

Line: 13 Column: 1

              from test.support import os_helper
from test.support import socket_helper
from test.support import captured_stderr
from test.support.os_helper import TESTFN, EnvironmentVarGuard, change_cwd
import builtins
import encodings
import glob
import io
import os

            

Reported by Pylint.

Using the global statement
Error

Line: 44 Column: 5

              

def setUpModule():
    global OLD_SYS_PATH
    OLD_SYS_PATH = sys.path[:]

    if site.ENABLE_USER_SITE and not os.path.isdir(site.USER_SITE):
        # need to add user site directory for tests
        try:

            

Reported by Pylint.

Access to a protected member _CONFIG_VARS of a client class
Error

Line: 72 Column: 30

                      self.old_base = site.USER_BASE
        self.old_site = site.USER_SITE
        self.old_prefixes = site.PREFIXES
        self.original_vars = sysconfig._CONFIG_VARS
        self.old_vars = copy(sysconfig._CONFIG_VARS)

    def tearDown(self):
        """Restore sys.path"""
        sys.path[:] = self.sys_path

            

Reported by Pylint.

Access to a protected member _CONFIG_VARS of a client class
Error

Line: 73 Column: 30

                      self.old_site = site.USER_SITE
        self.old_prefixes = site.PREFIXES
        self.original_vars = sysconfig._CONFIG_VARS
        self.old_vars = copy(sysconfig._CONFIG_VARS)

    def tearDown(self):
        """Restore sys.path"""
        sys.path[:] = self.sys_path
        site.USER_BASE = self.old_base

            

Reported by Pylint.

Lib/test/test_richcmp.py
109 issues
Method should have "self" as first argument
Error

Line: 195 Column: 13

              
    def test_misbehavin(self):
        class Misb:
            def __lt__(self_, other): return 0
            def __gt__(self_, other): return 0
            def __eq__(self_, other): return 0
            def __le__(self_, other): self.fail("This shouldn't happen")
            def __ge__(self_, other): self.fail("This shouldn't happen")
            def __ne__(self_, other): self.fail("This shouldn't happen")

            

Reported by Pylint.

Method should have "self" as first argument
Error

Line: 196 Column: 13

                  def test_misbehavin(self):
        class Misb:
            def __lt__(self_, other): return 0
            def __gt__(self_, other): return 0
            def __eq__(self_, other): return 0
            def __le__(self_, other): self.fail("This shouldn't happen")
            def __ge__(self_, other): self.fail("This shouldn't happen")
            def __ne__(self_, other): self.fail("This shouldn't happen")
        a = Misb()

            

Reported by Pylint.

Method should have "self" as first argument
Error

Line: 197 Column: 13

                      class Misb:
            def __lt__(self_, other): return 0
            def __gt__(self_, other): return 0
            def __eq__(self_, other): return 0
            def __le__(self_, other): self.fail("This shouldn't happen")
            def __ge__(self_, other): self.fail("This shouldn't happen")
            def __ne__(self_, other): self.fail("This shouldn't happen")
        a = Misb()
        b = Misb()

            

Reported by Pylint.

Method should have "self" as first argument
Error

Line: 198 Column: 13

                          def __lt__(self_, other): return 0
            def __gt__(self_, other): return 0
            def __eq__(self_, other): return 0
            def __le__(self_, other): self.fail("This shouldn't happen")
            def __ge__(self_, other): self.fail("This shouldn't happen")
            def __ne__(self_, other): self.fail("This shouldn't happen")
        a = Misb()
        b = Misb()
        self.assertEqual(a<b, 0)

            

Reported by Pylint.

Method should have "self" as first argument
Error

Line: 199 Column: 13

                          def __gt__(self_, other): return 0
            def __eq__(self_, other): return 0
            def __le__(self_, other): self.fail("This shouldn't happen")
            def __ge__(self_, other): self.fail("This shouldn't happen")
            def __ne__(self_, other): self.fail("This shouldn't happen")
        a = Misb()
        b = Misb()
        self.assertEqual(a<b, 0)
        self.assertEqual(a==b, 0)

            

Reported by Pylint.

Method should have "self" as first argument
Error

Line: 200 Column: 13

                          def __eq__(self_, other): return 0
            def __le__(self_, other): self.fail("This shouldn't happen")
            def __ge__(self_, other): self.fail("This shouldn't happen")
            def __ne__(self_, other): self.fail("This shouldn't happen")
        a = Misb()
        b = Misb()
        self.assertEqual(a<b, 0)
        self.assertEqual(a==b, 0)
        self.assertEqual(a>b, 0)

            

Reported by Pylint.

Redefining name 'operator' from outer scope (line 6)
Error

Line: 210 Column: 9

                  def test_not(self):
        # Check that exceptions in __bool__ are properly
        # propagated by the not operator
        import operator
        class Exc(Exception):
            pass
        class Bad:
            def __bool__(self):
                raise Exc

            

Reported by Pylint.

Reimport 'operator' (imported line 6)
Error

Line: 210 Column: 9

                  def test_not(self):
        # Check that exceptions in __bool__ are properly
        # propagated by the not operator
        import operator
        class Exc(Exception):
            pass
        class Bad:
            def __bool__(self):
                raise Exc

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 218 Column: 13

                              raise Exc

        def do(bad):
            not bad

        for func in (do, operator.not_):
            self.assertRaises(Exc, func, Bad())

    @support.no_tracing

            

Reported by Pylint.

Unused variable 'i'
Error

Line: 289 Column: 13

                      # __hash__).  Complex numbers are a fine example of that.
        import random
        imag1a = {}
        for i in range(50):
            imag1a[random.randrange(100)*1j] = random.randrange(100)*1j
        items = list(imag1a.items())
        random.shuffle(items)
        imag1b = {}
        for k, v in items:

            

Reported by Pylint.

Lib/ctypes/test/test_find.py
109 issues
Unused import kind from wildcard import
Error

Line: 7 Column: 1

              import sys
import test.support
from test.support import os_helper
from ctypes import *
from ctypes.util import find_library

# On some systems, loading the OpenGL libraries needs the RTLD_GLOBAL mode.
class Test_OpenGL_libs(unittest.TestCase):
    @classmethod

            

Reported by Pylint.

Unused import LittleEndianStructure from wildcard import
Error

Line: 7 Column: 1

              import sys
import test.support
from test.support import os_helper
from ctypes import *
from ctypes.util import find_library

# On some systems, loading the OpenGL libraries needs the RTLD_GLOBAL mode.
class Test_OpenGL_libs(unittest.TestCase):
    @classmethod

            

Reported by Pylint.

Unused import BigEndianStructure from wildcard import
Error

Line: 7 Column: 1

              import sys
import test.support
from test.support import os_helper
from ctypes import *
from ctypes.util import find_library

# On some systems, loading the OpenGL libraries needs the RTLD_GLOBAL mode.
class Test_OpenGL_libs(unittest.TestCase):
    @classmethod

            

Reported by Pylint.

Unused import set_last_error from wildcard import
Error

Line: 7 Column: 1

              import sys
import test.support
from test.support import os_helper
from ctypes import *
from ctypes.util import find_library

# On some systems, loading the OpenGL libraries needs the RTLD_GLOBAL mode.
class Test_OpenGL_libs(unittest.TestCase):
    @classmethod

            

Reported by Pylint.

Unused import get_last_error from wildcard import
Error

Line: 7 Column: 1

              import sys
import test.support
from test.support import os_helper
from ctypes import *
from ctypes.util import find_library

# On some systems, loading the OpenGL libraries needs the RTLD_GLOBAL mode.
class Test_OpenGL_libs(unittest.TestCase):
    @classmethod

            

Reported by Pylint.

Unused import pointer from wildcard import
Error

Line: 7 Column: 1

              import sys
import test.support
from test.support import os_helper
from ctypes import *
from ctypes.util import find_library

# On some systems, loading the OpenGL libraries needs the RTLD_GLOBAL mode.
class Test_OpenGL_libs(unittest.TestCase):
    @classmethod

            

Reported by Pylint.

Unused import POINTER from wildcard import
Error

Line: 7 Column: 1

              import sys
import test.support
from test.support import os_helper
from ctypes import *
from ctypes.util import find_library

# On some systems, loading the OpenGL libraries needs the RTLD_GLOBAL mode.
class Test_OpenGL_libs(unittest.TestCase):
    @classmethod

            

Reported by Pylint.

Unused import set_errno from wildcard import
Error

Line: 7 Column: 1

              import sys
import test.support
from test.support import os_helper
from ctypes import *
from ctypes.util import find_library

# On some systems, loading the OpenGL libraries needs the RTLD_GLOBAL mode.
class Test_OpenGL_libs(unittest.TestCase):
    @classmethod

            

Reported by Pylint.

Unused import get_errno from wildcard import
Error

Line: 7 Column: 1

              import sys
import test.support
from test.support import os_helper
from ctypes import *
from ctypes.util import find_library

# On some systems, loading the OpenGL libraries needs the RTLD_GLOBAL mode.
class Test_OpenGL_libs(unittest.TestCase):
    @classmethod

            

Reported by Pylint.

Unused import resize from wildcard import
Error

Line: 7 Column: 1

              import sys
import test.support
from test.support import os_helper
from ctypes import *
from ctypes.util import find_library

# On some systems, loading the OpenGL libraries needs the RTLD_GLOBAL mode.
class Test_OpenGL_libs(unittest.TestCase):
    @classmethod

            

Reported by Pylint.

Lib/test/test_codeccallbacks.py
109 issues
class already defined line 1067
Error

Line: 1072 Column: 13

                          for handler in handlers:
                with self.subTest(handler=handler, error_class=cls):
                    self.assertRaises(TypeError, handler, FakeUnicodeError())
            class FakeUnicodeError(Exception):
                __class__ = cls
            for handler in handlers:
                with self.subTest(handler=handler, error_class=cls):
                    with self.assertRaises((TypeError, FakeUnicodeError)):
                        handler(FakeUnicodeError())

            

Reported by Pylint.

Cell variable res defined in loop
Error

Line: 749 Column: 64

                      encs = ("ascii", "latin-1", "iso-8859-1", "iso-8859-15")

        for res in results:
            codecs.register_error("test.badhandler", lambda x: res)
            for enc in encs:
                self.assertRaises(
                    TypeError,
                    "\u3042".encode,
                    enc,

            

Reported by Pylint.

Redefining built-in 'bytes'
Error

Line: 757 Column: 23

                                  enc,
                    "test.badhandler"
                )
            for (enc, bytes) in (
                ("ascii", b"\xff"),
                ("utf-8", b"\xff"),
                ("utf-7", b"+x-"),
            ):
                self.assertRaises(

            

Reported by Pylint.

Unused argument 'exc'
Error

Line: 836 Column: 30

                      # and callers
        self.assertRaises(LookupError, b"\xff".decode, "ascii", "test.unknown")

        def baddecodereturn1(exc):
            return 42
        codecs.register_error("test.baddecodereturn1", baddecodereturn1)
        self.assertRaises(TypeError, b"\xff".decode, "ascii", "test.baddecodereturn1")
        self.assertRaises(TypeError, b"\\".decode, "unicode-escape", "test.baddecodereturn1")
        self.assertRaises(TypeError, b"\\x0".decode, "unicode-escape", "test.baddecodereturn1")

            

Reported by Pylint.

Unused argument 'exc'
Error

Line: 846 Column: 30

                      self.assertRaises(TypeError, b"\\Uffffeeee".decode, "unicode-escape", "test.baddecodereturn1")
        self.assertRaises(TypeError, b"\\uyyyy".decode, "raw-unicode-escape", "test.baddecodereturn1")

        def baddecodereturn2(exc):
            return ("?", None)
        codecs.register_error("test.baddecodereturn2", baddecodereturn2)
        self.assertRaises(TypeError, b"\xff".decode, "ascii", "test.baddecodereturn2")

        handler = PosReturn()

            

Reported by Pylint.

Unused argument 'exc'
Error

Line: 895 Column: 30

                      # and callers
        self.assertRaises(LookupError, "\xff".encode, "ascii", "test.unknown")

        def badencodereturn1(exc):
            return 42
        codecs.register_error("test.badencodereturn1", badencodereturn1)
        self.assertRaises(TypeError, "\xff".encode, "ascii", "test.badencodereturn1")

        def badencodereturn2(exc):

            

Reported by Pylint.

Unused argument 'exc'
Error

Line: 900 Column: 30

                      codecs.register_error("test.badencodereturn1", badencodereturn1)
        self.assertRaises(TypeError, "\xff".encode, "ascii", "test.badencodereturn1")

        def badencodereturn2(exc):
            return ("?", None)
        codecs.register_error("test.badencodereturn2", badencodereturn2)
        self.assertRaises(TypeError, "\xff".encode, "ascii", "test.badencodereturn2")

        handler = PosReturn()

            

Reported by Pylint.

Unused variable 'D'
Error

Line: 949 Column: 9

                      # and callers
        # (Unfortunately the errors argument is not directly accessible
        # from Python, so we can't test that much)
        class D(dict):
            def __getitem__(self, key):
                raise ValueError
        #self.assertRaises(ValueError, "\xff".translate, D())
        self.assertRaises(ValueError, "\xff".translate, {0xff: sys.maxunicode+1})
        self.assertRaises(TypeError, "\xff".translate, {0xff: ()})

            

Reported by Pylint.

Too many lines in module (1081/1000)
Error

Line: 1 Column: 1

              import codecs
import html.entities
import sys
import unicodedata
import unittest


class PosReturn:
    # this can be used for configurable callbacks

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import codecs
import html.entities
import sys
import unicodedata
import unittest


class PosReturn:
    # this can be used for configurable callbacks

            

Reported by Pylint.

Lib/test/test_sort.py
108 issues
function already defined line 155
Error

Line: 161 Column: 13

                              return (x > y) - (x < y)
            L = [1,2]
            self.assertRaises(ValueError, L.sort, key=cmp_to_key(mutating_cmp))
            def mutating_cmp(x, y):
                L.append(3)
                del L[:]
                return (x > y) - (x < y)
            self.assertRaises(ValueError, L.sort, key=cmp_to_key(mutating_cmp))
            memorywaster = [memorywaster]

            

Reported by Pylint.

Using the global statement
Error

Line: 11 Column: 5

              

def check(tag, expected, raw, compare=None):
    global nerrors

    if verbose:
        print("    checking", tag)

    orig = raw[:]   # save input in case of error

            

Reported by Pylint.

Unused variable 'i'
Error

Line: 154 Column: 13

                  def test_undetected_mutation(self):
        # Python 2.4a1 did not always detect mutation
        memorywaster = []
        for i in range(20):
            def mutating_cmp(x, y):
                L.append(3)
                L.pop()
                return (x > y) - (x < y)
            L = [1,2]

            

Reported by Pylint.

Cell variable L defined in loop
Error

Line: 156 Column: 17

                      memorywaster = []
        for i in range(20):
            def mutating_cmp(x, y):
                L.append(3)
                L.pop()
                return (x > y) - (x < y)
            L = [1,2]
            self.assertRaises(ValueError, L.sort, key=cmp_to_key(mutating_cmp))
            def mutating_cmp(x, y):

            

Reported by Pylint.

Cell variable L defined in loop
Error

Line: 157 Column: 17

                      for i in range(20):
            def mutating_cmp(x, y):
                L.append(3)
                L.pop()
                return (x > y) - (x < y)
            L = [1,2]
            self.assertRaises(ValueError, L.sort, key=cmp_to_key(mutating_cmp))
            def mutating_cmp(x, y):
                L.append(3)

            

Reported by Pylint.

Cell variable L defined in loop
Error

Line: 162 Column: 17

                          L = [1,2]
            self.assertRaises(ValueError, L.sort, key=cmp_to_key(mutating_cmp))
            def mutating_cmp(x, y):
                L.append(3)
                del L[:]
                return (x > y) - (x < y)
            self.assertRaises(ValueError, L.sort, key=cmp_to_key(mutating_cmp))
            memorywaster = [memorywaster]


            

Reported by Pylint.

Cell variable L defined in loop
Error

Line: 163 Column: 21

                          self.assertRaises(ValueError, L.sort, key=cmp_to_key(mutating_cmp))
            def mutating_cmp(x, y):
                L.append(3)
                del L[:]
                return (x > y) - (x < y)
            self.assertRaises(ValueError, L.sort, key=cmp_to_key(mutating_cmp))
            memorywaster = [memorywaster]

#==============================================================================

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from test import support
import random
import unittest
from functools import cmp_to_key

verbose = support.verbose
nerrors = 0



            

Reported by Pylint.

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

Line: 6 Column: 1

              import unittest
from functools import cmp_to_key

verbose = support.verbose
nerrors = 0


def check(tag, expected, raw, compare=None):
    global nerrors

            

Reported by Pylint.

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

Line: 7 Column: 1

              from functools import cmp_to_key

verbose = support.verbose
nerrors = 0


def check(tag, expected, raw, compare=None):
    global nerrors


            

Reported by Pylint.

Lib/test/test_email/test_defect_handling.py
108 issues
Instance of 'TestDefectsBase' has no '_str_msg' member
Error

Line: 57 Column: 19

                          """)
        # XXX better would be to actually detect the duplicate.
        with self._raise_point(errors.StartBoundaryNotFoundDefect):
            msg = self._str_msg(source)
        if self.raise_expected: return
        inner = msg.get_payload(0)
        self.assertTrue(hasattr(inner, 'defects'))
        self.assertEqual(len(self.get_defects(inner)), 1)
        self.assertIsInstance(self.get_defects(inner)[0],

            

Reported by Pylint.

Instance of 'TestDefectsBase' has no 'assertTrue' member
Error

Line: 60 Column: 9

                          msg = self._str_msg(source)
        if self.raise_expected: return
        inner = msg.get_payload(0)
        self.assertTrue(hasattr(inner, 'defects'))
        self.assertEqual(len(self.get_defects(inner)), 1)
        self.assertIsInstance(self.get_defects(inner)[0],
                              errors.StartBoundaryNotFoundDefect)

    def test_multipart_no_boundary(self):

            

Reported by Pylint.

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

Line: 61 Column: 9

                      if self.raise_expected: return
        inner = msg.get_payload(0)
        self.assertTrue(hasattr(inner, 'defects'))
        self.assertEqual(len(self.get_defects(inner)), 1)
        self.assertIsInstance(self.get_defects(inner)[0],
                              errors.StartBoundaryNotFoundDefect)

    def test_multipart_no_boundary(self):
        source = textwrap.dedent("""\

            

Reported by Pylint.

Instance of 'TestDefectsBase' has no 'get_defects' member
Error

Line: 61 Column: 30

                      if self.raise_expected: return
        inner = msg.get_payload(0)
        self.assertTrue(hasattr(inner, 'defects'))
        self.assertEqual(len(self.get_defects(inner)), 1)
        self.assertIsInstance(self.get_defects(inner)[0],
                              errors.StartBoundaryNotFoundDefect)

    def test_multipart_no_boundary(self):
        source = textwrap.dedent("""\

            

Reported by Pylint.

Instance of 'TestDefectsBase' has no 'get_defects' member
Error

Line: 62 Column: 31

                      inner = msg.get_payload(0)
        self.assertTrue(hasattr(inner, 'defects'))
        self.assertEqual(len(self.get_defects(inner)), 1)
        self.assertIsInstance(self.get_defects(inner)[0],
                              errors.StartBoundaryNotFoundDefect)

    def test_multipart_no_boundary(self):
        source = textwrap.dedent("""\
            Date: Fri, 6 Apr 2001 09:23:06 -0800 (GMT-0800)

            

Reported by Pylint.

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

Line: 62 Column: 9

                      inner = msg.get_payload(0)
        self.assertTrue(hasattr(inner, 'defects'))
        self.assertEqual(len(self.get_defects(inner)), 1)
        self.assertIsInstance(self.get_defects(inner)[0],
                              errors.StartBoundaryNotFoundDefect)

    def test_multipart_no_boundary(self):
        source = textwrap.dedent("""\
            Date: Fri, 6 Apr 2001 09:23:06 -0800 (GMT-0800)

            

Reported by Pylint.

Instance of 'TestDefectsBase' has no '_str_msg' member
Error

Line: 85 Column: 19

                          --JAB03225.986577786/zinfandel.lacita.com--
            """)
        with self._raise_point(errors.NoBoundaryInMultipartDefect):
            msg = self._str_msg(source)
        if self.raise_expected: return
        self.assertIsInstance(msg.get_payload(), str)
        self.assertEqual(len(self.get_defects(msg)), 2)
        self.assertIsInstance(self.get_defects(msg)[0],
                              errors.NoBoundaryInMultipartDefect)

            

Reported by Pylint.

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

Line: 87 Column: 9

                      with self._raise_point(errors.NoBoundaryInMultipartDefect):
            msg = self._str_msg(source)
        if self.raise_expected: return
        self.assertIsInstance(msg.get_payload(), str)
        self.assertEqual(len(self.get_defects(msg)), 2)
        self.assertIsInstance(self.get_defects(msg)[0],
                              errors.NoBoundaryInMultipartDefect)
        self.assertIsInstance(self.get_defects(msg)[1],
                              errors.MultipartInvariantViolationDefect)

            

Reported by Pylint.

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

Line: 88 Column: 9

                          msg = self._str_msg(source)
        if self.raise_expected: return
        self.assertIsInstance(msg.get_payload(), str)
        self.assertEqual(len(self.get_defects(msg)), 2)
        self.assertIsInstance(self.get_defects(msg)[0],
                              errors.NoBoundaryInMultipartDefect)
        self.assertIsInstance(self.get_defects(msg)[1],
                              errors.MultipartInvariantViolationDefect)


            

Reported by Pylint.

Instance of 'TestDefectsBase' has no 'get_defects' member
Error

Line: 88 Column: 30

                          msg = self._str_msg(source)
        if self.raise_expected: return
        self.assertIsInstance(msg.get_payload(), str)
        self.assertEqual(len(self.get_defects(msg)), 2)
        self.assertIsInstance(self.get_defects(msg)[0],
                              errors.NoBoundaryInMultipartDefect)
        self.assertIsInstance(self.get_defects(msg)[1],
                              errors.MultipartInvariantViolationDefect)


            

Reported by Pylint.