The following issues were found

Lib/test/test_long.py
242 issues
Method should have "self" as first argument
Error

Line: 147 Column: 5

                  # Get random long consisting of ndigits random digits (relative to base
    # BASE).  The sign bit is also random.

    def getran2(ndigits):
        answer = 0
        for i in range(ndigits):
            answer = (answer << SHIFT) | random.randint(0, MASK)
        if random.random() < 0.5:
            answer = -answer

            

Reported by Pylint.

Instance of 'int' has no 'bit_count' member
Error

Line: 1025 Column: 30

              
        for exp in [10, 17, 63, 64, 65, 1009, 70234, 1234567]:
            a = 2**exp
            self.assertEqual(a.bit_count(), 1)
            self.assertEqual((a - 1).bit_count(), exp)
            self.assertEqual((a ^ 63).bit_count(), 7)
            self.assertEqual(((a - 1) ^ 510).bit_count(), exp - 8)

    def test_round(self):

            

Reported by Pylint.

Instance of 'int' has no 'bit_count' member
Error

Line: 1026 Column: 30

                      for exp in [10, 17, 63, 64, 65, 1009, 70234, 1234567]:
            a = 2**exp
            self.assertEqual(a.bit_count(), 1)
            self.assertEqual((a - 1).bit_count(), exp)
            self.assertEqual((a ^ 63).bit_count(), 7)
            self.assertEqual(((a - 1) ^ 510).bit_count(), exp - 8)

    def test_round(self):
        # check round-half-even algorithm. For round to nearest ten;

            

Reported by Pylint.

Instance of 'int' has no 'bit_count' member
Error

Line: 1027 Column: 30

                          a = 2**exp
            self.assertEqual(a.bit_count(), 1)
            self.assertEqual((a - 1).bit_count(), exp)
            self.assertEqual((a ^ 63).bit_count(), 7)
            self.assertEqual(((a - 1) ^ 510).bit_count(), exp - 8)

    def test_round(self):
        # check round-half-even algorithm. For round to nearest ten;
        # rounding map is invariant under adding multiples of 20

            

Reported by Pylint.

Instance of 'int' has no 'bit_count' member
Error

Line: 1028 Column: 30

                          self.assertEqual(a.bit_count(), 1)
            self.assertEqual((a - 1).bit_count(), exp)
            self.assertEqual((a ^ 63).bit_count(), 7)
            self.assertEqual(((a - 1) ^ 510).bit_count(), exp - 8)

    def test_round(self):
        # check round-half-even algorithm. For round to nearest ten;
        # rounding map is invariant under adding multiples of 20
        test_dict = {0:0, 1:0, 2:0, 3:0, 4:0, 5:0,

            

Reported by Pylint.

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

Line: 149 Column: 13

              
    def getran2(ndigits):
        answer = 0
        for i in range(ndigits):
            answer = (answer << SHIFT) | random.randint(0, MASK)
        if random.random() < 0.5:
            answer = -answer
        return answer


            

Reported by Pylint.

Unused variable 'i'
Error

Line: 149 Column: 13

              
    def getran2(ndigits):
        answer = 0
        for i in range(ndigits):
            answer = (answer << SHIFT) | random.randint(0, MASK)
        if random.random() < 0.5:
            answer = -answer
        return answer


            

Reported by Pylint.

Redefining name 'p2' from outer scope (line 23)
Error

Line: 251 Column: 13

                          eq(-x, 1 + ~x)
            eq(-x, ~(x-1))
        for n in range(2*SHIFT):
            p2 = 2 ** n
            with self.subTest(x=x, n=n, p2=p2):
                eq(x << n >> n, x)
                eq(x // p2, x >> n)
                eq(x * p2, x << n)
                eq(x & -p2, x >> n << n)

            

Reported by Pylint.

Unused variable 'i'
Error

Line: 319 Column: 13

                  def test_format(self):
        for x in special:
            self.check_format_1(x)
        for i in range(10):
            for lenx in range(1, MAXDIGITS+1):
                x = self.getran(lenx)
                self.check_format_1(x)

    def test_long(self):

            

Reported by Pylint.

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

Line: 319 Column: 13

                  def test_format(self):
        for x in special:
            self.check_format_1(x)
        for i in range(10):
            for lenx in range(1, MAXDIGITS+1):
                x = self.getran(lenx)
                self.check_format_1(x)

    def test_long(self):

            

Reported by Pylint.

Lib/idlelib/idle_test/test_configdialog.py
242 issues
Using the global statement
Error

Line: 35 Column: 5

              

def setUpModule():
    global root, dialog
    idleConf.userCfg = testcfg
    root = Tk()
    # root.withdraw()    # Comment out, see issue 30870
    dialog = configdialog.ConfigDialog(root, 'Test', _utest=True)


            

Reported by Pylint.

Using the global statement
Error

Line: 43 Column: 5

              

def tearDownModule():
    global root, dialog
    idleConf.userCfg = usercfg
    tracers.detach()
    tracers.clear()
    changes.clear()
    root.update_idletasks()

            

Reported by Pylint.

TODO Improve checks when add IdleConf.get_font_values.
Error

Line: 128 Column: 3

              
    def test_load_font_cfg(self):
        # Leave widget load test to human visual check.
        # TODO Improve checks when add IdleConf.get_font_values.
        tracers.detach()
        d = self.page
        d.font_name.set('Fake')
        d.font_size.set('1')
        d.font_bold.set(True)

            

Reported by Pylint.

Unused variable 'offset'
Error

Line: 486 Column: 23

                      hs.see(1.0)
        hs.update_idletasks()

        x, y, dx, dy, offset = hs.dlineinfo('1.0')

        # Test binding from configdialog.
        hs.event_generate('<Leave>')
        hs.event_generate('<Enter>')
        hs.event_generate('<Motion>', x=x, y=y)

            

Reported by Pylint.

Unused variable 'gh'
Error

Line: 687 Column: 9

                      page = self.page
        del page.paint_theme_sample  # Delete masking mock.
        hs_tag = page.highlight_sample.tag_cget
        gh = idleConf.GetHighlight

        # Create custom theme based on IDLE Dark.
        page.theme_source.set(True)
        page.builtin_name.set('IDLE Dark')
        theme = 'IDLE Test'

            

Reported by Pylint.

Unused argument 'params'
Error

Line: 1494 Column: 1

                      self.tracers.clear()
        self.called = 0

    def var_changed_increment(self, *params):
        self.called += 13

    def var_changed_boolean(self, *params):
        pass


            

Reported by Pylint.

Too many lines in module (1583/1000)
Error

Line: 1 Column: 1

              """Test configdialog, coverage 94%.

Half the class creates dialog, half works with user customizations.
"""
from idlelib import configdialog
from test.support import requires
requires('gui')
import unittest
from unittest import mock

            

Reported by Pylint.

standard import "from test.support import requires" should be placed before "from idlelib import configdialog"
Error

Line: 6 Column: 1

              Half the class creates dialog, half works with user customizations.
"""
from idlelib import configdialog
from test.support import requires
requires('gui')
import unittest
from unittest import mock
from idlelib.idle_test.mock_idle import Func
from tkinter import (Tk, StringVar, IntVar, BooleanVar, DISABLED, NORMAL)

            

Reported by Pylint.

standard import "import unittest" should be placed before "from idlelib import configdialog"
Error

Line: 8 Column: 1

              from idlelib import configdialog
from test.support import requires
requires('gui')
import unittest
from unittest import mock
from idlelib.idle_test.mock_idle import Func
from tkinter import (Tk, StringVar, IntVar, BooleanVar, DISABLED, NORMAL)
from idlelib import config
from idlelib.configdialog import idleConf, changes, tracers

            

Reported by Pylint.

Import "import unittest" should be placed at the top of the module
Error

Line: 8 Column: 1

              from idlelib import configdialog
from test.support import requires
requires('gui')
import unittest
from unittest import mock
from idlelib.idle_test.mock_idle import Func
from tkinter import (Tk, StringVar, IntVar, BooleanVar, DISABLED, NORMAL)
from idlelib import config
from idlelib.configdialog import idleConf, changes, tracers

            

Reported by Pylint.

Lib/logging/__init__.py
241 issues
Cannot import 'traceback' due to syntax error 'invalid syntax (<unknown>, line 576)'
Error

Line: 26 Column: 1

              To use, simply 'import logging' and log away!
"""

import sys, os, time, io, re, traceback, warnings, weakref, collections.abc

from string import Template
from string import Formatter as StrFormatter



            

Reported by Pylint.

Instance of 'Logger' has no '_clear_cache' member
Error

Line: 1457 Column: 9

                      Set the logging level of this logger.  level must be an int or a str.
        """
        self.level = _checkLevel(level)
        self.manager._clear_cache()

    def debug(self, msg, *args, **kwargs):
        """
        Log 'msg % args' with severity 'DEBUG'.


            

Reported by Pylint.

Instance of 'Logger' has no 'disable' member; maybe 'disabled'?
Error

Line: 1740 Column: 20

                      except KeyError:
            _acquireLock()
            try:
                if self.manager.disable >= level:
                    is_enabled = self._cache[level] = False
                else:
                    is_enabled = self._cache[level] = (
                        level >= self.getEffectiveLevel()
                    )

            

Reported by Pylint.

Instance of 'Logger' has no 'getLogger' member
Error

Line: 1767 Column: 16

                      """
        if self.root is not self:
            suffix = '.'.join((self.name, suffix))
        return self.manager.getLogger(suffix)

    def __repr__(self):
        level = getLevelName(self.getEffectiveLevel())
        return '<%s %s (%s)>' % (self.__class__.__name__, self.name, level)


            

Reported by Pylint.

Access to a protected member _getframe of a client class
Error

Line: 163 Column: 28

                      _releaseLock()

if hasattr(sys, '_getframe'):
    currentframe = lambda: sys._getframe(3)
else: #pragma: no cover
    def currentframe():
        """Return the frame object for the caller's stack frame."""
        try:
            raise Exception

            

Reported by Pylint.

Catching too general exception Exception
Error

Line: 169 Column: 16

                      """Return the frame object for the caller's stack frame."""
        try:
            raise Exception
        except Exception:
            return sys.exc_info()[2].tb_frame.f_back

#
# _srcfile is used when walking the stack to check when we've got the first
# caller stack frame, by skipping frames whose filename is that of this

            

Reported by Pylint.

Unused argument 'instance'
Error

Line: 242 Column: 39

              # Prevent a held logging lock from blocking a child from logging.

if not hasattr(os, 'register_at_fork'):  # Windows and friends.
    def _register_at_fork_reinit_lock(instance):
        pass  # no-op when os.register_at_fork does not exist.
else:
    # A collection of instances with a _at_fork_reinit method (logging.Handler)
    # to be called in the child after forking.  The weakref avoids us keeping
    # discarded Handler instances alive.

            

Reported by Pylint.

Access to a protected member _at_fork_reinit of a client class
Error

Line: 259 Column: 13

              
    def _after_at_fork_child_reinit_locks():
        for handler in _at_fork_reinit_lock_weakset:
            handler._at_fork_reinit()

        # _acquireLock() was called in the parent before forking.
        # The lock is reinitialized to unlocked state.
        _lock._at_fork_reinit()


            

Reported by Pylint.

Access to a protected member _at_fork_reinit of a client class
Error

Line: 263 Column: 9

              
        # _acquireLock() was called in the parent before forking.
        # The lock is reinitialized to unlocked state.
        _lock._at_fork_reinit()

    os.register_at_fork(before=_acquireLock,
                        after_in_child=_after_at_fork_child_reinit_locks,
                        after_in_parent=_releaseLock)


            

Reported by Pylint.

Unused argument 'kwargs'
Error

Line: 286 Column: 1

                  the source line where the logging call was made, and any exception
    information to be logged.
    """
    def __init__(self, name, level, pathname, lineno,
                 msg, args, exc_info, func=None, sinfo=None, **kwargs):
        """
        Initialize a logging record with interesting information.
        """
        ct = time.time()

            

Reported by Pylint.

Lib/idlelib/tree.py
241 issues
Assigning result of a function call, where the function has no return
Error

Line: 367 Column: 9

                      """Do not override!  Called by TreeNode."""
        if not self.IsExpandable():
            return []
        sublist = self.GetSubList()
        if not sublist:
            self.expandable = 0
        return sublist

    def IsEditable(self):

            

Reported by Pylint.

Module 'idlelib.zoomheight' has no 'zoom_height' member
Error

Line: 481 Column: 9

                      self.canvas.yview_scroll(1, "unit")
        return "break"
    def zoom_height(self, event):
        zoomheight.zoom_height(self.master)
        return "break"


def _tree_widget(parent):  # htest #
    top = Toplevel(parent)

            

Reported by Pylint.

XXX TO DO:
Error

Line: 1 Column: 3

              # XXX TO DO:
# - popup menu
# - support partial or total redisplay
# - key bindings (instead of quick-n-dirty bindings on Canvas):
#   - up/down arrow keys to move focus around
#   - ditto for page up/down, home/end
#   - left/right arrows to expand/collapse & move out/in
# - more doc strings
# - add icons for "file", "module", "class", "method"; better "python" icon

            

Reported by Pylint.

Unused import Variable from wildcard import
Error

Line: 19 Column: 1

              
import os

from tkinter import *
from tkinter.ttk import Frame, Scrollbar

from idlelib.config import idleConf
from idlelib import zoomheight


            

Reported by Pylint.

Unused import StringVar from wildcard import
Error

Line: 19 Column: 1

              
import os

from tkinter import *
from tkinter.ttk import Frame, Scrollbar

from idlelib.config import idleConf
from idlelib import zoomheight


            

Reported by Pylint.

Unused import PAGES from wildcard import
Error

Line: 19 Column: 1

              
import os

from tkinter import *
from tkinter.ttk import Frame, Scrollbar

from idlelib.config import idleConf
from idlelib import zoomheight


            

Reported by Pylint.

Unused import BOTH from wildcard import
Error

Line: 19 Column: 1

              
import os

from tkinter import *
from tkinter.ttk import Frame, Scrollbar

from idlelib.config import idleConf
from idlelib import zoomheight


            

Reported by Pylint.

Unused import DoubleVar from wildcard import
Error

Line: 19 Column: 1

              
import os

from tkinter import *
from tkinter.ttk import Frame, Scrollbar

from idlelib.config import idleConf
from idlelib import zoomheight


            

Reported by Pylint.

Unused import types from wildcard import
Error

Line: 19 Column: 1

              
import os

from tkinter import *
from tkinter.ttk import Frame, Scrollbar

from idlelib.config import idleConf
from idlelib import zoomheight


            

Reported by Pylint.

Unused import TclError from wildcard import
Error

Line: 19 Column: 1

              
import os

from tkinter import *
from tkinter.ttk import Frame, Scrollbar

from idlelib.config import idleConf
from idlelib import zoomheight


            

Reported by Pylint.

Lib/test/test_time.py
238 issues
Instance of '_TestAsctimeYear' has no 'assertEqual' member
Error

Line: 589 Column: 9

              
    def test_large_year(self):
        # Check that it doesn't crash for year > 9999
        self.assertEqual(self.yearstr(12345), '12345')
        self.assertEqual(self.yearstr(123456789), '123456789')

class _TestStrftimeYear:

    # Issue 13305:  For years < 1000, the value is not always

            

Reported by Pylint.

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

Line: 590 Column: 9

                  def test_large_year(self):
        # Check that it doesn't crash for year > 9999
        self.assertEqual(self.yearstr(12345), '12345')
        self.assertEqual(self.yearstr(123456789), '123456789')

class _TestStrftimeYear:

    # Issue 13305:  For years < 1000, the value is not always
    # padded to 4 digits across platforms.  The C standard

            

Reported by Pylint.

Instance of '_TestStrftimeYear' has no 'test_year' member
Error

Line: 610 Column: 13

                  def test_4dyear(self):
        # Check that we can return the zero padded value.
        if self._format == '%04d':
            self.test_year('%04d')
        else:
            def year4d(y):
                return time.strftime('%4Y', (y,) + (0,) * 8)
            self.test_year('%04d', func=year4d)


            

Reported by Pylint.

Instance of '_TestStrftimeYear' has no 'test_year' member
Error

Line: 614 Column: 13

                      else:
            def year4d(y):
                return time.strftime('%4Y', (y,) + (0,) * 8)
            self.test_year('%04d', func=year4d)

    def skip_if_not_supported(y):
        msg = "strftime() is limited to [1; 9999] with Visual Studio"
        # Check that it doesn't crash for year > 9999
        try:

            

Reported by Pylint.

Method should have "self" as first argument
Error

Line: 616 Column: 5

                              return time.strftime('%4Y', (y,) + (0,) * 8)
            self.test_year('%04d', func=year4d)

    def skip_if_not_supported(y):
        msg = "strftime() is limited to [1; 9999] with Visual Studio"
        # Check that it doesn't crash for year > 9999
        try:
            time.strftime('%Y', (y,) + (0,) * 8)
        except ValueError:

            

Reported by Pylint.

Super of '_TestStrftimeYear' has no 'test_large_year' member
Error

Line: 629 Column: 16

              
    @skip_if_not_supported(10000)
    def test_large_year(self):
        return super().test_large_year()

    @skip_if_not_supported(0)
    def test_negative(self):
        return super().test_negative()


            

Reported by Pylint.

Super of '_TestStrftimeYear' has no 'test_negative' member
Error

Line: 633 Column: 16

              
    @skip_if_not_supported(0)
    def test_negative(self):
        return super().test_negative()

    del skip_if_not_supported


class _Test4dYear:

            

Reported by Pylint.

Instance of '_Test4dYear' has no 'yearstr' member
Error

Line: 643 Column: 24

              
    def test_year(self, fmt=None, func=None):
        fmt = fmt or self._format
        func = func or self.yearstr
        self.assertEqual(func(1),    fmt % 1)
        self.assertEqual(func(68),   fmt % 68)
        self.assertEqual(func(69),   fmt % 69)
        self.assertEqual(func(99),   fmt % 99)
        self.assertEqual(func(999),  fmt % 999)

            

Reported by Pylint.

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

Line: 644 Column: 9

                  def test_year(self, fmt=None, func=None):
        fmt = fmt or self._format
        func = func or self.yearstr
        self.assertEqual(func(1),    fmt % 1)
        self.assertEqual(func(68),   fmt % 68)
        self.assertEqual(func(69),   fmt % 69)
        self.assertEqual(func(99),   fmt % 99)
        self.assertEqual(func(999),  fmt % 999)
        self.assertEqual(func(9999), fmt % 9999)

            

Reported by Pylint.

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

Line: 645 Column: 9

                      fmt = fmt or self._format
        func = func or self.yearstr
        self.assertEqual(func(1),    fmt % 1)
        self.assertEqual(func(68),   fmt % 68)
        self.assertEqual(func(69),   fmt % 69)
        self.assertEqual(func(99),   fmt % 99)
        self.assertEqual(func(999),  fmt % 999)
        self.assertEqual(func(9999), fmt % 9999)


            

Reported by Pylint.

Lib/test/test_regrtest.py
237 issues
Instance of 'Namespace' has no 'wait' member
Error

Line: 67 Column: 25

              
    def test_wait(self):
        ns = libregrtest._parse_args(['--wait'])
        self.assertTrue(ns.wait)

    def test_worker_args(self):
        ns = libregrtest._parse_args(['--worker-args', '[[], {}]'])
        self.assertEqual(ns.worker_args, '[[], {}]')
        self.checkError(['--worker-args'], 'expected one argument')

            

Reported by Pylint.

Instance of 'Namespace' has no 'worker_args' member
Error

Line: 71 Column: 26

              
    def test_worker_args(self):
        ns = libregrtest._parse_args(['--worker-args', '[[], {}]'])
        self.assertEqual(ns.worker_args, '[[], {}]')
        self.checkError(['--worker-args'], 'expected one argument')

    def test_start(self):
        for opt in '-S', '--start':
            with self.subTest(opt=opt):

            

Reported by Pylint.

Instance of 'Namespace' has no 'start' member
Error

Line: 78 Column: 34

                      for opt in '-S', '--start':
            with self.subTest(opt=opt):
                ns = libregrtest._parse_args([opt, 'foo'])
                self.assertEqual(ns.start, 'foo')
                self.checkError([opt], 'expected one argument')

    def test_verbose(self):
        ns = libregrtest._parse_args(['-v'])
        self.assertEqual(ns.verbose, 1)

            

Reported by Pylint.

Instance of 'Namespace' has no 'memlimit' member
Error

Line: 237 Column: 34

                      for opt in '-M', '--memlimit':
            with self.subTest(opt=opt):
                ns = libregrtest._parse_args([opt, '4G'])
                self.assertEqual(ns.memlimit, '4G')
                self.checkError([opt], 'expected one argument')

    def test_testdir(self):
        ns = libregrtest._parse_args(['--testdir', 'foo'])
        self.assertEqual(ns.testdir, os.path.join(os_helper.SAVEDCWD, 'foo'))

            

Reported by Pylint.

Instance of 'Namespace' has no 'threshold' member
Error

Line: 302 Column: 34

                      for opt in '-t', '--threshold':
            with self.subTest(opt=opt):
                ns = libregrtest._parse_args([opt, '1000'])
                self.assertEqual(ns.threshold, 1000)
                self.checkError([opt], 'expected one argument')
                self.checkError([opt, 'foo'], 'invalid int value')

    def test_nowindows(self):
        for opt in '-n', '--nowindows':

            

Reported by Pylint.

Instance of 'Namespace' has no 'nowindows' member
Error

Line: 311 Column: 33

                          with self.subTest(opt=opt):
                with contextlib.redirect_stderr(io.StringIO()) as stderr:
                    ns = libregrtest._parse_args([opt])
                self.assertTrue(ns.nowindows)
                err = stderr.getvalue()
                self.assertIn('the --nowindows (-n) option is deprecated', err)

    def test_forever(self):
        for opt in '-F', '--forever':

            

Reported by Pylint.

Instance of 'Namespace' has no 'start' member
Error

Line: 337 Column: 26

              
    def test_option_with_empty_string_value(self):
        ns = libregrtest._parse_args(['--start', ''])
        self.assertEqual(ns.start, '')

    def test_arg(self):
        ns = libregrtest._parse_args(['foo'])
        self.assertEqual(ns.args, ['foo'])


            

Reported by Pylint.

Unused import time
Error

Line: 18 Column: 1

              import sysconfig
import tempfile
import textwrap
import time
import unittest
from test import libregrtest
from test import support
from test.support import os_helper
from test.libregrtest import utils, setup

            

Reported by Pylint.

Access to a protected member _parse_args of a client class
Error

Line: 48 Column: 13

              
    def checkError(self, args, msg):
        with support.captured_stderr() as err, self.assertRaises(SystemExit):
            libregrtest._parse_args(args)
        self.assertIn(msg, err.getvalue())

    def test_help(self):
        for opt in '-h', '--help':
            with self.subTest(opt=opt):

            

Reported by Pylint.

Access to a protected member _parse_args of a client class
Error

Line: 56 Column: 21

                          with self.subTest(opt=opt):
                with support.captured_stdout() as out, \
                     self.assertRaises(SystemExit):
                    libregrtest._parse_args([opt])
                self.assertIn('Run Python regression tests.', out.getvalue())

    def test_timeout(self):
        ns = libregrtest._parse_args(['--timeout', '4.2'])
        self.assertEqual(ns.timeout, 4.2)

            

Reported by Pylint.

Lib/sqlite3/test/dbapi.py
236 issues
Method should have "self" as first argument
Error

Line: 394 Column: 13

                      class L:
            def __len__(self):
                1/0
            def __getitem__(slf, x):
                raise AssertionError

        self.cu.execute("insert into test(name) values ('foo')")
        with self.assertRaises(ZeroDivisionError):
            self.cu.execute("select name from test where name=?", L())

            

Reported by Pylint.

Unused variable 'cu'
Error

Line: 149 Column: 9

                      self.cx.rollback()

    def test_cursor(self):
        cu = self.cx.cursor()

    def test_failed_open(self):
        YOU_CANNOT_OPEN_THIS = "/foo/bar/bla/23534/mydb.db"
        with self.assertRaises(sqlite.OperationalError):
            con = sqlite.connect(YOU_CANNOT_OPEN_THIS)

            

Reported by Pylint.

Unused variable 'con'
Error

Line: 154 Column: 13

                  def test_failed_open(self):
        YOU_CANNOT_OPEN_THIS = "/foo/bar/bla/23534/mydb.db"
        with self.assertRaises(sqlite.OperationalError):
            con = sqlite.connect(YOU_CANNOT_OPEN_THIS)

    def test_close(self):
        self.cx.close()

    def test_use_after_close(self):

            

Reported by Pylint.

Unused variable 'row'
Error

Line: 202 Column: 9

                      cu.execute("insert into transactiontest(name) values (?)", ("foo",))
        self.assertEqual(cx.in_transaction, True)
        cu.execute("select name from transactiontest where name=?", ["foo"])
        row = cu.fetchone()
        self.assertEqual(cx.in_transaction, True)
        cx.commit()
        self.assertEqual(cx.in_transaction, False)
        cu.execute("select name from transactiontest where name=?", ["foo"])
        row = cu.fetchone()

            

Reported by Pylint.

Lambda may not be necessary
Error

Line: 255 Column: 13

                          lambda: self.cx.isolation_level,
            lambda: self.cx.total_changes,
            lambda: self.cx.in_transaction,
            lambda: self.cx.iterdump(),
            lambda: self.cx.cursor(),
            lambda: self.cx.close(),
        )
        for func in funcs:
            with self.subTest(func=func):

            

Reported by Pylint.

Lambda may not be necessary
Error

Line: 256 Column: 13

                          lambda: self.cx.total_changes,
            lambda: self.cx.in_transaction,
            lambda: self.cx.iterdump(),
            lambda: self.cx.cursor(),
            lambda: self.cx.close(),
        )
        for func in funcs:
            with self.subTest(func=func):
                self.assertRaisesRegex(sqlite.ProgrammingError,

            

Reported by Pylint.

Lambda may not be necessary
Error

Line: 257 Column: 13

                          lambda: self.cx.in_transaction,
            lambda: self.cx.iterdump(),
            lambda: self.cx.cursor(),
            lambda: self.cx.close(),
        )
        for func in funcs:
            with self.subTest(func=func):
                self.assertRaisesRegex(sqlite.ProgrammingError,
                                       "Base Connection.__init__ not called",

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 393 Column: 17

                      # Issue41662: Error in __len__() was overridden with ProgrammingError.
        class L:
            def __len__(self):
                1/0
            def __getitem__(slf, x):
                raise AssertionError

        self.cu.execute("insert into test(name) values ('foo')")
        with self.assertRaises(ZeroDivisionError):

            

Reported by Pylint.

Unused variable 'cur'
Error

Line: 578 Column: 13

                  def test_wrong_cursor_callable(self):
        with self.assertRaises(TypeError):
            def f(): pass
            cur = self.cx.cursor(f)

    def test_cursor_wrong_class(self):
        class Foo: pass
        foo = Foo()
        with self.assertRaises(TypeError):

            

Reported by Pylint.

Unused variable 'cur'
Error

Line: 584 Column: 13

                      class Foo: pass
        foo = Foo()
        with self.assertRaises(TypeError):
            cur = sqlite.Cursor(foo)

    def test_last_row_id_on_replace(self):
        """
        INSERT OR REPLACE and REPLACE INTO should produce the same behavior.
        """

            

Reported by Pylint.

Lib/test/test_gzip.py
235 issues
Unused variable 'i'
Error

Line: 195 Column: 13

                      # works.
        with gzip.GzipFile(self.filename, 'wb', 9) as f:
            f.write(b'a')
        for i in range(0, 200):
            with gzip.GzipFile(self.filename, "ab", 9) as f: # append
                f.write(b'a')

        # Try reading the file
        with gzip.GzipFile(self.filename, "rb") as zgfile:

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 408 Column: 17

                          self.fail("__enter__ on a closed file didn't raise an exception")
        try:
            with gzip.GzipFile(self.filename, "wb") as f:
                1/0
        except ZeroDivisionError:
            pass
        else:
            self.fail("1/0 didn't raise an exception")


            

Reported by Pylint.

Unused variable 'g'
Error

Line: 480 Column: 56

                      # fileobj created with os.fdopen().
        fd = os.open(self.filename, os.O_WRONLY | os.O_CREAT)
        with os.fdopen(fd, "wb") as f:
            with gzip.GzipFile(fileobj=f, mode="w") as g:
                pass

    def test_fileobj_mode(self):
        gzip.GzipFile(self.filename, "wb").close()
        with open(self.filename, "r+b") as f:

            

Reported by Pylint.

Access to a protected member _buffer of a client class
Error

Line: 532 Column: 30

                      decomp = gzip.GzipFile(fileobj=bomb)
        self.assertEqual(decomp.read(1), b'\0')
        max_decomp = 1 + io.DEFAULT_BUFFER_SIZE
        self.assertLessEqual(decomp._buffer.raw.tell(), max_decomp,
            "Excessive amount of data was decompressed")

    # Testing compress/decompress shortcut functions

    def test_compress(self):

            

Reported by Pylint.

Access to a protected member _fp of a client class
Error

Line: 593 Column: 13

                      with gzip.open(self.filename, "wb") as f:
            f.write(data1)
        with gzip.open(self.filename, "rb") as f:
            f._buffer.raw._fp.prepend()

    def test_issue44439(self):
        q = array.array('Q', [1, 2, 3, 4, 5])
        LENGTH = len(q) * q.itemsize


            

Reported by Pylint.

Access to a protected member _buffer of a client class
Error

Line: 593 Column: 13

                      with gzip.open(self.filename, "wb") as f:
            f.write(data1)
        with gzip.open(self.filename, "rb") as f:
            f._buffer.raw._fp.prepend()

    def test_issue44439(self):
        q = array.array('Q', [1, 2, 3, 4, 5])
        LENGTH = len(q) * q.itemsize


            

Reported by Pylint.

Unused variable 'rc'
Error

Line: 809 Column: 9

                      with open(local_testgzip, 'wb') as fp:
            fp.write(self.data)

        rc, out, err = assert_python_ok('-m', 'gzip', local_testgzip)

        self.assertTrue(os.path.exists(gzipname))
        self.assertEqual(out, b'')
        self.assertEqual(err, b'')


            

Reported by Pylint.

Unused variable 'rc'
Error

Line: 826 Column: 17

                              with open(local_testgzip, 'wb') as fp:
                    fp.write(self.data)

                rc, out, err = assert_python_ok('-m', 'gzip', compress_level, local_testgzip)

                self.assertTrue(os.path.exists(gzipname))
                self.assertEqual(out, b'')
                self.assertEqual(err, b'')
                os.remove(gzipname)

            

Reported by Pylint.

Unused variable 'rc'
Error

Line: 835 Column: 9

                              self.assertFalse(os.path.exists(gzipname))

    def test_compress_fast_best_are_exclusive(self):
        rc, out, err = assert_python_failure('-m', 'gzip', '--fast', '--best')
        self.assertIn(b"error: argument --best: not allowed with argument --fast", err)
        self.assertEqual(out, b'')

    def test_decompress_cannot_have_flags_compression(self):
        rc, out, err = assert_python_failure('-m', 'gzip', '--fast', '-d')

            

Reported by Pylint.

Unused variable 'rc'
Error

Line: 840 Column: 9

                      self.assertEqual(out, b'')

    def test_decompress_cannot_have_flags_compression(self):
        rc, out, err = assert_python_failure('-m', 'gzip', '--fast', '-d')
        self.assertIn(b'error: argument -d/--decompress: not allowed with argument --fast', err)
        self.assertEqual(out, b'')


def test_main(verbose=None):

            

Reported by Pylint.

Lib/test/test_gettext.py
234 issues
Undefined variable '_'
Error

Line: 158 Column: 12

                  def test_some_translations(self):
        eq = self.assertEqual
        # test some translations
        eq(_('albatross'), 'albatross')
        eq(_('mullusk'), 'bacon')
        eq(_(r'Raymond Luxury Yach-t'), 'Throatwobbler Mangrove')
        eq(_(r'nudge nudge'), 'wink wink')

    def test_some_translations_with_context(self):

            

Reported by Pylint.

Undefined variable '_'
Error

Line: 159 Column: 12

                      eq = self.assertEqual
        # test some translations
        eq(_('albatross'), 'albatross')
        eq(_('mullusk'), 'bacon')
        eq(_(r'Raymond Luxury Yach-t'), 'Throatwobbler Mangrove')
        eq(_(r'nudge nudge'), 'wink wink')

    def test_some_translations_with_context(self):
        eq = self.assertEqual

            

Reported by Pylint.

Undefined variable '_'
Error

Line: 160 Column: 12

                      # test some translations
        eq(_('albatross'), 'albatross')
        eq(_('mullusk'), 'bacon')
        eq(_(r'Raymond Luxury Yach-t'), 'Throatwobbler Mangrove')
        eq(_(r'nudge nudge'), 'wink wink')

    def test_some_translations_with_context(self):
        eq = self.assertEqual
        eq(pgettext('my context', 'nudge nudge'),

            

Reported by Pylint.

Undefined variable '_'
Error

Line: 161 Column: 12

                      eq(_('albatross'), 'albatross')
        eq(_('mullusk'), 'bacon')
        eq(_(r'Raymond Luxury Yach-t'), 'Throatwobbler Mangrove')
        eq(_(r'nudge nudge'), 'wink wink')

    def test_some_translations_with_context(self):
        eq = self.assertEqual
        eq(pgettext('my context', 'nudge nudge'),
           'wink wink (in "my context")')

            

Reported by Pylint.

Undefined variable 'pgettext'
Error

Line: 165 Column: 12

              
    def test_some_translations_with_context(self):
        eq = self.assertEqual
        eq(pgettext('my context', 'nudge nudge'),
           'wink wink (in "my context")')
        eq(pgettext('my other context', 'nudge nudge'),
           'wink wink (in "my other context")')

    def test_double_quotes(self):

            

Reported by Pylint.

Undefined variable 'pgettext'
Error

Line: 167 Column: 12

                      eq = self.assertEqual
        eq(pgettext('my context', 'nudge nudge'),
           'wink wink (in "my context")')
        eq(pgettext('my other context', 'nudge nudge'),
           'wink wink (in "my other context")')

    def test_double_quotes(self):
        eq = self.assertEqual
        # double quotes

            

Reported by Pylint.

Undefined variable '_'
Error

Line: 173 Column: 12

                  def test_double_quotes(self):
        eq = self.assertEqual
        # double quotes
        eq(_("albatross"), 'albatross')
        eq(_("mullusk"), 'bacon')
        eq(_(r"Raymond Luxury Yach-t"), 'Throatwobbler Mangrove')
        eq(_(r"nudge nudge"), 'wink wink')

    def test_triple_single_quotes(self):

            

Reported by Pylint.

Undefined variable '_'
Error

Line: 174 Column: 12

                      eq = self.assertEqual
        # double quotes
        eq(_("albatross"), 'albatross')
        eq(_("mullusk"), 'bacon')
        eq(_(r"Raymond Luxury Yach-t"), 'Throatwobbler Mangrove')
        eq(_(r"nudge nudge"), 'wink wink')

    def test_triple_single_quotes(self):
        eq = self.assertEqual

            

Reported by Pylint.

Undefined variable '_'
Error

Line: 175 Column: 12

                      # double quotes
        eq(_("albatross"), 'albatross')
        eq(_("mullusk"), 'bacon')
        eq(_(r"Raymond Luxury Yach-t"), 'Throatwobbler Mangrove')
        eq(_(r"nudge nudge"), 'wink wink')

    def test_triple_single_quotes(self):
        eq = self.assertEqual
        # triple single quotes

            

Reported by Pylint.

Undefined variable '_'
Error

Line: 176 Column: 12

                      eq(_("albatross"), 'albatross')
        eq(_("mullusk"), 'bacon')
        eq(_(r"Raymond Luxury Yach-t"), 'Throatwobbler Mangrove')
        eq(_(r"nudge nudge"), 'wink wink')

    def test_triple_single_quotes(self):
        eq = self.assertEqual
        # triple single quotes
        eq(_('''albatross'''), 'albatross')

            

Reported by Pylint.

Lib/sre_compile.py
232 issues
Undefined variable 'LITERAL'
Error

Line: 19 Column: 19

              
assert _sre.MAGIC == MAGIC, "SRE module mismatch"

_LITERAL_CODES = {LITERAL, NOT_LITERAL}
_REPEATING_CODES = {REPEAT, MIN_REPEAT, MAX_REPEAT}
_SUCCESS_CODES = {SUCCESS, FAILURE}
_ASSERT_CODES = {ASSERT, ASSERT_NOT}
_UNIT_CODES = _LITERAL_CODES | {ANY, IN}


            

Reported by Pylint.

Undefined variable 'NOT_LITERAL'
Error

Line: 19 Column: 28

              
assert _sre.MAGIC == MAGIC, "SRE module mismatch"

_LITERAL_CODES = {LITERAL, NOT_LITERAL}
_REPEATING_CODES = {REPEAT, MIN_REPEAT, MAX_REPEAT}
_SUCCESS_CODES = {SUCCESS, FAILURE}
_ASSERT_CODES = {ASSERT, ASSERT_NOT}
_UNIT_CODES = _LITERAL_CODES | {ANY, IN}


            

Reported by Pylint.

Undefined variable 'REPEAT'
Error

Line: 20 Column: 21

              assert _sre.MAGIC == MAGIC, "SRE module mismatch"

_LITERAL_CODES = {LITERAL, NOT_LITERAL}
_REPEATING_CODES = {REPEAT, MIN_REPEAT, MAX_REPEAT}
_SUCCESS_CODES = {SUCCESS, FAILURE}
_ASSERT_CODES = {ASSERT, ASSERT_NOT}
_UNIT_CODES = _LITERAL_CODES | {ANY, IN}

# Sets of lowercase characters which have the same uppercase.

            

Reported by Pylint.

Undefined variable 'MIN_REPEAT'
Error

Line: 20 Column: 29

              assert _sre.MAGIC == MAGIC, "SRE module mismatch"

_LITERAL_CODES = {LITERAL, NOT_LITERAL}
_REPEATING_CODES = {REPEAT, MIN_REPEAT, MAX_REPEAT}
_SUCCESS_CODES = {SUCCESS, FAILURE}
_ASSERT_CODES = {ASSERT, ASSERT_NOT}
_UNIT_CODES = _LITERAL_CODES | {ANY, IN}

# Sets of lowercase characters which have the same uppercase.

            

Reported by Pylint.

Undefined variable 'MAX_REPEAT'
Error

Line: 20 Column: 41

              assert _sre.MAGIC == MAGIC, "SRE module mismatch"

_LITERAL_CODES = {LITERAL, NOT_LITERAL}
_REPEATING_CODES = {REPEAT, MIN_REPEAT, MAX_REPEAT}
_SUCCESS_CODES = {SUCCESS, FAILURE}
_ASSERT_CODES = {ASSERT, ASSERT_NOT}
_UNIT_CODES = _LITERAL_CODES | {ANY, IN}

# Sets of lowercase characters which have the same uppercase.

            

Reported by Pylint.

Undefined variable 'SUCCESS'
Error

Line: 21 Column: 19

              
_LITERAL_CODES = {LITERAL, NOT_LITERAL}
_REPEATING_CODES = {REPEAT, MIN_REPEAT, MAX_REPEAT}
_SUCCESS_CODES = {SUCCESS, FAILURE}
_ASSERT_CODES = {ASSERT, ASSERT_NOT}
_UNIT_CODES = _LITERAL_CODES | {ANY, IN}

# Sets of lowercase characters which have the same uppercase.
_equivalences = (

            

Reported by Pylint.

Undefined variable 'FAILURE'
Error

Line: 21 Column: 28

              
_LITERAL_CODES = {LITERAL, NOT_LITERAL}
_REPEATING_CODES = {REPEAT, MIN_REPEAT, MAX_REPEAT}
_SUCCESS_CODES = {SUCCESS, FAILURE}
_ASSERT_CODES = {ASSERT, ASSERT_NOT}
_UNIT_CODES = _LITERAL_CODES | {ANY, IN}

# Sets of lowercase characters which have the same uppercase.
_equivalences = (

            

Reported by Pylint.

Undefined variable 'ASSERT'
Error

Line: 22 Column: 18

              _LITERAL_CODES = {LITERAL, NOT_LITERAL}
_REPEATING_CODES = {REPEAT, MIN_REPEAT, MAX_REPEAT}
_SUCCESS_CODES = {SUCCESS, FAILURE}
_ASSERT_CODES = {ASSERT, ASSERT_NOT}
_UNIT_CODES = _LITERAL_CODES | {ANY, IN}

# Sets of lowercase characters which have the same uppercase.
_equivalences = (
    # LATIN SMALL LETTER I, LATIN SMALL LETTER DOTLESS I

            

Reported by Pylint.

Undefined variable 'ASSERT_NOT'
Error

Line: 22 Column: 26

              _LITERAL_CODES = {LITERAL, NOT_LITERAL}
_REPEATING_CODES = {REPEAT, MIN_REPEAT, MAX_REPEAT}
_SUCCESS_CODES = {SUCCESS, FAILURE}
_ASSERT_CODES = {ASSERT, ASSERT_NOT}
_UNIT_CODES = _LITERAL_CODES | {ANY, IN}

# Sets of lowercase characters which have the same uppercase.
_equivalences = (
    # LATIN SMALL LETTER I, LATIN SMALL LETTER DOTLESS I

            

Reported by Pylint.

Undefined variable 'ANY'
Error

Line: 23 Column: 33

              _REPEATING_CODES = {REPEAT, MIN_REPEAT, MAX_REPEAT}
_SUCCESS_CODES = {SUCCESS, FAILURE}
_ASSERT_CODES = {ASSERT, ASSERT_NOT}
_UNIT_CODES = _LITERAL_CODES | {ANY, IN}

# Sets of lowercase characters which have the same uppercase.
_equivalences = (
    # LATIN SMALL LETTER I, LATIN SMALL LETTER DOTLESS I
    (0x69, 0x131), # iı

            

Reported by Pylint.