The following issues were found

Lib/test/support/__init__.py
266 issues
Unable to import '__init__.testresult'
Error

Line: 18 Column: 1

              import unittest
import warnings

from .testresult import get_test_runner


try:
    from _testcapi import unicode_legacy_string
except ImportError:

            

Reported by Pylint.

Value 'use_resources' doesn't support membership test
Error

Line: 285 Column: 49

                  Known resources are set by regrtest.py.  If not running under regrtest.py,
    all resources are assumed enabled unless use_resources has been set.
    """
    return use_resources is None or resource in use_resources

def requires(resource, msg=None):
    """Raise ResourceDenied if the specified resource is not available."""
    if not is_resource_enabled(resource):
        if msg is None:

            

Reported by Pylint.

Module '_testinternalcapi' has no 'get_config' member; maybe 'get_configs'?
Error

Line: 432 Column: 14

              
def has_no_debug_ranges():
    import _testinternalcapi
    config = _testinternalcapi.get_config()
    return bool(config['no_debug_ranges'])

def requires_debug_ranges(reason='requires co_positions / debug_ranges'):
    return unittest.skipIf(has_no_debug_ranges(), reason)


            

Reported by Pylint.

Unable to import '__init__.os_helper'
Error

Line: 529 Column: 5

              
def open_urlresource(url, *args, **kw):
    import urllib.request, urllib.parse
    from .os_helper import unlink
    try:
        import gzip
    except ImportError:
        gzip = None


            

Reported by Pylint.

Module '_testinternalcapi' has no 'SIZEOF_PYGC_HEAD' member
Error

Line: 689 Column: 17

                  # add GC header size
    if ((type(o) == type) and (o.__flags__ & _TPFLAGS_HEAPTYPE) or\
        ((type(o) != type) and (type(o).__flags__ & _TPFLAGS_HAVE_GC))):
        size += _testinternalcapi.SIZEOF_PYGC_HEAD
    msg = 'wrong size for %s: got %d, expected %d' \
            % (type(o), result, size)
    test.assertEqual(result, size, msg)

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

            

Reported by Pylint.

Unable to import '__init__.os_helper'
Error

Line: 1352 Column: 9

              class PythonSymlink:
    """Creates a symlink for the current Python executable"""
    def __init__(self, link=None):
        from .os_helper import TESTFN

        self.link = link or os.path.abspath(TESTFN)
        self._linked = []
        self.real = os.path.realpath(sys.executable)
        self._also_link = []

            

Reported by Pylint.

Unable to import '_winapi'
Error

Line: 1369 Column: 13

                  if sys.platform == "win32":
        def _platform_specific(self):
            import glob
            import _winapi

            if os.path.lexists(self.real) and not os.path.exists(self.real):
                # App symlink appears to not exist, but we want the
                # real executable here anyway
                self.real = _winapi.GetModuleFileName(0)

            

Reported by Pylint.

Module 'sys' has no 'dllhandle' member
Error

Line: 1376 Column: 45

                              # real executable here anyway
                self.real = _winapi.GetModuleFileName(0)

            dll = _winapi.GetModuleFileName(sys.dllhandle)
            src_dir = os.path.dirname(dll)
            dest_dir = os.path.dirname(self.link)
            self._also_link.append((
                dll,
                os.path.join(dest_dir, os.path.basename(dll))

            

Reported by Pylint.

Unable to import 'msvcrt'
Error

Line: 1614 Column: 13

                          return

        if sys.platform.startswith('win'):
            import msvcrt
            msvcrt.SetErrorMode(self.old_value)

            if self.old_modes:
                for report_type, (old_mode, old_file) in self.old_modes.items():
                    msvcrt.CrtSetReportMode(report_type, old_mode)

            

Reported by Pylint.

Module 'os' has no 'waitstatus_to_exitcode' member
Error

Line: 1994 Column: 17

                      # Windows implementation
        pid2, status = os.waitpid(pid, 0)

    exitcode2 = os.waitstatus_to_exitcode(status)
    if exitcode2 != exitcode:
        raise AssertionError(f"process {pid} exited with code {exitcode2}, "
                             f"but exit code {exitcode} is expected")

    # sanity check: it should not fail in practice

            

Reported by Pylint.

Lib/tkinter/test/widget_tests.py
265 issues
Instance of 'AbstractWidgetTest' has no 'assertEqual' member; maybe 'assertEqual2'?
Error

Line: 46 Column: 9

                  def assertEqual2(self, actual, expected, msg=None, eq=object.__eq__):
        if eq(actual, expected):
            return
        self.assertEqual(actual, expected, msg)

    def checkParam(self, widget, name, value, *, expected=_sentinel,
                   conv=False, eq=None):
        widget[name] = value
        if expected is _sentinel:

            

Reported by Pylint.

Instance of 'AbstractWidgetTest' has no 'assertEqual' member; maybe 'assertEqual2'?
Error

Line: 65 Column: 9

                      self.assertEqual2(widget[name], expected, eq=eq)
        self.assertEqual2(widget.cget(name), expected, eq=eq)
        t = widget.configure(name)
        self.assertEqual(len(t), 5)
        self.assertEqual2(t[4], expected, eq=eq)

    def checkInvalidParam(self, widget, name, value, errmsg=None, *,
                          keep_orig=True):
        orig = widget[name]

            

Reported by Pylint.

Instance of 'AbstractWidgetTest' has no 'assertRaises' member
Error

Line: 73 Column: 14

                      orig = widget[name]
        if errmsg is not None:
            errmsg = errmsg.format(value)
        with self.assertRaises(tkinter.TclError) as cm:
            widget[name] = value
        if errmsg is not None:
            self.assertEqual(str(cm.exception), errmsg)
        if keep_orig:
            self.assertEqual(widget[name], orig)

            

Reported by Pylint.

Instance of 'AbstractWidgetTest' has no 'assertEqual' member; maybe 'assertEqual2'?
Error

Line: 76 Column: 13

                      with self.assertRaises(tkinter.TclError) as cm:
            widget[name] = value
        if errmsg is not None:
            self.assertEqual(str(cm.exception), errmsg)
        if keep_orig:
            self.assertEqual(widget[name], orig)
        else:
            widget[name] = orig
        with self.assertRaises(tkinter.TclError) as cm:

            

Reported by Pylint.

Instance of 'AbstractWidgetTest' has no 'assertEqual' member; maybe 'assertEqual2'?
Error

Line: 78 Column: 13

                      if errmsg is not None:
            self.assertEqual(str(cm.exception), errmsg)
        if keep_orig:
            self.assertEqual(widget[name], orig)
        else:
            widget[name] = orig
        with self.assertRaises(tkinter.TclError) as cm:
            widget.configure({name: value})
        if errmsg is not None:

            

Reported by Pylint.

Instance of 'AbstractWidgetTest' has no 'assertRaises' member
Error

Line: 81 Column: 14

                          self.assertEqual(widget[name], orig)
        else:
            widget[name] = orig
        with self.assertRaises(tkinter.TclError) as cm:
            widget.configure({name: value})
        if errmsg is not None:
            self.assertEqual(str(cm.exception), errmsg)
        if keep_orig:
            self.assertEqual(widget[name], orig)

            

Reported by Pylint.

Instance of 'AbstractWidgetTest' has no 'assertEqual' member; maybe 'assertEqual2'?
Error

Line: 84 Column: 13

                      with self.assertRaises(tkinter.TclError) as cm:
            widget.configure({name: value})
        if errmsg is not None:
            self.assertEqual(str(cm.exception), errmsg)
        if keep_orig:
            self.assertEqual(widget[name], orig)
        else:
            widget[name] = orig


            

Reported by Pylint.

Instance of 'AbstractWidgetTest' has no 'assertEqual' member; maybe 'assertEqual2'?
Error

Line: 86 Column: 13

                      if errmsg is not None:
            self.assertEqual(str(cm.exception), errmsg)
        if keep_orig:
            self.assertEqual(widget[name], orig)
        else:
            widget[name] = orig

    def checkParams(self, widget, name, *values, **kwargs):
        for value in values:

            

Reported by Pylint.

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

Line: 140 Column: 9

                      def command(*args):
            pass
        widget[name] = command
        self.assertTrue(widget[name])
        self.checkParams(widget, name, '')

    def checkEnumParam(self, widget, name, *values, errmsg=None, **kwargs):
        self.checkParams(widget, name, *values, **kwargs)
        if errmsg is None:

            

Reported by Pylint.

Instance of 'AbstractWidgetTest' has no 'assertIsNotNone' member
Error

Line: 195 Column: 9

                      self.checkParam(widget, name, var, conv=str)

    def assertIsBoundingBox(self, bbox):
        self.assertIsNotNone(bbox)
        self.assertIsInstance(bbox, tuple)
        if len(bbox) != 4:
            self.fail('Invalid bounding box: %r' % (bbox,))
        for item in bbox:
            if not isinstance(item, int):

            

Reported by Pylint.

Lib/email/_header_value_parser.py
265 issues
Instance of 'ValueTerminal' has no 'token_type' member
Error

Line: 623 Column: 27

                                  last[-1].token_type == 'cfws'):
                res[-1] = TokenList(last[:-1])
            is_tl = isinstance(tok, TokenList)
            if (is_tl and last.token_type == 'dot' and
                    tok[0].token_type == 'cfws'):
                res.append(TokenList(tok[1:]))
            else:
                res.append(tok)
            last = res[-1]

            

Reported by Pylint.

Instance of 'Terminal' has no 'token_type' member
Error

Line: 886 Column: 47

                      return "{}({})".format(self.__class__.__name__, super().__repr__())

    def pprint(self):
        print(self.__class__.__name__ + '/' + self.token_type)

    @property
    def all_defects(self):
        return list(self.defects)


            

Reported by Pylint.

Instance of 'Terminal' has no 'defects' member
Error

Line: 890 Column: 21

              
    @property
    def all_defects(self):
        return list(self.defects)

    def _pp(self, indent=''):
        return ["{}{}/{}({}){}".format(
            indent,
            self.__class__.__name__,

            

Reported by Pylint.

Instance of 'Terminal' has no 'token_type' member
Error

Line: 896 Column: 13

                      return ["{}{}/{}({}){}".format(
            indent,
            self.__class__.__name__,
            self.token_type,
            super().__repr__(),
            '' if not self.defects else ' {}'.format(self.defects),
            )]

    def pop_trailing_ws(self):

            

Reported by Pylint.

Instance of 'Terminal' has no 'defects' member
Error

Line: 898 Column: 54

                          self.__class__.__name__,
            self.token_type,
            super().__repr__(),
            '' if not self.defects else ' {}'.format(self.defects),
            )]

    def pop_trailing_ws(self):
        # This terminates the recursion.
        return None

            

Reported by Pylint.

Instance of 'Terminal' has no 'defects' member
Error

Line: 898 Column: 23

                          self.__class__.__name__,
            self.token_type,
            super().__repr__(),
            '' if not self.defects else ' {}'.format(self.defects),
            )]

    def pop_trailing_ws(self):
        # This terminates the recursion.
        return None

            

Reported by Pylint.

Instance of 'Terminal' has no 'token_type' member
Error

Line: 910 Column: 27

                      return []

    def __getnewargs__(self):
        return(str(self), self.token_type)


class WhiteSpaceTerminal(Terminal):

    @property

            

Reported by Pylint.

Instance of 'ValueTerminal' has no 'defects' member
Error

Line: 1545 Column: 9

                  ptext, value, had_qp = _get_ptext_to_endchars(value, '[]')
    ptext = ValueTerminal(ptext, 'ptext')
    if had_qp:
        ptext.defects.append(errors.ObsoleteHeaderDefect(
            "quoted printable found in domain-literal"))
    _validate_xtext(ptext)
    return ptext, value

def _check_for_early_dl_end(value, domain_literal):

            

Reported by Pylint.

Module 'email.errors' has no 'InvalidHeaderError' member
Error

Line: 2382 Column: 32

                      digits += value[0]
        value = value[1:]
    if digits[0] == '0' and digits != '0':
        section.defects.append(errors.InvalidHeaderError(
                "section number has an invalid leading 0"))
    section.number = int(digits)
    section.append(ValueTerminal(digits, 'digits'))
    return section, value


            

Reported by Pylint.

Access to a protected member _pp of a client class
Error

Line: 174 Column: 28

                              yield (indent + '    !! invalid element in token '
                                        'list: {!r}'.format(token))
            else:
                yield from token._pp(indent+'    ')
        if self.defects:
            extra = ' Defects: {}'.format(self.defects)
        else:
            extra = ''
        yield '{}){}'.format(indent, extra)

            

Reported by Pylint.

Lib/test/test_pydoc.py
259 issues
Unable to import 'test_error_package'
Error

Line: 974 Column: 21

                          sys.path.insert(0, TESTFN)
            try:
                with self.assertRaisesRegex(ValueError, "ouch"):
                    import test_error_package  # Sanity check

                text = self.call_url_handler("search?key=test_error_package",
                    "Pydoc: Search Results")
                found = ('<a href="test_error_package.html">'
                    'test_error_package</a>')

            

Reported by Pylint.

Class 'Point' has no 'x' member
Error

Line: 1202 Column: 49

                  def test_slot_descriptor(self):
        class Point:
            __slots__ = 'x', 'y'
        self.assertEqual(self._get_summary_line(Point.x), "x")

    @requires_docstrings
    def test_dict_attr_descriptor(self):
        class NS:
            pass

            

Reported by Pylint.

Instance of 'Rect' has no 'h' member
Error

Line: 1235 Column: 33

                          @property
            def area(self):
                '''Area of the rect'''
                return self.w * self.h

        self.assertEqual(self._get_summary_lines(Rect.area), """\
    Area of the rect
""")
        self.assertIn("""

            

Reported by Pylint.

Instance of 'Rect' has no 'w' member
Error

Line: 1235 Column: 24

                          @property
            def area(self):
                '''Area of the rect'''
                return self.w * self.h

        self.assertEqual(self._get_summary_lines(Rect.area), """\
    Area of the rect
""")
        self.assertIn("""

            

Reported by Pylint.

Super of 'Meta' has no '__getattr__' member
Error

Line: 1401 Column: 24

                          def __getattr__(self, name):
                if name == 'ham':
                    return 'spam'
                return super().__getattr__(name)
        class DA(metaclass=Meta):
            @types.DynamicClassAttribute
            def ham(self):
                return 'eggs'
        expected_text_data_docstrings = tuple('\n |      ' + s if s else ''

            

Reported by Pylint.

Super of 'Meta' has no '__getattr' member
Error

Line: 1427 Column: 24

                          def __getattr__(self, name):
                if name =='LIFE':
                    return 42
                return super().__getattr(name)
        class Class(metaclass=Meta):
            pass
        output = StringIO()
        helper = pydoc.Helper(output=output)
        helper(Class)

            

Reported by Pylint.

Super of 'Meta1' has no '__getattr__' member
Error

Line: 1448 Column: 24

                          def __getattr__(self, name):
                if name =='one':
                    return 1
                return super().__getattr__(name)
        class Meta2(type):
            def __dir__(cls):
                return ['__class__', '__module__', '__name__', 'two']
            def __getattr__(self, name):
                if name =='two':

            

Reported by Pylint.

Super of 'Meta2' has no '__getattr__' member
Error

Line: 1455 Column: 24

                          def __getattr__(self, name):
                if name =='two':
                    return 2
                return super().__getattr__(name)
        class Meta3(Meta1, Meta2):
            def __dir__(cls):
                return list(sorted(set(
                    ['__class__', '__module__', '__name__', 'three'] +
                    Meta1.__dir__(cls) + Meta2.__dir__(cls))))

            

Reported by Pylint.

Unused import string
Error

Line: 13 Column: 1

              import pkgutil
import re
import stat
import string
import tempfile
import test.support
import time
import types
import typing

            

Reported by Pylint.

Unnecessary pass statement
Error

Line: 37 Column: 5

              
class nonascii:
    'Це не латиниця'
    pass

if test.support.HAVE_DOCSTRINGS:
    expected_data_docstrings = (
        'dictionary for instance variables (if defined)',
        'list of weak references to the object (if defined)',

            

Reported by Pylint.

Lib/test/test_winreg.py
257 issues
Unable to import 'winreg'
Error

Line: 14 Column: 1

              # Do this first so test will be skipped if module doesn't exist
import_helper.import_module('winreg', required_on=['win'])
# Now import everything
from winreg import *

try:
    REMOTE_NAME = sys.argv[sys.argv.index("--remote")+1]
except (IndexError, ValueError):
    REMOTE_NAME = None

            

Reported by Pylint.

Module 'sys' has no 'getwindowsversion' member
Error

Line: 22 Column: 11

                  REMOTE_NAME = None

# tuple of (major, minor)
WIN_VER = sys.getwindowsversion()[:2]
# Some tests should only run on 64-bit architectures where WOW64 will be.
WIN64_MACHINE = True if machine() == "AMD64" else False

# Starting with Windows 7 and Windows Server 2008 R2, WOW64 no longer uses
# registry reflection and formerly reflected keys are shared instead.

            

Reported by Pylint.

Undefined variable 'REG_DWORD'
Error

Line: 40 Column: 64

              test_reflect_key_name = "SOFTWARE\\Classes\\" + test_key_base

test_data = [
    ("Int Value",     45,                                      REG_DWORD),
    ("Qword Value",   0x1122334455667788,                      REG_QWORD),
    ("String Val",    "A string value",                        REG_SZ),
    ("StringExpand",  "The path is %path%",                    REG_EXPAND_SZ),
    ("Multi-string",  ["Lots", "of", "string", "values"],      REG_MULTI_SZ),
    ("Multi-nul",     ["", "", "", ""],                        REG_MULTI_SZ),

            

Reported by Pylint.

Undefined variable 'REG_QWORD'
Error

Line: 41 Column: 64

              
test_data = [
    ("Int Value",     45,                                      REG_DWORD),
    ("Qword Value",   0x1122334455667788,                      REG_QWORD),
    ("String Val",    "A string value",                        REG_SZ),
    ("StringExpand",  "The path is %path%",                    REG_EXPAND_SZ),
    ("Multi-string",  ["Lots", "of", "string", "values"],      REG_MULTI_SZ),
    ("Multi-nul",     ["", "", "", ""],                        REG_MULTI_SZ),
    ("Raw Data",      b"binary\x00data",                       REG_BINARY),

            

Reported by Pylint.

Undefined variable 'REG_SZ'
Error

Line: 42 Column: 64

              test_data = [
    ("Int Value",     45,                                      REG_DWORD),
    ("Qword Value",   0x1122334455667788,                      REG_QWORD),
    ("String Val",    "A string value",                        REG_SZ),
    ("StringExpand",  "The path is %path%",                    REG_EXPAND_SZ),
    ("Multi-string",  ["Lots", "of", "string", "values"],      REG_MULTI_SZ),
    ("Multi-nul",     ["", "", "", ""],                        REG_MULTI_SZ),
    ("Raw Data",      b"binary\x00data",                       REG_BINARY),
    ("Big String",    "x"*(2**14-1),                           REG_SZ),

            

Reported by Pylint.

Undefined variable 'REG_EXPAND_SZ'
Error

Line: 43 Column: 64

                  ("Int Value",     45,                                      REG_DWORD),
    ("Qword Value",   0x1122334455667788,                      REG_QWORD),
    ("String Val",    "A string value",                        REG_SZ),
    ("StringExpand",  "The path is %path%",                    REG_EXPAND_SZ),
    ("Multi-string",  ["Lots", "of", "string", "values"],      REG_MULTI_SZ),
    ("Multi-nul",     ["", "", "", ""],                        REG_MULTI_SZ),
    ("Raw Data",      b"binary\x00data",                       REG_BINARY),
    ("Big String",    "x"*(2**14-1),                           REG_SZ),
    ("Big Binary",    b"x"*(2**14),                            REG_BINARY),

            

Reported by Pylint.

Undefined variable 'REG_MULTI_SZ'
Error

Line: 44 Column: 64

                  ("Qword Value",   0x1122334455667788,                      REG_QWORD),
    ("String Val",    "A string value",                        REG_SZ),
    ("StringExpand",  "The path is %path%",                    REG_EXPAND_SZ),
    ("Multi-string",  ["Lots", "of", "string", "values"],      REG_MULTI_SZ),
    ("Multi-nul",     ["", "", "", ""],                        REG_MULTI_SZ),
    ("Raw Data",      b"binary\x00data",                       REG_BINARY),
    ("Big String",    "x"*(2**14-1),                           REG_SZ),
    ("Big Binary",    b"x"*(2**14),                            REG_BINARY),
    # Two and three kanjis, meaning: "Japan" and "Japanese")

            

Reported by Pylint.

Undefined variable 'REG_MULTI_SZ'
Error

Line: 45 Column: 64

                  ("String Val",    "A string value",                        REG_SZ),
    ("StringExpand",  "The path is %path%",                    REG_EXPAND_SZ),
    ("Multi-string",  ["Lots", "of", "string", "values"],      REG_MULTI_SZ),
    ("Multi-nul",     ["", "", "", ""],                        REG_MULTI_SZ),
    ("Raw Data",      b"binary\x00data",                       REG_BINARY),
    ("Big String",    "x"*(2**14-1),                           REG_SZ),
    ("Big Binary",    b"x"*(2**14),                            REG_BINARY),
    # Two and three kanjis, meaning: "Japan" and "Japanese")
    ("Japanese 日本", "日本語", REG_SZ),

            

Reported by Pylint.

Undefined variable 'REG_BINARY'
Error

Line: 46 Column: 64

                  ("StringExpand",  "The path is %path%",                    REG_EXPAND_SZ),
    ("Multi-string",  ["Lots", "of", "string", "values"],      REG_MULTI_SZ),
    ("Multi-nul",     ["", "", "", ""],                        REG_MULTI_SZ),
    ("Raw Data",      b"binary\x00data",                       REG_BINARY),
    ("Big String",    "x"*(2**14-1),                           REG_SZ),
    ("Big Binary",    b"x"*(2**14),                            REG_BINARY),
    # Two and three kanjis, meaning: "Japan" and "Japanese")
    ("Japanese 日本", "日本語", REG_SZ),
]

            

Reported by Pylint.

Undefined variable 'REG_SZ'
Error

Line: 47 Column: 64

                  ("Multi-string",  ["Lots", "of", "string", "values"],      REG_MULTI_SZ),
    ("Multi-nul",     ["", "", "", ""],                        REG_MULTI_SZ),
    ("Raw Data",      b"binary\x00data",                       REG_BINARY),
    ("Big String",    "x"*(2**14-1),                           REG_SZ),
    ("Big Binary",    b"x"*(2**14),                            REG_BINARY),
    # Two and three kanjis, meaning: "Japan" and "Japanese")
    ("Japanese 日本", "日本語", REG_SZ),
]


            

Reported by Pylint.

Lib/test/test_csv.py
257 issues
Instance of 'TestCsvBase' has no 'dialect' member
Error

Line: 505 Column: 52

                      with TemporaryFile("w+", encoding="utf-8", newline='') as fileobj:
            fileobj.write(input)
            fileobj.seek(0)
            reader = csv.reader(fileobj, dialect = self.dialect)
            fields = list(reader)
            self.assertEqual(fields, expected_result)

    def writerAssertEqual(self, input, expected_result):
        with TemporaryFile("w+", encoding="utf-8", newline='') as fileobj:

            

Reported by Pylint.

Instance of 'TestCsvBase' has no 'dialect' member
Error

Line: 511 Column: 52

              
    def writerAssertEqual(self, input, expected_result):
        with TemporaryFile("w+", encoding="utf-8", newline='') as fileobj:
            writer = csv.writer(fileobj, dialect = self.dialect)
            writer.writerows(input)
            fileobj.seek(0)
            self.assertEqual(fileobj.read(), expected_result)

class TestDialectExcel(TestCsvBase):

            

Reported by Pylint.

Method should have "self" as first argument
Error

Line: 1131 Column: 5

                      self.assertTrue(dialect.doublequote)

class NUL:
    def write(s, *args):
        pass
    writelines = write

@unittest.skipUnless(hasattr(sys, "gettotalrefcount"),
                     'requires sys.gettotalrefcount()')

            

Reported by Pylint.

Module 'sys' has no 'gettotalrefcount' member
Error

Line: 1140 Column: 18

              class TestLeaks(unittest.TestCase):
    def test_create_read(self):
        delta = 0
        lastrc = sys.gettotalrefcount()
        for i in range(20):
            gc.collect()
            self.assertEqual(gc.garbage, [])
            rc = sys.gettotalrefcount()
            csv.reader(["a,b,c\r\n"])

            

Reported by Pylint.

Module 'sys' has no 'gettotalrefcount' member
Error

Line: 1144 Column: 18

                      for i in range(20):
            gc.collect()
            self.assertEqual(gc.garbage, [])
            rc = sys.gettotalrefcount()
            csv.reader(["a,b,c\r\n"])
            csv.reader(["a,b,c\r\n"])
            csv.reader(["a,b,c\r\n"])
            delta = rc-lastrc
            lastrc = rc

            

Reported by Pylint.

Module 'sys' has no 'gettotalrefcount' member
Error

Line: 1155 Column: 18

              
    def test_create_write(self):
        delta = 0
        lastrc = sys.gettotalrefcount()
        s = NUL()
        for i in range(20):
            gc.collect()
            self.assertEqual(gc.garbage, [])
            rc = sys.gettotalrefcount()

            

Reported by Pylint.

Module 'sys' has no 'gettotalrefcount' member
Error

Line: 1160 Column: 18

                      for i in range(20):
            gc.collect()
            self.assertEqual(gc.garbage, [])
            rc = sys.gettotalrefcount()
            csv.writer(s)
            csv.writer(s)
            csv.writer(s)
            delta = rc-lastrc
            lastrc = rc

            

Reported by Pylint.

Module 'sys' has no 'gettotalrefcount' member
Error

Line: 1172 Column: 18

                  def test_read(self):
        delta = 0
        rows = ["a,b,c\r\n"]*5
        lastrc = sys.gettotalrefcount()
        for i in range(20):
            gc.collect()
            self.assertEqual(gc.garbage, [])
            rc = sys.gettotalrefcount()
            rdr = csv.reader(rows)

            

Reported by Pylint.

Module 'sys' has no 'gettotalrefcount' member
Error

Line: 1176 Column: 18

                      for i in range(20):
            gc.collect()
            self.assertEqual(gc.garbage, [])
            rc = sys.gettotalrefcount()
            rdr = csv.reader(rows)
            for row in rdr:
                pass
            delta = rc-lastrc
            lastrc = rc

            

Reported by Pylint.

Module 'sys' has no 'gettotalrefcount' member
Error

Line: 1189 Column: 18

                      delta = 0
        rows = [[1,2,3]]*5
        s = NUL()
        lastrc = sys.gettotalrefcount()
        for i in range(20):
            gc.collect()
            self.assertEqual(gc.garbage, [])
            rc = sys.gettotalrefcount()
            writer = csv.writer(s)

            

Reported by Pylint.

Lib/test/test_fileinput.py
256 issues
Instance of 'BaseTests' has no 'addCleanup' member
Error

Line: 46 Column: 9

                  # temp file's name.
    def writeTmp(self, content, *, mode='w'):  # opening in text mode is the default
        fd, name = tempfile.mkstemp()
        self.addCleanup(os_helper.unlink, name)
        encoding = None if "b" in mode else "utf-8"
        with open(fd, mode, encoding=encoding) as f:
            f.write(content)
        return name


            

Reported by Pylint.

Unused argument 'mode'
Error

Line: 64 Column: 34

                      finally:
            self._linesread = []

    def openhook(self, filename, mode):
        self.it = iter(filename.splitlines(True))
        return self

    def readline(self, size=None):
        line = next(self.it, '')

            

Reported by Pylint.

Attribute 'it' defined outside __init__
Error

Line: 65 Column: 9

                          self._linesread = []

    def openhook(self, filename, mode):
        self.it = iter(filename.splitlines(True))
        return self

    def readline(self, size=None):
        line = next(self.it, '')
        self._linesread.append(line)

            

Reported by Pylint.

Unused argument 'size'
Error

Line: 68 Column: 24

                      self.it = iter(filename.splitlines(True))
        return self

    def readline(self, size=None):
        line = next(self.it, '')
        self._linesread.append(line)
        return line

    def readlines(self, hint=-1):

            

Reported by Pylint.

# # XXX A unicode string is always returned by writeTmp.
Error

Line: 211 Column: 14

                      self.assertEqual(fi.lineno(), 6)

##     def test_unicode_filenames(self):
##         # XXX A unicode string is always returned by writeTmp.
##         #     So is this needed?
##         t1 = self.writeTmp("A\nB")
##         encoding = sys.getfilesystemencoding()
##         if encoding is None:
##             encoding = 'ascii'

            

Reported by Pylint.

Unused variable 'line'
Error

Line: 226 Column: 9

                      t2 = self.writeTmp("C\nD")
        fi = FileInput(files=(t1, t2), encoding="utf-8")
        self.assertEqual(fi.fileno(), -1)
        line = next(fi)
        self.assertNotEqual(fi.fileno(), -1)
        fi.nextfile()
        self.assertEqual(fi.fileno(), -1)
        line = list(fi)
        self.assertEqual(fi.fileno(), -1)

            

Reported by Pylint.

Unused argument 'filename'
Error

Line: 340 Column: 22

                          self.assertEqual(f.read(), b'New line.')

    def test_file_hook_backward_compatibility(self):
        def old_hook(filename, mode):
            return io.StringIO("I used to receive only filename and mode")
        t = self.writeTmp("\n")
        with FileInput([t], openhook=old_hook) as fi:
            result = fi.readline()
        self.assertEqual(result, "I used to receive only filename and mode")

            

Reported by Pylint.

Unused argument 'mode'
Error

Line: 340 Column: 32

                          self.assertEqual(f.read(), b'New line.')

    def test_file_hook_backward_compatibility(self):
        def old_hook(filename, mode):
            return io.StringIO("I used to receive only filename and mode")
        t = self.writeTmp("\n")
        with FileInput([t], openhook=old_hook) as fi:
            result = fi.readline()
        self.assertEqual(result, "I used to receive only filename and mode")

            

Reported by Pylint.

Access to a protected member _files of a client class
Error

Line: 355 Column: 26

                      self.assertEqual(lines, ["A\n", "B\n", "C", "D\n", "E\n", "F"])
        self.assertEqual(fi.filelineno(), 3)
        self.assertEqual(fi.lineno(), 6)
        self.assertEqual(fi._files, ())

    def test_close_on_exception(self):
        t1 = self.writeTmp("")
        try:
            with FileInput(files=t1, encoding="utf-8") as fi:

            

Reported by Pylint.

Access to a protected member _files of a client class
Error

Line: 363 Column: 30

                          with FileInput(files=t1, encoding="utf-8") as fi:
                raise OSError
        except OSError:
            self.assertEqual(fi._files, ())

    def test_empty_files_list_specified_to_constructor(self):
        with FileInput(files=[], encoding="utf-8") as fi:
            self.assertEqual(fi._files, ('-',))


            

Reported by Pylint.

Lib/pickle.py
256 issues
Assigning result of a function call, where the function returns None
Error

Line: 539 Column: 9

                      self.framer.commit_frame()

        # Check for persistent id (defined by a subclass)
        pid = self.persistent_id(obj)
        if pid is not None and save_persistent_id:
            self.save_pers(pid)
            return

        # Check the memo

            

Reported by Pylint.

reduce is not callable
Error

Line: 553 Column: 18

                      rv = NotImplemented
        reduce = getattr(self, "reducer_override", None)
        if reduce is not None:
            rv = reduce(obj)

        if rv is NotImplemented:
            # Check the type dispatch table
            t = type(obj)
            f = self.dispatch.get(t)

            

Reported by Pylint.

Unnecessary pass statement
Error

Line: 75 Column: 5

              
class PickleError(Exception):
    """A common base class for the other pickling exceptions."""
    pass

class PicklingError(PickleError):
    """This exception is raised when an unpicklable object is passed to the
    dump() method.


            

Reported by Pylint.

Unnecessary pass statement
Error

Line: 82 Column: 5

                  dump() method.

    """
    pass

class UnpicklingError(PickleError):
    """This exception is raised when there is a problem unpickling an object,
    such as a security violation.


            

Reported by Pylint.

Unnecessary pass statement
Error

Line: 93 Column: 5

                  and IndexError.

    """
    pass

# An instance of _Stop is raised by Unpickler.load_stop() in response to
# the STOP opcode, passing the object that is the result of unpickling.
class _Stop(Exception):
    def __init__(self, value):

            

Reported by Pylint.

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

Line: 98 Column: 5

              # An instance of _Stop is raised by Unpickler.load_stop() in response to
# the STOP opcode, passing the object that is the result of unpickling.
class _Stop(Exception):
    def __init__(self, value):
        self.value = value

# Jython has PyStringMap; it's a dict subclass with string keys
try:
    from org.python.core import PyStringMap

            

Reported by Pylint.

Redefining name 'f' from outer scope (line 1818)
Error

Line: 219 Column: 13

              
    def commit_frame(self, force=False):
        if self.current_frame:
            f = self.current_frame
            if f.tell() >= self._FRAME_SIZE_TARGET or force:
                data = f.getbuffer()
                write = self.file_write
                if len(data) >= self._FRAME_SIZE_MIN:
                    # Issue a single call to the write method of the underlying

            

Reported by Pylint.

Unused argument 'file_tell'
Error

Line: 265 Column: 50

              
class _Unframer:

    def __init__(self, file_read, file_readline, file_tell=None):
        self.file_read = file_read
        self.file_readline = file_readline
        self.current_frame = None

    def readinto(self, buf):

            

Reported by Pylint.

Redefining name 'obj' from outer scope (line 1819)
Error

Line: 322 Column: 19

              
# Tools used for pickling.

def _getattribute(obj, name):
    for subpath in name.split('.'):
        if subpath == '<locals>':
            raise AttributeError("Can't get local attribute {!r} on {!r}"
                                 .format(name, obj))
        try:

            

Reported by Pylint.

Redefining name 'obj' from outer scope (line 1819)
Error

Line: 335 Column: 17

                                               .format(name, obj)) from None
    return obj, parent

def whichmodule(obj, name):
    """Find the module an object belong to."""
    module_name = getattr(obj, '__module__', None)
    if module_name is not None:
        return module_name
    # Protect the iteration by using a list copy of sys.modules against dynamic

            

Reported by Pylint.

Lib/test/test_http_cookiejar.py
256 issues
Cannot import 'traceback' due to syntax error 'invalid syntax (<unknown>, line 576)'
Error

Line: 258 Column: 1

                          try:
                result = split_header_words([arg])
            except:
                import traceback, io
                f = io.StringIO()
                traceback.print_exc(None, f)
                result = "(error -- traceback follows)\n\n%s" % f.getvalue()
            self.assertEqual(result,  expect, """
When parsing: '%s'

            

Reported by Pylint.

Assigning result of a function call, where the function has no return
Error

Line: 1009 Column: 9

                      c.extract_cookies(res, req)
        self.assertEqual(len(c), 0)

        p = pol.set_blocked_domains(["acme.com"])
        c.extract_cookies(res, req)
        self.assertEqual(len(c), 1)

        c.clear()
        req = urllib.request.Request("http://www.roadrunner.net/")

            

Reported by Pylint.

Assigning result of a function call, where the function has no return
Error

Line: 1056 Column: 9

                      self.assertFalse(pol.return_ok(cookies[0], req))
        self.assertFalse(req.has_header("Cookie"))

        p = pol.set_blocked_domains(["acme.com"])
        req = urllib.request.Request("http://acme.com/")
        c.add_cookie_header(req)
        self.assertFalse(req.has_header("Cookie"))

        req = urllib.request.Request("http://badacme.com/")

            

Reported by Pylint.

Redefining name 'test' from outer scope (line 5)
Error

Line: 108 Column: 13

                          self.assertEqual(http2time(s.upper()), test_t, s.upper())

    def test_http2time_garbage(self):
        for test in [
            '',
            'Garbage',
            'Mandag 16. September 1996',
            '01-00-1980',
            '01-13-1980',

            

Reported by Pylint.

Redefining name 'test' from outer scope (line 5)
Error

Line: 175 Column: 13

                          self.assertEqual(iso2time(s.upper()), test_t, s.upper())

    def test_iso2time_garbage(self):
        for test in [
            '',
            'Garbage',
            'Thursday, 03-Feb-94 00:00:00 GMT',
            '1980-00-01',
            '1980-13-01',

            

Reported by Pylint.

No exception type(s) specified
Error

Line: 257 Column: 13

                      for arg, expect in tests:
            try:
                result = split_header_words([arg])
            except:
                import traceback, io
                f = io.StringIO()
                traceback.print_exc(None, f)
                result = "(error -- traceback follows)\n\n%s" % f.getvalue()
            self.assertEqual(result,  expect, """

            

Reported by Pylint.

Redefining built-in 'input'
Error

Line: 292 Column: 13

                          ]

        for arg, expect in tests:
            input = split_header_words([arg])
            res = join_header_words(input)
            self.assertEqual(res, expect, """
When parsing: '%s'
Expected:     '%s'
Got:          '%s'

            

Reported by Pylint.

Dangerous default value [] as argument
Error

Line: 303 Column: 5

              

class FakeResponse:
    def __init__(self, headers=[], url=None):
        """
        headers: list of RFC822-style 'Key: value' strings
        """
        import email
        self._headers = email.message_from_string("\n".join(headers))

            

Reported by Pylint.

Unused variable 'c'
Error

Line: 354 Column: 21

                          with self.subTest(filename=type_):
                with self.assertRaises(TypeError):
                    instance = type_()
                    c = LWPCookieJar(filename=instance)

    def test_lwp_valueless_cookie(self):
        # cookies with no value should be saved and loaded consistently
        filename = os_helper.TESTFN
        c = LWPCookieJar()

            

Reported by Pylint.

Access to a protected member _cookies of a client class
Error

Line: 361 Column: 26

                      filename = os_helper.TESTFN
        c = LWPCookieJar()
        interact_netscape(c, "http://www.acme.com/", 'boo')
        self.assertEqual(c._cookies["www.acme.com"]["/"]["boo"].value, None)
        try:
            c.save(filename, ignore_discard=True)
            c = LWPCookieJar()
            c.load(filename, ignore_discard=True)
        finally:

            

Reported by Pylint.

Lib/test/test_heapq.py
254 issues
Instance of 'TestHeap' has no 'module' member
Error

Line: 58 Column: 13

                      for i in range(256):
            item = random.random()
            data.append(item)
            self.module.heappush(heap, item)
            self.check_invariant(heap)
        results = []
        while heap:
            item = self.module.heappop(heap)
            self.check_invariant(heap)

            

Reported by Pylint.

Instance of 'TestHeap' has no 'module' member
Error

Line: 62 Column: 20

                          self.check_invariant(heap)
        results = []
        while heap:
            item = self.module.heappop(heap)
            self.check_invariant(heap)
            results.append(item)
        data_sorted = data[:]
        data_sorted.sort()
        self.assertEqual(data_sorted, results)

            

Reported by Pylint.

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

Line: 67 Column: 9

                          results.append(item)
        data_sorted = data[:]
        data_sorted.sort()
        self.assertEqual(data_sorted, results)
        # 2) Check that the invariant holds for a sorted array
        self.check_invariant(results)

        self.assertRaises(TypeError, self.module.heappush, [])
        try:

            

Reported by Pylint.

Instance of 'TestHeap' has no 'module' member
Error

Line: 71 Column: 38

                      # 2) Check that the invariant holds for a sorted array
        self.check_invariant(results)

        self.assertRaises(TypeError, self.module.heappush, [])
        try:
            self.assertRaises(TypeError, self.module.heappush, None, None)
            self.assertRaises(TypeError, self.module.heappop, None)
        except AttributeError:
            pass

            

Reported by Pylint.

Instance of 'TestHeap' has no 'assertRaises' member
Error

Line: 71 Column: 9

                      # 2) Check that the invariant holds for a sorted array
        self.check_invariant(results)

        self.assertRaises(TypeError, self.module.heappush, [])
        try:
            self.assertRaises(TypeError, self.module.heappush, None, None)
            self.assertRaises(TypeError, self.module.heappop, None)
        except AttributeError:
            pass

            

Reported by Pylint.

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

Line: 83 Column: 17

                      for pos, item in enumerate(heap):
            if pos: # pos 0 has no parent
                parentpos = (pos-1) >> 1
                self.assertTrue(heap[parentpos] <= item)

    def test_heapify(self):
        for size in list(range(30)) + [20000]:
            heap = [random.random() for dummy in range(size)]
            self.module.heapify(heap)

            

Reported by Pylint.

Instance of 'TestHeap' has no 'module' member
Error

Line: 88 Column: 13

                  def test_heapify(self):
        for size in list(range(30)) + [20000]:
            heap = [random.random() for dummy in range(size)]
            self.module.heapify(heap)
            self.check_invariant(heap)

        self.assertRaises(TypeError, self.module.heapify, None)

    def test_naive_nbest(self):

            

Reported by Pylint.

Instance of 'TestHeap' has no 'assertRaises' member
Error

Line: 91 Column: 9

                          self.module.heapify(heap)
            self.check_invariant(heap)

        self.assertRaises(TypeError, self.module.heapify, None)

    def test_naive_nbest(self):
        data = [random.randrange(2000) for i in range(1000)]
        heap = []
        for item in data:

            

Reported by Pylint.

Instance of 'TestHeap' has no 'module' member
Error

Line: 91 Column: 38

                          self.module.heapify(heap)
            self.check_invariant(heap)

        self.assertRaises(TypeError, self.module.heapify, None)

    def test_naive_nbest(self):
        data = [random.randrange(2000) for i in range(1000)]
        heap = []
        for item in data:

            

Reported by Pylint.

Instance of 'TestHeap' has no 'module' member
Error

Line: 97 Column: 13

                      data = [random.randrange(2000) for i in range(1000)]
        heap = []
        for item in data:
            self.module.heappush(heap, item)
            if len(heap) > 10:
                self.module.heappop(heap)
        heap.sort()
        self.assertEqual(heap, sorted(data)[-10:])


            

Reported by Pylint.