The following issues were found

Lib/test/test_timeit.py
90 issues
XXX: some tests are commented out that would improve the coverage but take a
Error

Line: 16 Column: 3

              # timeit's default number of repetitions.
DEFAULT_REPEAT = 5

# XXX: some tests are commented out that would improve the coverage but take a
# long time to run because they test the default number of loops, which is
# large.  The tests could be enabled if there was a way to override the default
# number of loops during testing, but this would require changing the signature
# of some functions that use the default as a default argument.


            

Reported by Pylint.

Attribute 'saved_timer' defined outside __init__
Error

Line: 41 Column: 9

              
    def wrap_timer(self, timer):
        """Records 'timer' and returns self as callable timer."""
        self.saved_timer = timer
        return self

class TestTimeit(unittest.TestCase):

    def tearDown(self):

            

Reported by Pylint.

Redefining built-in 'globals'
Error

Line: 108 Column: 48

                  def fake_callable_stmt(self):
        self.fake_timer.inc()

    def timeit(self, stmt, setup, number=None, globals=None):
        self.fake_timer = FakeTimer()
        t = timeit.Timer(stmt=stmt, setup=setup, timer=self.fake_timer,
                globals=globals)
        kwargs = {}
        if number is None:

            

Reported by Pylint.

Attribute 'fake_timer' defined outside __init__
Error

Line: 109 Column: 9

                      self.fake_timer.inc()

    def timeit(self, stmt, setup, number=None, globals=None):
        self.fake_timer = FakeTimer()
        t = timeit.Timer(stmt=stmt, setup=setup, timer=self.fake_timer,
                globals=globals)
        kwargs = {}
        if number is None:
            number = DEFAULT_NUMBER

            

Reported by Pylint.

Global variable '_global_timer' undefined at the module level
Error

Line: 154 Column: 9

                      self.assertEqual(delta_time, 0)

    def test_timeit_globals_args(self):
        global _global_timer
        _global_timer = FakeTimer()
        t = timeit.Timer(stmt='_global_timer.inc()', timer=_global_timer)
        self.assertRaises(NameError, t.timeit, number=3)
        timeit.timeit(stmt='_global_timer.inc()', timer=_global_timer,
                      globals=globals(), number=3)

            

Reported by Pylint.

Attribute 'fake_timer' defined outside __init__
Error

Line: 165 Column: 9

                                    globals=locals(), number=3)

    def repeat(self, stmt, setup, repeat=None, number=None):
        self.fake_timer = FakeTimer()
        t = timeit.Timer(stmt=stmt, setup=setup, timer=self.fake_timer)
        kwargs = {}
        if repeat is None:
            repeat = DEFAULT_REPEAT
        else:

            

Reported by Pylint.

No exception type(s) specified
Error

Line: 233 Column: 9

                      t = timeit.Timer("1/0")
        try:
            t.timeit()
        except:
            t.print_exc(s)
        self.assert_exc_string(s.getvalue(), 'ZeroDivisionError')

    MAIN_DEFAULT_OUTPUT = "1 loop, best of 5: 1 sec per loop\n"


            

Reported by Pylint.

Unused variable 'invalid'
Error

Line: 351 Column: 13

                              "100 loops, best of 5: 3e+03 usec per loop\n")
        # Test invalid unit input
        with captured_stderr() as error_stringio:
            invalid = self.run_main(seconds_per_increment=0.003,
                    switches=['-u', 'parsec'])
        self.assertEqual(error_stringio.getvalue(),
                    "Unrecognized unit. Please select nsec, usec, msec, or sec.\n")

    def test_main_exception(self):

            

Reported by Pylint.

Unused variable 's'
Error

Line: 358 Column: 13

              
    def test_main_exception(self):
        with captured_stderr() as error_stringio:
            s = self.run_main(switches=['1/0'])
        self.assert_exc_string(error_stringio.getvalue(), 'ZeroDivisionError')

    def test_main_exception_fixed_reps(self):
        with captured_stderr() as error_stringio:
            s = self.run_main(switches=['-n1', '1/0'])

            

Reported by Pylint.

Unused variable 's'
Error

Line: 363 Column: 13

              
    def test_main_exception_fixed_reps(self):
        with captured_stderr() as error_stringio:
            s = self.run_main(switches=['-n1', '1/0'])
        self.assert_exc_string(error_stringio.getvalue(), 'ZeroDivisionError')

    def autorange(self, seconds_per_increment=1/1024, callback=None):
        timer = FakeTimer(seconds_per_increment=seconds_per_increment)
        t = timeit.Timer(stmt=self.fake_stmt, setup=self.fake_setup, timer=timer)

            

Reported by Pylint.

Lib/email/headerregistry.py
90 issues
Class 'BaseHeader' has no 'parse' member
Error

Line: 192 Column: 9

              
    def __new__(cls, name, value):
        kwds = {'defects': []}
        cls.parse(value, kwds)
        if utils._has_surrogates(kwds['decoded']):
            kwds['decoded'] = utils._sanitize(kwds['decoded'])
        self = str.__new__(cls, kwds['decoded'])
        del kwds['decoded']
        self.init(name, **kwds)

            

Reported by Pylint.

Super of 'DateHeader' has no 'init' member
Error

Line: 315 Column: 9

              
    def init(self, *args, **kw):
        self._datetime = kw.pop('datetime')
        super().init(*args, **kw)

    @property
    def datetime(self):
        return self._datetime


            

Reported by Pylint.

Super of 'AddressHeader' has no 'init' member
Error

Line: 368 Column: 9

                  def init(self, *args, **kw):
        self._groups = tuple(kw.pop('groups'))
        self._addresses = None
        super().init(*args, **kw)

    @property
    def groups(self):
        return self._groups


            

Reported by Pylint.

Instance of 'SingleAddressHeader' has no 'name' member
Error

Line: 393 Column: 44

                  def address(self):
        if len(self.addresses)!=1:
            raise ValueError(("value of single address header {} is not "
                "a single address").format(self.name))
        return self.addresses[0]


class UniqueSingleAddressHeader(SingleAddressHeader):


            

Reported by Pylint.

Super of 'MIMEVersionHeader' has no 'init' member
Error

Line: 424 Column: 9

                      self._version = kw.pop('version')
        self._major = kw.pop('major')
        self._minor = kw.pop('minor')
        super().init(*args, **kw)

    @property
    def major(self):
        return self._major


            

Reported by Pylint.

Class 'ParameterizedMIMEHeader' has no 'value_parser' member
Error

Line: 448 Column: 43

              
    @classmethod
    def parse(cls, value, kwds):
        kwds['parse_tree'] = parse_tree = cls.value_parser(value)
        kwds['decoded'] = str(parse_tree)
        kwds['defects'].extend(parse_tree.all_defects)
        if parse_tree.params is None:
            kwds['params'] = {}
        else:

            

Reported by Pylint.

Super of 'ParameterizedMIMEHeader' has no 'init' member
Error

Line: 461 Column: 9

              
    def init(self, *args, **kw):
        self._params = kw.pop('params')
        super().init(*args, **kw)

    @property
    def params(self):
        return MappingProxyType(self._params)


            

Reported by Pylint.

Instance of 'ContentTypeHeader' has no '_parse_tree' member
Error

Line: 474 Column: 42

              
    def init(self, *args, **kw):
        super().init(*args, **kw)
        self._maintype = utils._sanitize(self._parse_tree.maintype)
        self._subtype = utils._sanitize(self._parse_tree.subtype)

    @property
    def maintype(self):
        return self._maintype

            

Reported by Pylint.

Instance of 'ContentTypeHeader' has no '_parse_tree' member
Error

Line: 475 Column: 41

                  def init(self, *args, **kw):
        super().init(*args, **kw)
        self._maintype = utils._sanitize(self._parse_tree.maintype)
        self._subtype = utils._sanitize(self._parse_tree.subtype)

    @property
    def maintype(self):
        return self._maintype


            

Reported by Pylint.

Instance of 'ContentDispositionHeader' has no '_parse_tree' member
Error

Line: 496 Column: 14

              
    def init(self, *args, **kw):
        super().init(*args, **kw)
        cd = self._parse_tree.content_disposition
        self._content_disposition = cd if cd is None else utils._sanitize(cd)

    @property
    def content_disposition(self):
        return self._content_disposition

            

Reported by Pylint.

Lib/ctypes/test/test_array_in_pointer.py
90 issues
Unused import c_long from wildcard import
Error

Line: 2 Column: 1

              import unittest
from ctypes import *
from binascii import hexlify
import re

def dump(obj):
    # helper function to dump memory contents in hex, with a hyphen
    # between the bytes.
    h = hexlify(memoryview(obj)).decode()

            

Reported by Pylint.

Unused import PYFUNCTYPE from wildcard import
Error

Line: 2 Column: 1

              import unittest
from ctypes import *
from binascii import hexlify
import re

def dump(obj):
    # helper function to dump memory contents in hex, with a hyphen
    # between the bytes.
    h = hexlify(memoryview(obj)).decode()

            

Reported by Pylint.

Unused import string_at from wildcard import
Error

Line: 2 Column: 1

              import unittest
from ctypes import *
from binascii import hexlify
import re

def dump(obj):
    # helper function to dump memory contents in hex, with a hyphen
    # between the bytes.
    h = hexlify(memoryview(obj)).decode()

            

Reported by Pylint.

Unused import wstring_at from wildcard import
Error

Line: 2 Column: 1

              import unittest
from ctypes import *
from binascii import hexlify
import re

def dump(obj):
    # helper function to dump memory contents in hex, with a hyphen
    # between the bytes.
    h = hexlify(memoryview(obj)).decode()

            

Reported by Pylint.

Unused import DllGetClassObject from wildcard import
Error

Line: 2 Column: 1

              import unittest
from ctypes import *
from binascii import hexlify
import re

def dump(obj):
    # helper function to dump memory contents in hex, with a hyphen
    # between the bytes.
    h = hexlify(memoryview(obj)).decode()

            

Reported by Pylint.

Unused import DllCanUnloadNow from wildcard import
Error

Line: 2 Column: 1

              import unittest
from ctypes import *
from binascii import hexlify
import re

def dump(obj):
    # helper function to dump memory contents in hex, with a hyphen
    # between the bytes.
    h = hexlify(memoryview(obj)).decode()

            

Reported by Pylint.

Unused import c_int8 from wildcard import
Error

Line: 2 Column: 1

              import unittest
from ctypes import *
from binascii import hexlify
import re

def dump(obj):
    # helper function to dump memory contents in hex, with a hyphen
    # between the bytes.
    h = hexlify(memoryview(obj)).decode()

            

Reported by Pylint.

Unused import c_uint8 from wildcard import
Error

Line: 2 Column: 1

              import unittest
from ctypes import *
from binascii import hexlify
import re

def dump(obj):
    # helper function to dump memory contents in hex, with a hyphen
    # between the bytes.
    h = hexlify(memoryview(obj)).decode()

            

Reported by Pylint.

Unused import kind from wildcard import
Error

Line: 2 Column: 1

              import unittest
from ctypes import *
from binascii import hexlify
import re

def dump(obj):
    # helper function to dump memory contents in hex, with a hyphen
    # between the bytes.
    h = hexlify(memoryview(obj)).decode()

            

Reported by Pylint.

Unused import c_int16 from wildcard import
Error

Line: 2 Column: 1

              import unittest
from ctypes import *
from binascii import hexlify
import re

def dump(obj):
    # helper function to dump memory contents in hex, with a hyphen
    # between the bytes.
    h = hexlify(memoryview(obj)).decode()

            

Reported by Pylint.

Lib/ctypes/_endian.py
90 issues
class already defined line 2
Error

Line: 46 Column: 5

              
    LittleEndianStructure = Structure

    class BigEndianStructure(Structure, metaclass=_swapped_meta):
        """Structure with big endian byte order"""
        __slots__ = ()
        _swappedbytes_ = None

elif sys.byteorder == "big":

            

Reported by Pylint.

class already defined line 2
Error

Line: 55 Column: 5

                  _OTHER_ENDIAN = "__ctype_le__"

    BigEndianStructure = Structure
    class LittleEndianStructure(Structure, metaclass=_swapped_meta):
        """Structure with little endian byte order"""
        __slots__ = ()
        _swappedbytes_ = None

else:

            

Reported by Pylint.

Unused import kind from wildcard import
Error

Line: 2 Column: 1

              import sys
from ctypes import *

_array_type = type(Array)

def _other_endian(typ):
    """Return the type with the 'other' byte order.  Simple types like
    c_int and so on already have __ctype_be__ and __ctype_le__
    attributes which contain the types, for more complicated types

            

Reported by Pylint.

Unused import c_int16 from wildcard import
Error

Line: 2 Column: 1

              import sys
from ctypes import *

_array_type = type(Array)

def _other_endian(typ):
    """Return the type with the 'other' byte order.  Simple types like
    c_int and so on already have __ctype_be__ and __ctype_le__
    attributes which contain the types, for more complicated types

            

Reported by Pylint.

Unused import c_int32 from wildcard import
Error

Line: 2 Column: 1

              import sys
from ctypes import *

_array_type = type(Array)

def _other_endian(typ):
    """Return the type with the 'other' byte order.  Simple types like
    c_int and so on already have __ctype_be__ and __ctype_le__
    attributes which contain the types, for more complicated types

            

Reported by Pylint.

Unused import c_int64 from wildcard import
Error

Line: 2 Column: 1

              import sys
from ctypes import *

_array_type = type(Array)

def _other_endian(typ):
    """Return the type with the 'other' byte order.  Simple types like
    c_int and so on already have __ctype_be__ and __ctype_le__
    attributes which contain the types, for more complicated types

            

Reported by Pylint.

Unused import c_uint16 from wildcard import
Error

Line: 2 Column: 1

              import sys
from ctypes import *

_array_type = type(Array)

def _other_endian(typ):
    """Return the type with the 'other' byte order.  Simple types like
    c_int and so on already have __ctype_be__ and __ctype_le__
    attributes which contain the types, for more complicated types

            

Reported by Pylint.

Unused import c_uint32 from wildcard import
Error

Line: 2 Column: 1

              import sys
from ctypes import *

_array_type = type(Array)

def _other_endian(typ):
    """Return the type with the 'other' byte order.  Simple types like
    c_int and so on already have __ctype_be__ and __ctype_le__
    attributes which contain the types, for more complicated types

            

Reported by Pylint.

Unused import c_uint64 from wildcard import
Error

Line: 2 Column: 1

              import sys
from ctypes import *

_array_type = type(Array)

def _other_endian(typ):
    """Return the type with the 'other' byte order.  Simple types like
    c_int and so on already have __ctype_be__ and __ctype_le__
    attributes which contain the types, for more complicated types

            

Reported by Pylint.

Unused import Union from wildcard import
Error

Line: 2 Column: 1

              import sys
from ctypes import *

_array_type = type(Array)

def _other_endian(typ):
    """Return the type with the 'other' byte order.  Simple types like
    c_int and so on already have __ctype_be__ and __ctype_le__
    attributes which contain the types, for more complicated types

            

Reported by Pylint.

Lib/test/test_json/test_decode.py
89 issues
Instance of 'TestDecode' has no 'loads' member
Error

Line: 9 Column: 16

              
class TestDecode:
    def test_decimal(self):
        rval = self.loads('1.1', parse_float=decimal.Decimal)
        self.assertTrue(isinstance(rval, decimal.Decimal))
        self.assertEqual(rval, decimal.Decimal('1.1'))

    def test_float(self):
        rval = self.loads('1', parse_int=float)

            

Reported by Pylint.

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

Line: 10 Column: 9

              class TestDecode:
    def test_decimal(self):
        rval = self.loads('1.1', parse_float=decimal.Decimal)
        self.assertTrue(isinstance(rval, decimal.Decimal))
        self.assertEqual(rval, decimal.Decimal('1.1'))

    def test_float(self):
        rval = self.loads('1', parse_int=float)
        self.assertTrue(isinstance(rval, float))

            

Reported by Pylint.

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

Line: 11 Column: 9

                  def test_decimal(self):
        rval = self.loads('1.1', parse_float=decimal.Decimal)
        self.assertTrue(isinstance(rval, decimal.Decimal))
        self.assertEqual(rval, decimal.Decimal('1.1'))

    def test_float(self):
        rval = self.loads('1', parse_int=float)
        self.assertTrue(isinstance(rval, float))
        self.assertEqual(rval, 1.0)

            

Reported by Pylint.

Instance of 'TestDecode' has no 'loads' member
Error

Line: 14 Column: 16

                      self.assertEqual(rval, decimal.Decimal('1.1'))

    def test_float(self):
        rval = self.loads('1', parse_int=float)
        self.assertTrue(isinstance(rval, float))
        self.assertEqual(rval, 1.0)

    def test_empty_objects(self):
        self.assertEqual(self.loads('{}'), {})

            

Reported by Pylint.

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

Line: 15 Column: 9

              
    def test_float(self):
        rval = self.loads('1', parse_int=float)
        self.assertTrue(isinstance(rval, float))
        self.assertEqual(rval, 1.0)

    def test_empty_objects(self):
        self.assertEqual(self.loads('{}'), {})
        self.assertEqual(self.loads('[]'), [])

            

Reported by Pylint.

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

Line: 16 Column: 9

                  def test_float(self):
        rval = self.loads('1', parse_int=float)
        self.assertTrue(isinstance(rval, float))
        self.assertEqual(rval, 1.0)

    def test_empty_objects(self):
        self.assertEqual(self.loads('{}'), {})
        self.assertEqual(self.loads('[]'), [])
        self.assertEqual(self.loads('""'), "")

            

Reported by Pylint.

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

Line: 19 Column: 9

                      self.assertEqual(rval, 1.0)

    def test_empty_objects(self):
        self.assertEqual(self.loads('{}'), {})
        self.assertEqual(self.loads('[]'), [])
        self.assertEqual(self.loads('""'), "")

    def test_object_pairs_hook(self):
        s = '{"xkd":1, "kcw":2, "art":3, "hxm":4, "qrt":5, "pad":6, "hoy":7}'

            

Reported by Pylint.

Instance of 'TestDecode' has no 'loads' member
Error

Line: 19 Column: 26

                      self.assertEqual(rval, 1.0)

    def test_empty_objects(self):
        self.assertEqual(self.loads('{}'), {})
        self.assertEqual(self.loads('[]'), [])
        self.assertEqual(self.loads('""'), "")

    def test_object_pairs_hook(self):
        s = '{"xkd":1, "kcw":2, "art":3, "hxm":4, "qrt":5, "pad":6, "hoy":7}'

            

Reported by Pylint.

Instance of 'TestDecode' has no 'loads' member
Error

Line: 20 Column: 26

              
    def test_empty_objects(self):
        self.assertEqual(self.loads('{}'), {})
        self.assertEqual(self.loads('[]'), [])
        self.assertEqual(self.loads('""'), "")

    def test_object_pairs_hook(self):
        s = '{"xkd":1, "kcw":2, "art":3, "hxm":4, "qrt":5, "pad":6, "hoy":7}'
        p = [("xkd", 1), ("kcw", 2), ("art", 3), ("hxm", 4),

            

Reported by Pylint.

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

Line: 20 Column: 9

              
    def test_empty_objects(self):
        self.assertEqual(self.loads('{}'), {})
        self.assertEqual(self.loads('[]'), [])
        self.assertEqual(self.loads('""'), "")

    def test_object_pairs_hook(self):
        s = '{"xkd":1, "kcw":2, "art":3, "hxm":4, "qrt":5, "pad":6, "hoy":7}'
        p = [("xkd", 1), ("kcw", 2), ("art", 3), ("hxm", 4),

            

Reported by Pylint.

Lib/tkinter/test/test_tkinter/test_misc.py
89 issues
Unused variable 'f'
Error

Line: 33 Column: 9

              
    def test_generated_names(self):
        t = tkinter.Toplevel(self.root)
        f = tkinter.Frame(t)
        f2 = tkinter.Frame(t)
        b = tkinter.Button(f2)
        for name in str(b).split('.'):
            self.assertFalse(name.isidentifier(), msg=repr(name))


            

Reported by Pylint.

Access to a protected member _test_simple_enum of a client class
Error

Line: 313 Column: 9

                          Activate = '36'
            Deactivate = '37'
            MouseWheel = '38'
        enum._test_simple_enum(CheckedEventType, tkinter.EventType)

    def test_getboolean(self):
        for v in 'true', 'yes', 'on', '1', 't', 'y', 1, True:
            self.assertIs(self.root.getboolean(v), True)
        for v in 'false', 'no', 'off', '0', 'f', 'n', 0, False:

            

Reported by Pylint.

Access to a protected member _support_default_root of a client class
Error

Line: 341 Column: 23

              class DefaultRootTest(AbstractDefaultRootTest, unittest.TestCase):

    def test_default_root(self):
        self.assertIs(tkinter._support_default_root, True)
        self.assertIsNone(tkinter._default_root)
        root = tkinter.Tk()
        root2 = tkinter.Tk()
        root3 = tkinter.Tk()
        self.assertIs(tkinter._default_root, root)

            

Reported by Pylint.

Access to a protected member _default_root of a client class
Error

Line: 342 Column: 27

              
    def test_default_root(self):
        self.assertIs(tkinter._support_default_root, True)
        self.assertIsNone(tkinter._default_root)
        root = tkinter.Tk()
        root2 = tkinter.Tk()
        root3 = tkinter.Tk()
        self.assertIs(tkinter._default_root, root)
        root2.destroy()

            

Reported by Pylint.

Access to a protected member _default_root of a client class
Error

Line: 346 Column: 23

                      root = tkinter.Tk()
        root2 = tkinter.Tk()
        root3 = tkinter.Tk()
        self.assertIs(tkinter._default_root, root)
        root2.destroy()
        self.assertIs(tkinter._default_root, root)
        root.destroy()
        self.assertIsNone(tkinter._default_root)
        root3.destroy()

            

Reported by Pylint.

Access to a protected member _default_root of a client class
Error

Line: 348 Column: 23

                      root3 = tkinter.Tk()
        self.assertIs(tkinter._default_root, root)
        root2.destroy()
        self.assertIs(tkinter._default_root, root)
        root.destroy()
        self.assertIsNone(tkinter._default_root)
        root3.destroy()
        self.assertIsNone(tkinter._default_root)


            

Reported by Pylint.

Access to a protected member _default_root of a client class
Error

Line: 350 Column: 27

                      root2.destroy()
        self.assertIs(tkinter._default_root, root)
        root.destroy()
        self.assertIsNone(tkinter._default_root)
        root3.destroy()
        self.assertIsNone(tkinter._default_root)

    def test_no_default_root(self):
        self.assertIs(tkinter._support_default_root, True)

            

Reported by Pylint.

Access to a protected member _default_root of a client class
Error

Line: 352 Column: 27

                      root.destroy()
        self.assertIsNone(tkinter._default_root)
        root3.destroy()
        self.assertIsNone(tkinter._default_root)

    def test_no_default_root(self):
        self.assertIs(tkinter._support_default_root, True)
        self.assertIsNone(tkinter._default_root)
        root = tkinter.Tk()

            

Reported by Pylint.

Access to a protected member _support_default_root of a client class
Error

Line: 355 Column: 23

                      self.assertIsNone(tkinter._default_root)

    def test_no_default_root(self):
        self.assertIs(tkinter._support_default_root, True)
        self.assertIsNone(tkinter._default_root)
        root = tkinter.Tk()
        self.assertIs(tkinter._default_root, root)
        tkinter.NoDefaultRoot()
        self.assertIs(tkinter._support_default_root, False)

            

Reported by Pylint.

Access to a protected member _default_root of a client class
Error

Line: 356 Column: 27

              
    def test_no_default_root(self):
        self.assertIs(tkinter._support_default_root, True)
        self.assertIsNone(tkinter._default_root)
        root = tkinter.Tk()
        self.assertIs(tkinter._default_root, root)
        tkinter.NoDefaultRoot()
        self.assertIs(tkinter._support_default_root, False)
        self.assertFalse(hasattr(tkinter, '_default_root'))

            

Reported by Pylint.

Lib/gettext.py
89 issues
TODO:
Error

Line: 37 Column: 3

              #
# J. David Ibanez implemented plural forms. Bruno Haible fixed some bugs.
#
# TODO:
# - Lazy loading of .mo files.  Currently the entire catalog is loaded into
#   memory, but that's probably bad for large translated programs.  Instead,
#   the lexical sort of original strings in GNU .mo files should be exploited
#   to do binary searches and lazy initializations.  Or you might want to use
#   the undocumented double-hash algorithm for .mo files with hash tables, but

            

Reported by Pylint.

Unused variable 'i'
Error

Line: 169 Column: 9

              
def _as_int(n):
    try:
        i = round(n)
    except TypeError:
        raise TypeError('Plural value must be an integer, got %s' %
                        (n.__class__.__name__,)) from None
    import warnings
    warnings.warn('Plural value must be an integer, got %s' %

            

Reported by Pylint.

Use of exec
Error

Line: 204 Column: 9

                              depth -= 1

        ns = {'_as_int': _as_int}
        exec('''if True:
            def func(n):
                if not isinstance(n, int):
                    n = _as_int(n)
                return int(%s)
            ''' % result, ns)

            

Reported by Pylint.

Use of exec detected.
Security

Line: 204
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b102_exec_used.html

                              depth -= 1

        ns = {'_as_int': _as_int}
        exec('''if True:
            def func(n):
                if not isinstance(n, int):
                    n = _as_int(n)
                return int(%s)
            ''' % result, ns)

            

Reported by Bandit.

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

Line: 213 Column: 9

                      return ns['func']
    except RecursionError:
        # Recursion error can be raised in _parse() or exec().
        raise ValueError('plural form expression is too complex')


def _expand_lang(loc):
    import locale
    loc = locale.normalize(loc)

            

Reported by Pylint.

Unused variable 'minor_version'
Error

Line: 355 Column: 24

                      else:
            raise OSError(0, 'Bad magic number', filename)

        major_version, minor_version = self._get_versions(version)

        if major_version not in self.VERSIONS:
            raise OSError(0, 'Bad version number ' + str(major_version), filename)

        # Now put all messages from the .mo file buffer into the catalog

            

Reported by Pylint.

Unused variable 'msgid2'
Error

Line: 410 Column: 25

                          charset = self._charset or 'ascii'
            if b'\x00' in msg:
                # Plural forms
                msgid1, msgid2 = msg.split(b'\x00')
                tmsg = tmsg.split(b'\x00')
                msgid1 = str(msgid1, charset)
                for i, x in enumerate(tmsg):
                    catalog[(msgid1, i)] = str(x, charset)
            else:

            

Reported by Pylint.

Redefining name 'i' from outer scope (line 362)
Error

Line: 413 Column: 17

                              msgid1, msgid2 = msg.split(b'\x00')
                tmsg = tmsg.split(b'\x00')
                msgid1 = str(msgid1, charset)
                for i, x in enumerate(tmsg):
                    catalog[(msgid1, i)] = str(x, charset)
            else:
                catalog[str(msg, charset)] = str(tmsg, charset)
            # advance to next entry in the seek tables
            masteridx += 8

            

Reported by Pylint.

Redefining built-in 'all'
Error

Line: 467 Column: 50

              

# Locate a .mo file using the gettext strategy
def find(domain, localedir=None, languages=None, all=False):
    # Get some reasonable defaults for arguments that were not supplied
    if localedir is None:
        localedir = _default_localedir
    if languages is None:
        languages = []

            

Reported by Pylint.

Using the global statement
Error

Line: 553 Column: 5

              

def textdomain(domain=None):
    global _current_domain
    if domain is not None:
        _current_domain = domain
    return _current_domain



            

Reported by Pylint.

Lib/sqlite3/test/types.py
89 issues
Unused argument 'maxsize'
Error

Line: 108 Column: 37

              
    @unittest.skipUnless(sys.maxsize > 2**32, 'requires 64bit platform')
    @support.bigmemtest(size=2**31, memuse=4, dry_run=False)
    def test_too_large_string(self, maxsize):
        with self.assertRaises(sqlite.InterfaceError):
            self.cur.execute("insert into test(s) values (?)", ('x'*(2**31-1),))
        with self.assertRaises(OverflowError):
            self.cur.execute("insert into test(s) values (?)", ('x'*(2**31),))
        self.cur.execute("select 1 from test")

            

Reported by Pylint.

Unused argument 'maxsize'
Error

Line: 119 Column: 35

              
    @unittest.skipUnless(sys.maxsize > 2**32, 'requires 64bit platform')
    @support.bigmemtest(size=2**31, memuse=3, dry_run=False)
    def test_too_large_blob(self, maxsize):
        with self.assertRaises(sqlite.InterfaceError):
            self.cur.execute("insert into test(s) values (?)", (b'x'*(2**31-1),))
        with self.assertRaises(OverflowError):
            self.cur.execute("insert into test(s) values (?)", (b'x'*(2**31),))
        self.cur.execute("select 1 from test")

            

Reported by Pylint.

No exception type(s) specified
Error

Line: 417 Column: 9

                      self.con = sqlite.connect(":memory:")
        try:
            del sqlite.adapters[int]
        except:
            pass
        sqlite.register_adapter(int, ObjectAdaptationTests.cast)
        self.cur = self.con.cursor()

    def tearDown(self):

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # pysqlite2/test/types.py: tests for type conversion and detection
#
# Copyright (C) 2005 Gerhard Häring <gh@ghaering.de>
#
# This file is part of pysqlite.
#
# This software is provided 'as-is', without any express or implied
# warranty.  In no event will the authors be held liable for any damages
# arising from the use of this software.

            

Reported by Pylint.

Missing class docstring
Error

Line: 35 Column: 1

              from test import support


class SqliteTypeTests(unittest.TestCase):
    def setUp(self):
        self.con = sqlite.connect(":memory:")
        self.cur = self.con.cursor()
        self.cur.execute("create table test(i integer, s varchar, f number, b blob)")


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 45 Column: 5

                      self.cur.close()
        self.con.close()

    def test_string(self):
        self.cur.execute("insert into test(s) values (?)", ("Österreich",))
        self.cur.execute("select s from test")
        row = self.cur.fetchone()
        self.assertEqual(row[0], "Österreich")


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 51 Column: 5

                      row = self.cur.fetchone()
        self.assertEqual(row[0], "Österreich")

    def test_string_with_null_character(self):
        self.cur.execute("insert into test(s) values (?)", ("a\0b",))
        self.cur.execute("select s from test")
        row = self.cur.fetchone()
        self.assertEqual(row[0], "a\0b")


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 57 Column: 5

                      row = self.cur.fetchone()
        self.assertEqual(row[0], "a\0b")

    def test_small_int(self):
        self.cur.execute("insert into test(i) values (?)", (42,))
        self.cur.execute("select i from test")
        row = self.cur.fetchone()
        self.assertEqual(row[0], 42)


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 63 Column: 5

                      row = self.cur.fetchone()
        self.assertEqual(row[0], 42)

    def test_large_int(self):
        num = 123456789123456789
        self.cur.execute("insert into test(i) values (?)", (num,))
        self.cur.execute("select i from test")
        row = self.cur.fetchone()
        self.assertEqual(row[0], num)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 70 Column: 5

                      row = self.cur.fetchone()
        self.assertEqual(row[0], num)

    def test_float(self):
        val = 3.14
        self.cur.execute("insert into test(f) values (?)", (val,))
        self.cur.execute("select f from test")
        row = self.cur.fetchone()
        self.assertEqual(row[0], val)

            

Reported by Pylint.

Lib/test/test_textwrap.py
88 issues
Instance of 'BaseTestCase' has no 'wrapper' member
Error

Line: 40 Column: 18

                      self.check(result, expect)

    def check_split(self, text, expect):
        result = self.wrapper._split(text)
        self.assertEqual(result, expect,
                         "\nexpected %r\n"
                         "but got  %r" % (expect, result))



            

Reported by Pylint.

Access to a protected member _split of a client class
Error

Line: 40 Column: 18

                      self.check(result, expect)

    def check_split(self, text, expect):
        result = self.wrapper._split(text)
        self.assertEqual(result, expect,
                         "\nexpected %r\n"
                         "but got  %r" % (expect, result))



            

Reported by Pylint.

Access to a protected member _split of a client class
Error

Line: 420 Column: 18

              
        text = "Hello there -- you goof-ball, use the -b option!"

        result = self.wrapper._split(text)
        self.check(result,
             ["Hello", " ", "there", " ", "--", " ", "you", " ", "goof-",
              "ball,", " ", "use", " ", "the", " ", "-b", " ",  "option!"])

    def test_break_on_hyphens(self):

            

Reported by Pylint.

Too many lines in module (1080/1000)
Error

Line: 1 Column: 1

              #
# Test suite for the textwrap module.
#
# Original tests written by Greg Ward <gward@python.net>.
# Converted to PyUnit by Peter Hansen <peter@engcorp.com>.
# Currently maintained by Greg Ward.
#
# $Id$
#

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              #
# Test suite for the textwrap module.
#
# Original tests written by Greg Ward <gward@python.net>.
# Converted to PyUnit by Peter Hansen <peter@engcorp.com>.
# Currently maintained by Greg Ward.
#
# $Id$
#

            

Reported by Pylint.

Method could be a function
Error

Line: 19 Column: 5

              class BaseTestCase(unittest.TestCase):
    '''Parent class with utility methods for textwrap tests.'''

    def show(self, textin):
        if isinstance(textin, list):
            result = []
            for i in range(len(textin)):
                result.append("  %d: %r" % (i, textin[i]))
            result = "\n".join(result) if result else "  no lines"

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 19 Column: 5

              class BaseTestCase(unittest.TestCase):
    '''Parent class with utility methods for textwrap tests.'''

    def show(self, textin):
        if isinstance(textin, list):
            result = []
            for i in range(len(textin)):
                result.append("  %d: %r" % (i, textin[i]))
            result = "\n".join(result) if result else "  no lines"

            

Reported by Pylint.

Consider using enumerate instead of iterating with range and len
Error

Line: 22 Column: 13

                  def show(self, textin):
        if isinstance(textin, list):
            result = []
            for i in range(len(textin)):
                result.append("  %d: %r" % (i, textin[i]))
            result = "\n".join(result) if result else "  no lines"
        elif isinstance(textin, str):
            result = "  %s\n" % repr(textin)
        return result

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 30 Column: 5

                      return result


    def check(self, result, expect):
        self.assertEqual(result, expect,
            'expected:\n%s\nbut got:\n%s' % (
                self.show(expect), self.show(result)))

    def check_wrap(self, text, width, expect, **kwargs):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 35 Column: 5

                          'expected:\n%s\nbut got:\n%s' % (
                self.show(expect), self.show(result)))

    def check_wrap(self, text, width, expect, **kwargs):
        result = wrap(text, width, **kwargs)
        self.check(result, expect)

    def check_split(self, text, expect):
        result = self.wrapper._split(text)

            

Reported by Pylint.

Lib/ctypes/test/test_varsize_struct.py
88 issues
Unused import c_float from wildcard import
Error

Line: 1 Column: 1

              from ctypes import *
import unittest

class VarSizeTest(unittest.TestCase):
    def test_resize(self):
        class X(Structure):
            _fields_ = [("item", c_int),
                        ("array", c_int * 1)]


            

Reported by Pylint.

Unused import LittleEndianStructure from wildcard import
Error

Line: 1 Column: 1

              from ctypes import *
import unittest

class VarSizeTest(unittest.TestCase):
    def test_resize(self):
        class X(Structure):
            _fields_ = [("item", c_int),
                        ("array", c_int * 1)]


            

Reported by Pylint.

Unused import BigEndianStructure from wildcard import
Error

Line: 1 Column: 1

              from ctypes import *
import unittest

class VarSizeTest(unittest.TestCase):
    def test_resize(self):
        class X(Structure):
            _fields_ = [("item", c_int),
                        ("array", c_int * 1)]


            

Reported by Pylint.

Unused import set_last_error from wildcard import
Error

Line: 1 Column: 1

              from ctypes import *
import unittest

class VarSizeTest(unittest.TestCase):
    def test_resize(self):
        class X(Structure):
            _fields_ = [("item", c_int),
                        ("array", c_int * 1)]


            

Reported by Pylint.

Unused import get_last_error from wildcard import
Error

Line: 1 Column: 1

              from ctypes import *
import unittest

class VarSizeTest(unittest.TestCase):
    def test_resize(self):
        class X(Structure):
            _fields_ = [("item", c_int),
                        ("array", c_int * 1)]


            

Reported by Pylint.

Unused import pointer from wildcard import
Error

Line: 1 Column: 1

              from ctypes import *
import unittest

class VarSizeTest(unittest.TestCase):
    def test_resize(self):
        class X(Structure):
            _fields_ = [("item", c_int),
                        ("array", c_int * 1)]


            

Reported by Pylint.

Unused import POINTER from wildcard import
Error

Line: 1 Column: 1

              from ctypes import *
import unittest

class VarSizeTest(unittest.TestCase):
    def test_resize(self):
        class X(Structure):
            _fields_ = [("item", c_int),
                        ("array", c_int * 1)]


            

Reported by Pylint.

Unused import set_errno from wildcard import
Error

Line: 1 Column: 1

              from ctypes import *
import unittest

class VarSizeTest(unittest.TestCase):
    def test_resize(self):
        class X(Structure):
            _fields_ = [("item", c_int),
                        ("array", c_int * 1)]


            

Reported by Pylint.

Unused import get_errno from wildcard import
Error

Line: 1 Column: 1

              from ctypes import *
import unittest

class VarSizeTest(unittest.TestCase):
    def test_resize(self):
        class X(Structure):
            _fields_ = [("item", c_int),
                        ("array", c_int * 1)]


            

Reported by Pylint.

Unused import alignment from wildcard import
Error

Line: 1 Column: 1

              from ctypes import *
import unittest

class VarSizeTest(unittest.TestCase):
    def test_resize(self):
        class X(Structure):
            _fields_ = [("item", c_int),
                        ("array", c_int * 1)]


            

Reported by Pylint.