The following issues were found

Lib/test/test_pkg.py
66 issues
Unable to import 't1'
Error

Line: 97 Column: 9

                  def test_1(self):
        hier = [("t1", None), ("t1 __init__.py", "")]
        self.mkhier(hier)
        import t1

    def test_2(self):
        hier = [
         ("t2", None),
         ("t2 __init__.py", "'doc for t2'"),

            

Reported by Pylint.

Unable to import 't2.sub'
Error

Line: 110 Column: 9

                      ]
        self.mkhier(hier)

        import t2.sub
        import t2.sub.subsub
        self.assertEqual(t2.__name__, "t2")
        self.assertEqual(t2.sub.__name__, "t2.sub")
        self.assertEqual(t2.sub.subsub.__name__, "t2.sub.subsub")


            

Reported by Pylint.

Unable to import 't2.sub.subsub'
Error

Line: 111 Column: 9

                      self.mkhier(hier)

        import t2.sub
        import t2.sub.subsub
        self.assertEqual(t2.__name__, "t2")
        self.assertEqual(t2.sub.__name__, "t2.sub")
        self.assertEqual(t2.sub.subsub.__name__, "t2.sub.subsub")

        # This exec crap is needed because Py3k forbids 'import *' outside

            

Reported by Pylint.

Unable to import 't2'
Error

Line: 125 Column: 9

                          """
        self.run_code(s)

        from t2 import sub
        from t2.sub import subsub
        from t2.sub.subsub import spam
        self.assertEqual(sub.__name__, "t2.sub")
        self.assertEqual(subsub.__name__, "t2.sub.subsub")
        self.assertEqual(sub.subsub.__name__, "t2.sub.subsub")

            

Reported by Pylint.

Unable to import 't2.sub'
Error

Line: 126 Column: 9

                      self.run_code(s)

        from t2 import sub
        from t2.sub import subsub
        from t2.sub.subsub import spam
        self.assertEqual(sub.__name__, "t2.sub")
        self.assertEqual(subsub.__name__, "t2.sub.subsub")
        self.assertEqual(sub.subsub.__name__, "t2.sub.subsub")
        for name in ['spam', 'sub', 'subsub', 't2']:

            

Reported by Pylint.

Unable to import 't2.sub.subsub'
Error

Line: 127 Column: 9

              
        from t2 import sub
        from t2.sub import subsub
        from t2.sub.subsub import spam
        self.assertEqual(sub.__name__, "t2.sub")
        self.assertEqual(subsub.__name__, "t2.sub.subsub")
        self.assertEqual(sub.subsub.__name__, "t2.sub.subsub")
        for name in ['spam', 'sub', 'subsub', 't2']:
            self.assertTrue(locals()["name"], "Failed to import %s" % name)

            

Reported by Pylint.

Unable to import 't2.sub'
Error

Line: 134 Column: 9

                      for name in ['spam', 'sub', 'subsub', 't2']:
            self.assertTrue(locals()["name"], "Failed to import %s" % name)

        import t2.sub
        import t2.sub.subsub
        self.assertEqual(t2.__name__, "t2")
        self.assertEqual(t2.sub.__name__, "t2.sub")
        self.assertEqual(t2.sub.subsub.__name__, "t2.sub.subsub")


            

Reported by Pylint.

Unable to import 't2.sub.subsub'
Error

Line: 135 Column: 9

                          self.assertTrue(locals()["name"], "Failed to import %s" % name)

        import t2.sub
        import t2.sub.subsub
        self.assertEqual(t2.__name__, "t2")
        self.assertEqual(t2.sub.__name__, "t2.sub")
        self.assertEqual(t2.sub.subsub.__name__, "t2.sub.subsub")

        s = """

            

Reported by Pylint.

Unable to import 't3.sub.subsub'
Error

Line: 157 Column: 9

                             ]
        self.mkhier(hier)

        import t3.sub.subsub
        self.assertEqual(t3.__name__, "t3")
        self.assertEqual(t3.sub.__name__, "t3.sub")
        self.assertEqual(t3.sub.subsub.__name__, "t3.sub.subsub")

    def test_4(self):

            

Reported by Pylint.

Unable to import 't5'
Error

Line: 193 Column: 9

                       ]
        self.mkhier(hier)

        import t5
        s = """
            from t5 import *
            self.assertEqual(dir(), ['foo', 'self', 'string', 't5'])
            """
        self.run_code(s)

            

Reported by Pylint.

Lib/test/test_sched.py
66 issues
Lambda may not be necessary
Error

Line: 45 Column: 15

              
    def test_enter(self):
        l = []
        fun = lambda x: l.append(x)
        scheduler = sched.scheduler(time.time, time.sleep)
        for x in [0.5, 0.4, 0.3, 0.2, 0.1]:
            z = scheduler.enter(x, 1, fun, (x,))
        scheduler.run()
        self.assertEqual(l, [0.1, 0.2, 0.3, 0.4, 0.5])

            

Reported by Pylint.

Unused variable 'z'
Error

Line: 48 Column: 13

                      fun = lambda x: l.append(x)
        scheduler = sched.scheduler(time.time, time.sleep)
        for x in [0.5, 0.4, 0.3, 0.2, 0.1]:
            z = scheduler.enter(x, 1, fun, (x,))
        scheduler.run()
        self.assertEqual(l, [0.1, 0.2, 0.3, 0.4, 0.5])

    def test_enterabs(self):
        l = []

            

Reported by Pylint.

Lambda may not be necessary
Error

Line: 54 Column: 15

              
    def test_enterabs(self):
        l = []
        fun = lambda x: l.append(x)
        scheduler = sched.scheduler(time.time, time.sleep)
        for x in [0.05, 0.04, 0.03, 0.02, 0.01]:
            z = scheduler.enterabs(x, 1, fun, (x,))
        scheduler.run()
        self.assertEqual(l, [0.01, 0.02, 0.03, 0.04, 0.05])

            

Reported by Pylint.

Unused variable 'z'
Error

Line: 57 Column: 13

                      fun = lambda x: l.append(x)
        scheduler = sched.scheduler(time.time, time.sleep)
        for x in [0.05, 0.04, 0.03, 0.02, 0.01]:
            z = scheduler.enterabs(x, 1, fun, (x,))
        scheduler.run()
        self.assertEqual(l, [0.01, 0.02, 0.03, 0.04, 0.05])

    def test_enter_concurrent(self):
        q = queue.Queue()

            

Reported by Pylint.

Unused variable 'z'
Error

Line: 74 Column: 13

                      self.assertEqual(q.get(timeout=TIMEOUT), 1)
        self.assertTrue(q.empty())
        for x in [4, 5, 2]:
            z = scheduler.enter(x - 1, 1, fun, (x,))
        timer.advance(2)
        self.assertEqual(q.get(timeout=TIMEOUT), 2)
        self.assertEqual(q.get(timeout=TIMEOUT), 3)
        self.assertTrue(q.empty())
        timer.advance(1)

            

Reported by Pylint.

Lambda may not be necessary
Error

Line: 92 Column: 15

              
    def test_priority(self):
        l = []
        fun = lambda x: l.append(x)
        scheduler = sched.scheduler(time.time, time.sleep)
        for priority in [1, 2, 3, 4, 5]:
            z = scheduler.enterabs(0.01, priority, fun, (priority,))
        scheduler.run()
        self.assertEqual(l, [1, 2, 3, 4, 5])

            

Reported by Pylint.

Unused variable 'z'
Error

Line: 95 Column: 13

                      fun = lambda x: l.append(x)
        scheduler = sched.scheduler(time.time, time.sleep)
        for priority in [1, 2, 3, 4, 5]:
            z = scheduler.enterabs(0.01, priority, fun, (priority,))
        scheduler.run()
        self.assertEqual(l, [1, 2, 3, 4, 5])

    def test_cancel(self):
        l = []

            

Reported by Pylint.

Lambda may not be necessary
Error

Line: 101 Column: 15

              
    def test_cancel(self):
        l = []
        fun = lambda x: l.append(x)
        scheduler = sched.scheduler(time.time, time.sleep)
        now = time.time()
        event1 = scheduler.enterabs(now + 0.01, 1, fun, (0.01,))
        event2 = scheduler.enterabs(now + 0.02, 1, fun, (0.02,))
        event3 = scheduler.enterabs(now + 0.03, 1, fun, (0.03,))

            

Reported by Pylint.

Unused variable 'event2'
Error

Line: 105 Column: 9

                      scheduler = sched.scheduler(time.time, time.sleep)
        now = time.time()
        event1 = scheduler.enterabs(now + 0.01, 1, fun, (0.01,))
        event2 = scheduler.enterabs(now + 0.02, 1, fun, (0.02,))
        event3 = scheduler.enterabs(now + 0.03, 1, fun, (0.03,))
        event4 = scheduler.enterabs(now + 0.04, 1, fun, (0.04,))
        event5 = scheduler.enterabs(now + 0.05, 1, fun, (0.05,))
        scheduler.cancel(event1)
        scheduler.cancel(event5)

            

Reported by Pylint.

Unused variable 'event3'
Error

Line: 106 Column: 9

                      now = time.time()
        event1 = scheduler.enterabs(now + 0.01, 1, fun, (0.01,))
        event2 = scheduler.enterabs(now + 0.02, 1, fun, (0.02,))
        event3 = scheduler.enterabs(now + 0.03, 1, fun, (0.03,))
        event4 = scheduler.enterabs(now + 0.04, 1, fun, (0.04,))
        event5 = scheduler.enterabs(now + 0.05, 1, fun, (0.05,))
        scheduler.cancel(event1)
        scheduler.cancel(event5)
        scheduler.run()

            

Reported by Pylint.

Lib/test/test_unicodedata.py
66 issues
Use of insecure MD2, MD4, MD5, or SHA1 hash function.
Security blacklist

Line: 25
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b303-md5

              
    @requires_resource('cpu')
    def test_method_checksum(self):
        h = hashlib.sha1()
        for i in range(sys.maxunicode + 1):
            char = chr(i)
            data = [
                # Predicates (single char)
                "01"[char.isalnum()],

            

Reported by Bandit.

Use of insecure MD2, MD4, MD5, or SHA1 hash function.
Security blacklist

Line: 79
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b303-md5

                  @requires_resource('cpu')
    def test_function_checksum(self):
        data = []
        h = hashlib.sha1()

        for i in range(sys.maxunicode + 1):
            char = chr(i)
            data = [
                # Properties

            

Reported by Bandit.

Reimport 'unicodedata' (imported line 12)
Error

Line: 280 Column: 9

                      self.assertEqual(self.db.lookup("GOTHIC LETTER FAIHU"), '\U00010346')

    def test_ucd_510(self):
        import unicodedata
        # In UCD 5.1.0, a mirrored property changed wrt. UCD 3.2.0
        self.assertTrue(unicodedata.mirrored("\u0f3a"))
        self.assertTrue(not unicodedata.ucd_3_2_0.mirrored("\u0f3a"))
        # Also, we now have two ways of representing
        # the upper-case mapping: as delta, or as absolute value

            

Reported by Pylint.

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

Line: 280 Column: 9

                      self.assertEqual(self.db.lookup("GOTHIC LETTER FAIHU"), '\U00010346')

    def test_ucd_510(self):
        import unicodedata
        # In UCD 5.1.0, a mirrored property changed wrt. UCD 3.2.0
        self.assertTrue(unicodedata.mirrored("\u0f3a"))
        self.assertTrue(not unicodedata.ucd_3_2_0.mirrored("\u0f3a"))
        # Also, we now have two ways of representing
        # the upper-case mapping: as delta, or as absolute value

            

Reported by Pylint.

Redefining built-in 'str'
Error

Line: 351 Column: 17

                      part = None
        part1_data = {}

        def NFC(str):
            return unicodedata.normalize("NFC", str)

        def NFKC(str):
            return unicodedata.normalize("NFKC", str)


            

Reported by Pylint.

Redefining built-in 'str'
Error

Line: 354 Column: 18

                      def NFC(str):
            return unicodedata.normalize("NFC", str)

        def NFKC(str):
            return unicodedata.normalize("NFKC", str)

        def NFD(str):
            return unicodedata.normalize("NFD", str)


            

Reported by Pylint.

Redefining built-in 'str'
Error

Line: 357 Column: 17

                      def NFKC(str):
            return unicodedata.normalize("NFKC", str)

        def NFD(str):
            return unicodedata.normalize("NFD", str)

        def NFKD(str):
            return unicodedata.normalize("NFKD", str)


            

Reported by Pylint.

Redefining built-in 'str'
Error

Line: 360 Column: 18

                      def NFD(str):
            return unicodedata.normalize("NFD", str)

        def NFKD(str):
            return unicodedata.normalize("NFKD", str)

        for line in testdata:
            if '#' in line:
                line = line.split('#')[0]

            

Reported by Pylint.

Missing class docstring
Error

Line: 18 Column: 1

                                        cpython_only, check_disallow_instantiation)


class UnicodeMethodsTest(unittest.TestCase):

    # update this, if the database changes
    expectedchecksum = 'fbdf8106a3c7c242086b0a9efa03ad4d30d5b85d'

    @requires_resource('cpu')

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 24 Column: 5

                  expectedchecksum = 'fbdf8106a3c7c242086b0a9efa03ad4d30d5b85d'

    @requires_resource('cpu')
    def test_method_checksum(self):
        h = hashlib.sha1()
        for i in range(sys.maxunicode + 1):
            char = chr(i)
            data = [
                # Predicates (single char)

            

Reported by Pylint.

Tools/pynche/ListViewer.py
65 issues
Unable to import 'tkinter'
Error

Line: 18 Column: 1

              given name, without selecting the color.
"""

from tkinter import *
import ColorDB

ADDTOVIEW = 'Color %List Window...'

class ListViewer:

            

Reported by Pylint.

Unable to import 'ColorDB'
Error

Line: 19 Column: 1

              """

from tkinter import *
import ColorDB

ADDTOVIEW = 'Color %List Window...'

class ListViewer:
    def __init__(self, switchboard, master=None):

            

Reported by Pylint.

Undefined variable 'Toplevel'
Error

Line: 30 Column: 30

                      self.__lastbox = None
        self.__dontcenter = 0
        # GUI
        root = self.__root = Toplevel(master, class_='Pynche')
        root.protocol('WM_DELETE_WINDOW', self.withdraw)
        root.title('Pynche Color List')
        root.iconname('Pynche Color List')
        root.bind('<Alt-q>', self.__quit)
        root.bind('<Alt-Q>', self.__quit)

            

Reported by Pylint.

Undefined variable 'Frame'
Error

Line: 41 Column: 32

                      #
        # create the canvas which holds everything, and its scrollbar
        #
        frame = self.__frame = Frame(root)
        frame.pack()
        canvas = self.__canvas = Canvas(frame, width=160, height=300,
                                        borderwidth=2, relief=SUNKEN)
        self.__scrollbar = Scrollbar(frame)
        self.__scrollbar.pack(fill=Y, side=RIGHT)

            

Reported by Pylint.

Undefined variable 'Canvas'
Error

Line: 43 Column: 34

                      #
        frame = self.__frame = Frame(root)
        frame.pack()
        canvas = self.__canvas = Canvas(frame, width=160, height=300,
                                        borderwidth=2, relief=SUNKEN)
        self.__scrollbar = Scrollbar(frame)
        self.__scrollbar.pack(fill=Y, side=RIGHT)
        canvas.pack(fill=BOTH, expand=1)
        canvas.configure(yscrollcommand=(self.__scrollbar, 'set'))

            

Reported by Pylint.

Undefined variable 'SUNKEN'
Error

Line: 44 Column: 63

                      frame = self.__frame = Frame(root)
        frame.pack()
        canvas = self.__canvas = Canvas(frame, width=160, height=300,
                                        borderwidth=2, relief=SUNKEN)
        self.__scrollbar = Scrollbar(frame)
        self.__scrollbar.pack(fill=Y, side=RIGHT)
        canvas.pack(fill=BOTH, expand=1)
        canvas.configure(yscrollcommand=(self.__scrollbar, 'set'))
        self.__scrollbar.configure(command=(canvas, 'yview'))

            

Reported by Pylint.

Undefined variable 'Scrollbar'
Error

Line: 45 Column: 28

                      frame.pack()
        canvas = self.__canvas = Canvas(frame, width=160, height=300,
                                        borderwidth=2, relief=SUNKEN)
        self.__scrollbar = Scrollbar(frame)
        self.__scrollbar.pack(fill=Y, side=RIGHT)
        canvas.pack(fill=BOTH, expand=1)
        canvas.configure(yscrollcommand=(self.__scrollbar, 'set'))
        self.__scrollbar.configure(command=(canvas, 'yview'))
        self.__populate()

            

Reported by Pylint.

Undefined variable 'RIGHT'
Error

Line: 46 Column: 44

                      canvas = self.__canvas = Canvas(frame, width=160, height=300,
                                        borderwidth=2, relief=SUNKEN)
        self.__scrollbar = Scrollbar(frame)
        self.__scrollbar.pack(fill=Y, side=RIGHT)
        canvas.pack(fill=BOTH, expand=1)
        canvas.configure(yscrollcommand=(self.__scrollbar, 'set'))
        self.__scrollbar.configure(command=(canvas, 'yview'))
        self.__populate()
        #

            

Reported by Pylint.

Undefined variable 'Y'
Error

Line: 46 Column: 36

                      canvas = self.__canvas = Canvas(frame, width=160, height=300,
                                        borderwidth=2, relief=SUNKEN)
        self.__scrollbar = Scrollbar(frame)
        self.__scrollbar.pack(fill=Y, side=RIGHT)
        canvas.pack(fill=BOTH, expand=1)
        canvas.configure(yscrollcommand=(self.__scrollbar, 'set'))
        self.__scrollbar.configure(command=(canvas, 'yview'))
        self.__populate()
        #

            

Reported by Pylint.

Undefined variable 'BOTH'
Error

Line: 47 Column: 26

                                                      borderwidth=2, relief=SUNKEN)
        self.__scrollbar = Scrollbar(frame)
        self.__scrollbar.pack(fill=Y, side=RIGHT)
        canvas.pack(fill=BOTH, expand=1)
        canvas.configure(yscrollcommand=(self.__scrollbar, 'set'))
        self.__scrollbar.configure(command=(canvas, 'yview'))
        self.__populate()
        #
        # Update on click

            

Reported by Pylint.

Lib/distutils/command/build_py.py
65 issues
No value for argument 'a' in function call
Error

Line: 165 Column: 28

                                  del path[-1]
                else:
                    tail.insert(0, pdir)
                    return os.path.join(*tail)
            else:
                # Oops, got all the way through 'path' without finding a
                # match in package_dir.  If package_dir defines a directory
                # for the root (nameless) package, then fallback on it;
                # otherwise, we might as well have not consulted

            

Reported by Pylint.

No value for argument 'a' in function call
Error

Line: 179 Column: 28

                                  tail.insert(0, pdir)

                if tail:
                    return os.path.join(*tail)
                else:
                    return ''

    def check_package(self, package, package_dir):
        # Empty dir name means current directory, which we can probably

            

Reported by Pylint.

Value 'prefix' is unsubscriptable
Error

Line: 381 Column: 12

              
        from distutils.util import byte_compile
        prefix = self.build_lib
        if prefix[-1] != os.sep:
            prefix = prefix + os.sep

        # XXX this code is essentially the same as the 'byte_compile()
        # method of the "install_lib" command, except for the determination
        # of the 'prefix' string.  Hmmm.

            

Reported by Pylint.

Unused import DistutilsSetupError from wildcard import
Error

Line: 11 Column: 1

              import glob

from distutils.core import Command
from distutils.errors import *
from distutils.util import convert_path, Mixin2to3
from distutils import log

class build_py (Command):


            

Reported by Pylint.

Unused import LinkError from wildcard import
Error

Line: 11 Column: 1

              import glob

from distutils.core import Command
from distutils.errors import *
from distutils.util import convert_path, Mixin2to3
from distutils import log

class build_py (Command):


            

Reported by Pylint.

Unused import DistutilsInternalError from wildcard import
Error

Line: 11 Column: 1

              import glob

from distutils.core import Command
from distutils.errors import *
from distutils.util import convert_path, Mixin2to3
from distutils import log

class build_py (Command):


            

Reported by Pylint.

Unused import DistutilsTemplateError from wildcard import
Error

Line: 11 Column: 1

              import glob

from distutils.core import Command
from distutils.errors import *
from distutils.util import convert_path, Mixin2to3
from distutils import log

class build_py (Command):


            

Reported by Pylint.

Unused import DistutilsByteCompileError from wildcard import
Error

Line: 11 Column: 1

              import glob

from distutils.core import Command
from distutils.errors import *
from distutils.util import convert_path, Mixin2to3
from distutils import log

class build_py (Command):


            

Reported by Pylint.

Unused import CCompilerError from wildcard import
Error

Line: 11 Column: 1

              import glob

from distutils.core import Command
from distutils.errors import *
from distutils.util import convert_path, Mixin2to3
from distutils import log

class build_py (Command):


            

Reported by Pylint.

Unused import PreprocessError from wildcard import
Error

Line: 11 Column: 1

              import glob

from distutils.core import Command
from distutils.errors import *
from distutils.util import convert_path, Mixin2to3
from distutils import log

class build_py (Command):


            

Reported by Pylint.

Lib/idlelib/undo.py
65 issues
Unused argument 'event'
Error

Line: 40 Column: 26

                          self.bind("<<redo>>", self.redo_event)
            self.bind("<<dump-undo-state>>", self.dump_event)

    def dump_event(self, event):
        from pprint import pprint
        pprint(self.undolist[:self.pointer])
        print("pointer:", self.pointer, end=' ')
        print("saved:", self.saved, end=' ')
        print("can_merge:", self.can_merge, end=' ')

            

Reported by Pylint.

Attribute 'saved' defined outside __init__
Error

Line: 59 Column: 13

              
    def set_saved(self, flag):
        if flag:
            self.saved = self.pointer
        else:
            self.saved = -1
        self.can_merge = False
        self.check_saved()


            

Reported by Pylint.

Attribute 'saved' defined outside __init__
Error

Line: 61 Column: 13

                      if flag:
            self.saved = self.pointer
        else:
            self.saved = -1
        self.can_merge = False
        self.check_saved()

    def get_saved(self):
        return self.saved == self.pointer

            

Reported by Pylint.

Attribute 'can_merge' defined outside __init__
Error

Line: 62 Column: 9

                          self.saved = self.pointer
        else:
            self.saved = -1
        self.can_merge = False
        self.check_saved()

    def get_saved(self):
        return self.saved == self.pointer


            

Reported by Pylint.

Attribute 'undoblock' defined outside __init__
Error

Line: 101 Column: 13

              
    def undo_block_start(self):
        if self.undoblock == 0:
            self.undoblock = CommandSequence()
        self.undoblock.bump_depth()

    def undo_block_stop(self):
        if self.undoblock.bump_depth(-1) == 0:
            cmd = self.undoblock

            

Reported by Pylint.

Attribute 'undoblock' defined outside __init__
Error

Line: 107 Column: 13

                  def undo_block_stop(self):
        if self.undoblock.bump_depth(-1) == 0:
            cmd = self.undoblock
            self.undoblock = 0
            if len(cmd) > 0:
                if len(cmd) == 1:
                    # no need to wrap a single cmd
                    cmd = cmd.getcmd(0)
                # this blk of cmds, or single cmd, has already

            

Reported by Pylint.

Attribute 'saved' defined outside __init__
Error

Line: 128 Column: 13

                              return
        self.undolist[self.pointer:] = [cmd]
        if self.saved > self.pointer:
            self.saved = -1
        self.pointer = self.pointer + 1
        if len(self.undolist) > self.max_undo:
            ##print "truncating undo list"
            del self.undolist[0]
            self.pointer = self.pointer - 1

            

Reported by Pylint.

Attribute 'pointer' defined outside __init__
Error

Line: 129 Column: 9

                      self.undolist[self.pointer:] = [cmd]
        if self.saved > self.pointer:
            self.saved = -1
        self.pointer = self.pointer + 1
        if len(self.undolist) > self.max_undo:
            ##print "truncating undo list"
            del self.undolist[0]
            self.pointer = self.pointer - 1
            if self.saved >= 0:

            

Reported by Pylint.

Attribute 'pointer' defined outside __init__
Error

Line: 133 Column: 13

                      if len(self.undolist) > self.max_undo:
            ##print "truncating undo list"
            del self.undolist[0]
            self.pointer = self.pointer - 1
            if self.saved >= 0:
                self.saved = self.saved - 1
        self.can_merge = True
        self.check_saved()


            

Reported by Pylint.

Attribute 'saved' defined outside __init__
Error

Line: 135 Column: 17

                          del self.undolist[0]
            self.pointer = self.pointer - 1
            if self.saved >= 0:
                self.saved = self.saved - 1
        self.can_merge = True
        self.check_saved()

    def undo_event(self, event):
        if self.pointer == 0:

            

Reported by Pylint.

Lib/test/mock_socket.py
65 issues
Using the global statement
Error

Line: 15 Column: 5

              # *before* the socket object is even created. It is intended to handle a single
# line which the socket will feed on recv() or makefile().
def reply_with(line):
    global _reply_data
    _reply_data = line


class MockFile:
    """Mock file object returned by MockSocket.makefile().

            

Reported by Pylint.

Using the global statement
Error

Line: 39 Column: 9

                  """Mock socket object used by smtpd and smtplib tests.
    """
    def __init__(self, family=None):
        global _reply_data
        self.family = family
        self.output = []
        self.lines = []
        if _reply_data:
            self.lines.append(_reply_data)

            

Reported by Pylint.

Unused argument 'flags'
Error

Line: 52 Column: 29

                  def queue_recv(self, line):
        self.lines.append(line)

    def recv(self, bufsize, flags=None):
        data = self.lines.pop(0) + b'\r\n'
        return data

    def fileno(self):
        return 0

            

Reported by Pylint.

Unused argument 'bufsize'
Error

Line: 52 Column: 20

                  def queue_recv(self, line):
        self.lines.append(line)

    def recv(self, bufsize, flags=None):
        data = self.lines.pop(0) + b'\r\n'
        return data

    def fileno(self):
        return 0

            

Reported by Pylint.

Unused argument 'level'
Error

Line: 71 Column: 26

                  def setsockopt(self, level, optname, value):
        pass

    def getsockopt(self, level, optname, buflen=None):
        return 0

    def bind(self, address):
        pass


            

Reported by Pylint.

Unused argument 'buflen'
Error

Line: 71 Column: 42

                  def setsockopt(self, level, optname, value):
        pass

    def getsockopt(self, level, optname, buflen=None):
        return 0

    def bind(self, address):
        pass


            

Reported by Pylint.

Unused argument 'optname'
Error

Line: 71 Column: 33

                  def setsockopt(self, level, optname, value):
        pass

    def getsockopt(self, level, optname, buflen=None):
        return 0

    def bind(self, address):
        pass


            

Reported by Pylint.

Possible binding to all interfaces.
Security

Line: 82
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b104_hardcoded_bind_all_interfaces.html

                      return self.conn, 'c'

    def getsockname(self):
        return ('0.0.0.0', 0)

    def setblocking(self, flag):
        pass

    def listen(self, backlog):

            

Reported by Bandit.

Unused argument 'mode'
Error

Line: 90 Column: 24

                  def listen(self, backlog):
        pass

    def makefile(self, mode='r', bufsize=-1):
        handle = MockFile(self.lines)
        return handle

    def sendall(self, data, flags=None):
        self.last = data

            

Reported by Pylint.

Unused argument 'bufsize'
Error

Line: 90 Column: 34

                  def listen(self, backlog):
        pass

    def makefile(self, mode='r', bufsize=-1):
        handle = MockFile(self.lines)
        return handle

    def sendall(self, data, flags=None):
        self.last = data

            

Reported by Pylint.

Lib/test/test_asynchat.py
65 issues
Unused support imported from test
Error

Line: 3 Column: 1

              # test asynchat

from test import support
from test.support import socket_helper
from test.support import threading_helper

import errno
import socket
import sys

            

Reported by Pylint.

Unused variable 'client'
Error

Line: 42 Column: 15

                  def run(self):
        self.sock.listen()
        self.event.set()
        conn, client = self.sock.accept()
        self.buffer = b""
        # collect data until quit message is seen
        while SERVER_QUIT not in self.buffer:
            data = conn.recv(1)
            if not data:

            

Reported by Pylint.

Attribute 'buffer' defined outside __init__
Error

Line: 43 Column: 9

                      self.sock.listen()
        self.event.set()
        conn, client = self.sock.accept()
        self.buffer = b""
        # collect data until quit message is seen
        while SERVER_QUIT not in self.buffer:
            data = conn.recv(1)
            if not data:
                break

            

Reported by Pylint.

Attribute 'buffer' defined outside __init__
Error

Line: 49 Column: 13

                          data = conn.recv(1)
            if not data:
                break
            self.buffer = self.buffer + data

        # remove the SERVER_QUIT message
        self.buffer = self.buffer.replace(SERVER_QUIT, b'')

        if self.start_resend_event:

            

Reported by Pylint.

Attribute 'buffer' defined outside __init__
Error

Line: 52 Column: 9

                          self.buffer = self.buffer + data

        # remove the SERVER_QUIT message
        self.buffer = self.buffer.replace(SERVER_QUIT, b'')

        if self.start_resend_event:
            self.start_resend_event.wait()

        # re-send entire set of collected data

            

Reported by Pylint.

Attribute 'buffer' defined outside __init__
Error

Line: 64 Column: 17

                          while self.buffer:
                n = conn.send(self.buffer[:self.chunk_size])
                time.sleep(0.001)
                self.buffer = self.buffer[n:]
        except:
            pass

        conn.close()
        self.sock.close()

            

Reported by Pylint.

No exception type(s) specified
Error

Line: 65 Column: 9

                              n = conn.send(self.buffer[:self.chunk_size])
                time.sleep(0.001)
                self.buffer = self.buffer[n:]
        except:
            pass

        conn.close()
        self.sock.close()


            

Reported by Pylint.

Unused variable 'event'
Error

Line: 155 Column: 12

              
    def numeric_terminator_check(self, termlen):
        # Try reading a fixed number of bytes
        s, event = start_echo_server()
        c = echo_client(termlen, s.port)
        data = b"hello world, I'm not dead yet!\n"
        c.push(data)
        c.push(SERVER_QUIT)
        asyncore.loop(use_poll=self.usepoll, count=300, timeout=.01)

            

Reported by Pylint.

Unused variable 'event'
Error

Line: 175 Column: 12

              
    def test_none_terminator(self):
        # Try reading a fixed number of bytes
        s, event = start_echo_server()
        c = echo_client(None, s.port)
        data = b"hello world, I'm not dead yet!\n"
        c.push(data)
        c.push(SERVER_QUIT)
        asyncore.loop(use_poll=self.usepoll, count=300, timeout=.01)

            

Reported by Pylint.

Unused variable 'event'
Error

Line: 187 Column: 12

                      self.assertEqual(c.buffer, data)

    def test_simple_producer(self):
        s, event = start_echo_server()
        c = echo_client(b'\n', s.port)
        data = b"hello world\nI'm not dead yet!\n"
        p = asynchat.simple_producer(data+SERVER_QUIT, buffer_size=8)
        c.push_with_producer(p)
        asyncore.loop(use_poll=self.usepoll, count=300, timeout=.01)

            

Reported by Pylint.

Lib/tkinter/test/test_tkinter/test_variables.py
65 issues
Missing module docstring
Error

Line: 1 Column: 1

              import unittest
import gc
import tkinter
from tkinter import (Variable, StringVar, IntVar, DoubleVar, BooleanVar, Tcl,
                     TclError)
from test.support import ALWAYS_EQ
from tkinter.test.support import AbstractDefaultRootTest



            

Reported by Pylint.

Imports from package tkinter are not grouped
Error

Line: 7 Column: 1

              from tkinter import (Variable, StringVar, IntVar, DoubleVar, BooleanVar, Tcl,
                     TclError)
from test.support import ALWAYS_EQ
from tkinter.test.support import AbstractDefaultRootTest


class Var(Variable):

    _default = "default"

            

Reported by Pylint.

Missing class docstring
Error

Line: 10 Column: 1

              from tkinter.test.support import AbstractDefaultRootTest


class Var(Variable):

    _default = "default"
    side_effect = False

    def set(self, value):

            

Reported by Pylint.

Missing class docstring
Error

Line: 20 Column: 1

                      super().set(value)


class TestBase(unittest.TestCase):

    def setUp(self):
        self.root = Tcl()

    def tearDown(self):

            

Reported by Pylint.

Missing class docstring
Error

Line: 29 Column: 1

                      del self.root


class TestVariable(TestBase):

    def info_exists(self, *args):
        return self.root.getboolean(self.root.call("info", "exists", *args))

    def test_default(self):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 31 Column: 5

              
class TestVariable(TestBase):

    def info_exists(self, *args):
        return self.root.getboolean(self.root.call("info", "exists", *args))

    def test_default(self):
        v = Variable(self.root)
        self.assertEqual("", v.get())

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 34 Column: 5

                  def info_exists(self, *args):
        return self.root.getboolean(self.root.call("info", "exists", *args))

    def test_default(self):
        v = Variable(self.root)
        self.assertEqual("", v.get())
        self.assertRegex(str(v), r"^PY_VAR(\d+)$")

    def test_name_and_value(self):

            

Reported by Pylint.

Variable name "v" doesn't conform to snake_case naming style
Error

Line: 35 Column: 9

                      return self.root.getboolean(self.root.call("info", "exists", *args))

    def test_default(self):
        v = Variable(self.root)
        self.assertEqual("", v.get())
        self.assertRegex(str(v), r"^PY_VAR(\d+)$")

    def test_name_and_value(self):
        v = Variable(self.root, "sample string", "varname")

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 39 Column: 5

                      self.assertEqual("", v.get())
        self.assertRegex(str(v), r"^PY_VAR(\d+)$")

    def test_name_and_value(self):
        v = Variable(self.root, "sample string", "varname")
        self.assertEqual("sample string", v.get())
        self.assertEqual("varname", str(v))

    def test___del__(self):

            

Reported by Pylint.

Variable name "v" doesn't conform to snake_case naming style
Error

Line: 40 Column: 9

                      self.assertRegex(str(v), r"^PY_VAR(\d+)$")

    def test_name_and_value(self):
        v = Variable(self.root, "sample string", "varname")
        self.assertEqual("sample string", v.get())
        self.assertEqual("varname", str(v))

    def test___del__(self):
        self.assertFalse(self.info_exists("varname"))

            

Reported by Pylint.

Lib/colorsys.py
65 issues
XXX assume int() truncates!
Error

Line: 148 Column: 3

              def hsv_to_rgb(h, s, v):
    if s == 0.0:
        return v, v, v
    i = int(h*6.0) # XXX assume int() truncates!
    f = (h*6.0) - i
    p = v*(1.0 - s)
    q = v*(1.0 - s*f)
    t = v*(1.0 - s*(1.0-f))
    i = i%6

            

Reported by Pylint.

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

Line: 40 Column: 1

              # There are a great many versions of the constants used in these formulae.
# The ones in this library uses constants from the FCC version of NTSC.

def rgb_to_yiq(r, g, b):
    y = 0.30*r + 0.59*g + 0.11*b
    i = 0.74*(r-y) - 0.27*(b-y)
    q = 0.48*(r-y) + 0.41*(b-y)
    return (y, i, q)


            

Reported by Pylint.

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

Line: 40 Column: 1

              # There are a great many versions of the constants used in these formulae.
# The ones in this library uses constants from the FCC version of NTSC.

def rgb_to_yiq(r, g, b):
    y = 0.30*r + 0.59*g + 0.11*b
    i = 0.74*(r-y) - 0.27*(b-y)
    q = 0.48*(r-y) + 0.41*(b-y)
    return (y, i, q)


            

Reported by Pylint.

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

Line: 40 Column: 1

              # There are a great many versions of the constants used in these formulae.
# The ones in this library uses constants from the FCC version of NTSC.

def rgb_to_yiq(r, g, b):
    y = 0.30*r + 0.59*g + 0.11*b
    i = 0.74*(r-y) - 0.27*(b-y)
    q = 0.48*(r-y) + 0.41*(b-y)
    return (y, i, q)


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 40 Column: 1

              # There are a great many versions of the constants used in these formulae.
# The ones in this library uses constants from the FCC version of NTSC.

def rgb_to_yiq(r, g, b):
    y = 0.30*r + 0.59*g + 0.11*b
    i = 0.74*(r-y) - 0.27*(b-y)
    q = 0.48*(r-y) + 0.41*(b-y)
    return (y, i, q)


            

Reported by Pylint.

Variable name "y" doesn't conform to snake_case naming style
Error

Line: 41 Column: 5

              # The ones in this library uses constants from the FCC version of NTSC.

def rgb_to_yiq(r, g, b):
    y = 0.30*r + 0.59*g + 0.11*b
    i = 0.74*(r-y) - 0.27*(b-y)
    q = 0.48*(r-y) + 0.41*(b-y)
    return (y, i, q)

def yiq_to_rgb(y, i, q):

            

Reported by Pylint.

Variable name "q" doesn't conform to snake_case naming style
Error

Line: 43 Column: 5

              def rgb_to_yiq(r, g, b):
    y = 0.30*r + 0.59*g + 0.11*b
    i = 0.74*(r-y) - 0.27*(b-y)
    q = 0.48*(r-y) + 0.41*(b-y)
    return (y, i, q)

def yiq_to_rgb(y, i, q):
    # r = y + (0.27*q + 0.41*i) / (0.74*0.41 + 0.27*0.48)
    # b = y + (0.74*q - 0.48*i) / (0.74*0.41 + 0.27*0.48)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 46 Column: 1

                  q = 0.48*(r-y) + 0.41*(b-y)
    return (y, i, q)

def yiq_to_rgb(y, i, q):
    # r = y + (0.27*q + 0.41*i) / (0.74*0.41 + 0.27*0.48)
    # b = y + (0.74*q - 0.48*i) / (0.74*0.41 + 0.27*0.48)
    # g = y - (0.30*(r-y) + 0.11*(b-y)) / 0.59

    r = y + 0.9468822170900693*i + 0.6235565819861433*q

            

Reported by Pylint.

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

Line: 46 Column: 1

                  q = 0.48*(r-y) + 0.41*(b-y)
    return (y, i, q)

def yiq_to_rgb(y, i, q):
    # r = y + (0.27*q + 0.41*i) / (0.74*0.41 + 0.27*0.48)
    # b = y + (0.74*q - 0.48*i) / (0.74*0.41 + 0.27*0.48)
    # g = y - (0.30*(r-y) + 0.11*(b-y)) / 0.59

    r = y + 0.9468822170900693*i + 0.6235565819861433*q

            

Reported by Pylint.

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

Line: 46 Column: 1

                  q = 0.48*(r-y) + 0.41*(b-y)
    return (y, i, q)

def yiq_to_rgb(y, i, q):
    # r = y + (0.27*q + 0.41*i) / (0.74*0.41 + 0.27*0.48)
    # b = y + (0.74*q - 0.48*i) / (0.74*0.41 + 0.27*0.48)
    # g = y - (0.30*(r-y) + 0.11*(b-y)) / 0.59

    r = y + 0.9468822170900693*i + 0.6235565819861433*q

            

Reported by Pylint.