The following issues were found

Lib/_weakrefset.py
28 issues
Missing module docstring
Error

Line: 1 Column: 1

              # Access WeakSet through the weakref module.
# This code is separated-out because it is needed
# by abc.py to load everything else at startup.

from _weakref import ref
from types import GenericAlias

__all__ = ['WeakSet']


            

Reported by Pylint.

standard import "from types import GenericAlias" should be placed before "from _weakref import ref"
Error

Line: 6 Column: 1

              # by abc.py to load everything else at startup.

from _weakref import ref
from types import GenericAlias

__all__ = ['WeakSet']


class _IterationGuard:

            

Reported by Pylint.

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

Line: 22 Column: 9

                      self.weakcontainer = ref(weakcontainer)

    def __enter__(self):
        w = self.weakcontainer()
        if w is not None:
            w._iterating.add(self)
        return self

    def __exit__(self, e, t, b):

            

Reported by Pylint.

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

Line: 27 Column: 5

                          w._iterating.add(self)
        return self

    def __exit__(self, e, t, b):
        w = self.weakcontainer()
        if w is not None:
            s = w._iterating
            s.remove(self)
            if not s:

            

Reported by Pylint.

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

Line: 27 Column: 5

                          w._iterating.add(self)
        return self

    def __exit__(self, e, t, b):
        w = self.weakcontainer()
        if w is not None:
            s = w._iterating
            s.remove(self)
            if not s:

            

Reported by Pylint.

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

Line: 27 Column: 5

                          w._iterating.add(self)
        return self

    def __exit__(self, e, t, b):
        w = self.weakcontainer()
        if w is not None:
            s = w._iterating
            s.remove(self)
            if not s:

            

Reported by Pylint.

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

Line: 28 Column: 9

                      return self

    def __exit__(self, e, t, b):
        w = self.weakcontainer()
        if w is not None:
            s = w._iterating
            s.remove(self)
            if not s:
                w._commit_removals()

            

Reported by Pylint.

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

Line: 30 Column: 13

                  def __exit__(self, e, t, b):
        w = self.weakcontainer()
        if w is not None:
            s = w._iterating
            s.remove(self)
            if not s:
                w._commit_removals()



            

Reported by Pylint.

Missing class docstring
Error

Line: 36 Column: 1

                              w._commit_removals()


class WeakSet:
    def __init__(self, data=None):
        self.data = set()
        def _remove(item, selfref=ref(self)):
            self = selfref()
            if self is not None:

            

Reported by Pylint.

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

Line: 54 Column: 9

                          self.update(data)

    def _commit_removals(self):
        l = self._pending_removals
        discard = self.data.discard
        while l:
            discard(l.pop())

    def __iter__(self):

            

Reported by Pylint.

Lib/idlelib/autocomplete.py
28 issues
TODO Update this here and elsewhere.
Error

Line: 26 Column: 3

              TRY_F = False,    False,    False,   FILES  # '/' in quotes for file name.

# This string includes all chars that may be in an identifier.
# TODO Update this here and elsewhere.
ID_CHARS = string.ascii_letters + string.digits + "_"

SEPS = f"{os.sep}{os.altsep if os.altsep else ''}"
TRIGGERS = f".{SEPS}"


            

Reported by Pylint.

Unused argument 'event'
Error

Line: 54 Column: 43

                  def _make_autocomplete_window(self):  # Makes mocking easier.
        return autocomplete_w.AutoCompleteWindow(self.text, tags=self.tags)

    def _remove_autocomplete_window(self, event=None):
        if self.autocompletewindow:
            self.autocompletewindow.hide_window()
            self.autocompletewindow = None

    def force_open_completions_event(self, event):

            

Reported by Pylint.

Unused argument 'event'
Error

Line: 59 Column: 44

                          self.autocompletewindow.hide_window()
            self.autocompletewindow = None

    def force_open_completions_event(self, event):
        "(^space) Open completion list, even if a function call is needed."
        self.open_completions(FORCE)
        return "break"

    def autocomplete_event(self, event):

            

Reported by Pylint.

Unused argument 'event'
Error

Line: 78 Column: 42

                          opened = self.open_completions(TAB)
            return "break" if opened else None

    def try_open_completions_event(self, event=None):
        "(./) Open completion list after pause with no movement."
        lastchar = self.text.get("insert-1c")
        if lastchar in TRIGGERS:
            args = TRY_A if lastchar == "." else TRY_F
            self._delayed_completion_index = self.text.index("insert")

            

Reported by Pylint.

XXX could consider raw strings here and unescape the string
Error

Line: 115 Column: 3

                          # Find the beginning of the string.
            # fetch_completions will look at the file system to determine
            # whether the string value constitutes an actual file name
            # XXX could consider raw strings here and unescape the string
            # value if it's not raw.
            self._remove_autocomplete_window()
            mode = FILES
            # Find last separator or string start
            while i and curline[i-1] not in "'\"" + SEPS:

            

Reported by Pylint.

No exception type(s) specified
Error

Line: 169 Column: 9

                      """
        try:
            rpcclt = self.editwin.flist.pyshell.interp.rpcclt
        except:
            rpcclt = None
        if rpcclt:
            return rpcclt.remotecall("exec", "get_the_completion_list",
                                     (what, mode), {})
        else:

            

Reported by Pylint.

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

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

                              if what == "":  # Main module names.
                    namespace = {**__main__.__builtins__.__dict__,
                                 **__main__.__dict__}
                    bigl = eval("dir()", namespace)
                    kwds = (s for s in keyword.kwlist
                            if s not in {'True', 'False', 'None'})
                    bigl.extend(kwds)
                    bigl.sort()
                    if "__all__" in bigl:

            

Reported by Bandit.

Use of eval
Error

Line: 179 Column: 28

                              if what == "":  # Main module names.
                    namespace = {**__main__.__builtins__.__dict__,
                                 **__main__.__dict__}
                    bigl = eval("dir()", namespace)
                    kwds = (s for s in keyword.kwlist
                            if s not in {'True', 'False', 'None'})
                    bigl.extend(kwds)
                    bigl.sort()
                    if "__all__" in bigl:

            

Reported by Pylint.

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

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

                                  bigl.extend(kwds)
                    bigl.sort()
                    if "__all__" in bigl:
                        smalll = sorted(eval("__all__", namespace))
                    else:
                        smalll = [s for s in bigl if s[:1] != '_']
                else:
                    try:
                        entity = self.get_entity(what)

            

Reported by Bandit.

Use of eval
Error

Line: 185 Column: 41

                                  bigl.extend(kwds)
                    bigl.sort()
                    if "__all__" in bigl:
                        smalll = sorted(eval("__all__", namespace))
                    else:
                        smalll = [s for s in bigl if s[:1] != '_']
                else:
                    try:
                        entity = self.get_entity(what)

            

Reported by Pylint.

Lib/asyncio/base_tasks.py
28 issues
Cannot import 'traceback' due to syntax error 'invalid syntax (<unknown>, line 576)'
Error

Line: 2 Column: 1

              import linecache
import traceback

from . import base_futures
from . import coroutines


def _task_repr_info(task):
    info = base_futures._future_repr_info(task)

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 4 Column: 1

              import linecache
import traceback

from . import base_futures
from . import coroutines


def _task_repr_info(task):
    info = base_futures._future_repr_info(task)

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 5 Column: 1

              import traceback

from . import base_futures
from . import coroutines


def _task_repr_info(task):
    info = base_futures._future_repr_info(task)


            

Reported by Pylint.

Access to a protected member _future_repr_info of a client class
Error

Line: 9 Column: 12

              

def _task_repr_info(task):
    info = base_futures._future_repr_info(task)

    if task._must_cancel:
        # replace status
        info[0] = 'cancelling'


            

Reported by Pylint.

Access to a protected member _must_cancel of a client class
Error

Line: 11 Column: 8

              def _task_repr_info(task):
    info = base_futures._future_repr_info(task)

    if task._must_cancel:
        # replace status
        info[0] = 'cancelling'

    info.insert(1, 'name=%r' % task.get_name())


            

Reported by Pylint.

Access to a protected member _format_coroutine of a client class
Error

Line: 17 Column: 12

              
    info.insert(1, 'name=%r' % task.get_name())

    coro = coroutines._format_coroutine(task._coro)
    info.insert(2, f'coro=<{coro}>')

    if task._fut_waiter is not None:
        info.insert(3, f'wait_for={task._fut_waiter!r}')
    return info

            

Reported by Pylint.

Access to a protected member _coro of a client class
Error

Line: 17 Column: 41

              
    info.insert(1, 'name=%r' % task.get_name())

    coro = coroutines._format_coroutine(task._coro)
    info.insert(2, f'coro=<{coro}>')

    if task._fut_waiter is not None:
        info.insert(3, f'wait_for={task._fut_waiter!r}')
    return info

            

Reported by Pylint.

Access to a protected member _fut_waiter of a client class
Error

Line: 20 Column: 8

                  coro = coroutines._format_coroutine(task._coro)
    info.insert(2, f'coro=<{coro}>')

    if task._fut_waiter is not None:
        info.insert(3, f'wait_for={task._fut_waiter!r}')
    return info


def _task_get_stack(task, limit):

            

Reported by Pylint.

Access to a protected member _fut_waiter of a client class
Error

Line: 21 Column: 25

                  info.insert(2, f'coro=<{coro}>')

    if task._fut_waiter is not None:
        info.insert(3, f'wait_for={task._fut_waiter!r}')
    return info


def _task_get_stack(task, limit):
    frames = []

            

Reported by Pylint.

Access to a protected member _coro of a client class
Error

Line: 27 Column: 16

              
def _task_get_stack(task, limit):
    frames = []
    if hasattr(task._coro, 'cr_frame'):
        # case 1: 'async def' coroutines
        f = task._coro.cr_frame
    elif hasattr(task._coro, 'gi_frame'):
        # case 2: legacy coroutines
        f = task._coro.gi_frame

            

Reported by Pylint.

Lib/idlelib/replace.py
28 issues
Access to a protected member _root of a client class
Error

Line: 23 Column: 12

                  Args:
        text: Text widget containing the text to be searched.
    """
    root = text._root()
    engine = searchengine.get(root)
    if not hasattr(engine, "_replacedialog"):
        engine._replacedialog = ReplaceDialog(root, engine)
    dialog = engine._replacedialog
    dialog.open(text, insert_tags=insert_tags)

            

Reported by Pylint.

Access to a protected member _replacedialog of a client class
Error

Line: 26 Column: 9

                  root = text._root()
    engine = searchengine.get(root)
    if not hasattr(engine, "_replacedialog"):
        engine._replacedialog = ReplaceDialog(root, engine)
    dialog = engine._replacedialog
    dialog.open(text, insert_tags=insert_tags)


class ReplaceDialog(SearchDialogBase):

            

Reported by Pylint.

Access to a protected member _replacedialog of a client class
Error

Line: 27 Column: 14

                  engine = searchengine.get(root)
    if not hasattr(engine, "_replacedialog"):
        engine._replacedialog = ReplaceDialog(root, engine)
    dialog = engine._replacedialog
    dialog.open(text, insert_tags=insert_tags)


class ReplaceDialog(SearchDialogBase):
    "Dialog for finding and replacing a pattern in text."

            

Reported by Pylint.

Parameters differ from overridden 'open' method
Error

Line: 54 Column: 5

                      self.replvar = StringVar(root)
        self.insert_tags = None

    def open(self, text, insert_tags=None):
        """Make dialog visible on top of others and ready to use.

        Also, highlight the currently selected text and set the
        search to include the current selection (self.ok).


            

Reported by Pylint.

Attribute 'ok' defined outside __init__
Error

Line: 75 Column: 9

                      first = first or text.index("insert")
        last = last or first
        self.show_hit(first, last)
        self.ok = True
        self.insert_tags = insert_tags

    def create_entries(self):
        "Create base and additional label and text entry widgets."
        SearchDialogBase.create_entries(self)

            

Reported by Pylint.

Attribute 'replent' defined outside __init__
Error

Line: 81 Column: 9

                  def create_entries(self):
        "Create base and additional label and text entry widgets."
        SearchDialogBase.create_entries(self)
        self.replent = self.make_entry("Replace with:", self.replvar)[0]

    def create_command_buttons(self):
        """Create base and additional command buttons.

        The additional buttons are for Find, Replace,

            

Reported by Pylint.

Unused argument 'event'
Error

Line: 95 Column: 23

                      self.make_button("Replace+Find", self.default_command, isdef=True)
        self.make_button("Replace All", self.replace_all)

    def find_it(self, event=None):
        "Handle the Find button."
        self.do_find(False)

    def replace_it(self, event=None):
        """Handle the Replace button.

            

Reported by Pylint.

Unused argument 'event'
Error

Line: 99 Column: 26

                      "Handle the Find button."
        self.do_find(False)

    def replace_it(self, event=None):
        """Handle the Replace button.

        If the find is successful, then perform replace.
        """
        if self.do_find(self.ok):

            

Reported by Pylint.

Unused argument 'event'
Error

Line: 107 Column: 31

                      if self.do_find(self.ok):
            self.do_replace()

    def default_command(self, event=None):
        """Handle the Replace+Find button as the default command.

        First performs a replace and then, if the replace was
        successful, a find next.
        """

            

Reported by Pylint.

Unused argument 'event'
Error

Line: 131 Column: 27

              
        return new

    def replace_all(self, event=None):
        """Handle the Replace All button.

        Search text for occurrences of the Find value and replace
        each of them.  The 'wrap around' value controls the start
        point for searching.  If wrap isn't set, then the searching

            

Reported by Pylint.

Lib/test/test_dtrace.py
28 issues
Value 'self.COMMAND' is unsubscriptable
Error

Line: 86 Column: 43

                          output = str(fnfe)
        if output != "probe: success":
            raise unittest.SkipTest(
                "{}(1) failed: {}".format(self.COMMAND[0], output)
            )


class DTraceBackend(TraceBackend):
    EXTENSION = ".d"

            

Reported by Pylint.

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

Line: 36 Column: 9

                      result = [row[1] for row in result]
        return "\n".join(result)
    except (IndexError, ValueError):
        raise AssertionError(
            "tracer produced unparseable output:\n{}".format(output)
        )


class TraceBackend:

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import dis
import os.path
import re
import subprocess
import sys
import types
import unittest

from test.support import findfile, run_unittest

            

Reported by Pylint.

Consider possible security implications associated with subprocess module.
Security blacklist

Line: 4
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_imports.html#b404-import-subprocess

              import dis
import os.path
import re
import subprocess
import sys
import types
import unittest

from test.support import findfile, run_unittest

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 12 Column: 1

              from test.support import findfile, run_unittest


def abspath(filename):
    return os.path.abspath(findfile(filename, subdir="dtracedata"))


def normalize_trace_output(output):
    """Normalize DTrace output for comparison.

            

Reported by Pylint.

Missing class docstring
Error

Line: 41 Column: 1

                      )


class TraceBackend:
    EXTENSION = None
    COMMAND = None
    COMMAND_ARGS = []

    def run_case(self, name, optimize_python=None):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 46 Column: 5

                  COMMAND = None
    COMMAND_ARGS = []

    def run_case(self, name, optimize_python=None):
        actual_output = normalize_trace_output(self.trace_python(
            script_file=abspath(name + self.EXTENSION),
            python_file=abspath(name + ".py"),
            optimize_python=optimize_python))


            

Reported by Pylint.

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

Line: 52 Column: 68

                          python_file=abspath(name + ".py"),
            optimize_python=optimize_python))

        with open(abspath(name + self.EXTENSION + ".expected")) as f:
            expected_output = f.read().rstrip()

        return (expected_output, actual_output)

    def generate_trace_command(self, script_file, subcommand=None):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 57 Column: 5

              
        return (expected_output, actual_output)

    def generate_trace_command(self, script_file, subcommand=None):
        command = self.COMMAND + [script_file]
        if subcommand:
            command += ["-c", subcommand]
        return command


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 63 Column: 5

                          command += ["-c", subcommand]
        return command

    def trace(self, script_file, subcommand=None):
        command = self.generate_trace_command(script_file, subcommand)
        stdout, _ = subprocess.Popen(command,
                                     stdout=subprocess.PIPE,
                                     stderr=subprocess.STDOUT,
                                     universal_newlines=True).communicate()

            

Reported by Pylint.

Lib/test/test_asyncio/test_windows_utils.py
28 issues
Unable to import '_overlapped'
Error

Line: 10 Column: 1

              if sys.platform != 'win32':
    raise unittest.SkipTest('Windows only')

import _overlapped
import _winapi

import asyncio
from asyncio import windows_utils
from test import support

            

Reported by Pylint.

Unable to import '_winapi'
Error

Line: 11 Column: 1

                  raise unittest.SkipTest('Windows only')

import _overlapped
import _winapi

import asyncio
from asyncio import windows_utils
from test import support


            

Reported by Pylint.

Instance of 'OSError' has no 'winerror' member
Error

Line: 38 Column: 34

                          try:
                ov1.getresult()
            except OSError as e:
                self.assertEqual(e.winerror, ERROR_IO_INCOMPLETE)
            else:
                raise RuntimeError('expected ERROR_IO_INCOMPLETE')

            ov2 = _overlapped.Overlapped()
            self.assertFalse(ov2.pending)

            

Reported by Pylint.

Instance of 'OSError' has no 'winerror' member
Error

Line: 76 Column: 30

                      try:
            _winapi.CloseHandle(h)
        except OSError as e:
            self.assertEqual(e.winerror, 6)     # ERROR_INVALID_HANDLE
        else:
            raise RuntimeError('expected ERROR_INVALID_HANDLE')


class PopenTests(unittest.TestCase):

            

Reported by Pylint.

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

Line: 10 Column: 1

              if sys.platform != 'win32':
    raise unittest.SkipTest('Windows only')

import _overlapped
import _winapi

import asyncio
from asyncio import windows_utils
from test import support

            

Reported by Pylint.

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

Line: 11 Column: 1

                  raise unittest.SkipTest('Windows only')

import _overlapped
import _winapi

import asyncio
from asyncio import windows_utils
from test import support


            

Reported by Pylint.

standard import "import asyncio" should be placed before "import _overlapped"
Error

Line: 13 Column: 1

              import _overlapped
import _winapi

import asyncio
from asyncio import windows_utils
from test import support


def tearDownModule():

            

Reported by Pylint.

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

Line: 13 Column: 1

              import _overlapped
import _winapi

import asyncio
from asyncio import windows_utils
from test import support


def tearDownModule():

            

Reported by Pylint.

standard import "from asyncio import windows_utils" should be placed before "import _overlapped"
Error

Line: 14 Column: 1

              import _winapi

import asyncio
from asyncio import windows_utils
from test import support


def tearDownModule():
    asyncio.set_event_loop_policy(None)

            

Reported by Pylint.

Import "from asyncio import windows_utils" should be placed at the top of the module
Error

Line: 14 Column: 1

              import _winapi

import asyncio
from asyncio import windows_utils
from test import support


def tearDownModule():
    asyncio.set_event_loop_policy(None)

            

Reported by Pylint.

Lib/test/test_filecmp.py
28 issues
Unused variable 'first_compare'
Error

Line: 47 Column: 9

                                  "File and directory compare as equal")

    def test_cache_clear(self):
        first_compare = filecmp.cmp(self.name, self.name_same, shallow=False)
        second_compare = filecmp.cmp(self.name, self.name_diff, shallow=False)
        filecmp.clear_cache()
        self.assertTrue(len(filecmp._cache) == 0,
                        "Cache not cleared after calling clear_cache")


            

Reported by Pylint.

Unused variable 'second_compare'
Error

Line: 48 Column: 9

              
    def test_cache_clear(self):
        first_compare = filecmp.cmp(self.name, self.name_same, shallow=False)
        second_compare = filecmp.cmp(self.name, self.name_diff, shallow=False)
        filecmp.clear_cache()
        self.assertTrue(len(filecmp._cache) == 0,
                        "Cache not cleared after calling clear_cache")

class DirCompareTestCase(unittest.TestCase):

            

Reported by Pylint.

Access to a protected member _cache of a client class
Error

Line: 50 Column: 29

                      first_compare = filecmp.cmp(self.name, self.name_same, shallow=False)
        second_compare = filecmp.cmp(self.name, self.name_diff, shallow=False)
        filecmp.clear_cache()
        self.assertTrue(len(filecmp._cache) == 0,
                        "Cache not cleared after calling clear_cache")

class DirCompareTestCase(unittest.TestCase):
    def setUp(self):
        tmpdir = tempfile.gettempdir()

            

Reported by Pylint.

Redefining built-in 'dir'
Error

Line: 66 Column: 13

              
        self.caseinsensitive = os.path.normcase('A') == os.path.normcase('a')
        data = 'Contents of file go here.\n'
        for dir in (self.dir, self.dir_same, self.dir_diff, self.dir_ignored):
            shutil.rmtree(dir, True)
            os.mkdir(dir)
            subdir_path = os.path.join(dir, 'subdir')
            os.mkdir(subdir_path)
            if self.caseinsensitive and dir is self.dir_same:

            

Reported by Pylint.

Redefining built-in 'dir'
Error

Line: 82 Column: 13

                          output.write('An extra file.\n')

    def tearDown(self):
        for dir in (self.dir, self.dir_same, self.dir_diff):
            shutil.rmtree(dir)

    def test_default_ignores(self):
        self.assertIn('.hg', filecmp.DEFAULT_IGNORES)


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import filecmp
import os
import shutil
import tempfile
import unittest

from test import support
from test.support import os_helper


            

Reported by Pylint.

Missing class docstring
Error

Line: 11 Column: 1

              from test.support import os_helper


class FileCompareTestCase(unittest.TestCase):
    def setUp(self):
        self.name = os_helper.TESTFN
        self.name_same = os_helper.TESTFN + '-same'
        self.name_diff = os_helper.TESTFN + '-diff'
        data = 'Contents of file go here.\n'

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 30 Column: 5

                      os.unlink(self.name_same)
        os.unlink(self.name_diff)

    def test_matching(self):
        self.assertTrue(filecmp.cmp(self.name, self.name),
                        "Comparing file to itself fails")
        self.assertTrue(filecmp.cmp(self.name, self.name, shallow=False),
                        "Comparing file to itself fails")
        self.assertTrue(filecmp.cmp(self.name, self.name_same),

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 40 Column: 5

                      self.assertTrue(filecmp.cmp(self.name, self.name_same, shallow=False),
                        "Comparing file to identical file fails")

    def test_different(self):
        self.assertFalse(filecmp.cmp(self.name, self.name_diff),
                    "Mismatched files compare as equal")
        self.assertFalse(filecmp.cmp(self.name, self.dir),
                    "File and directory compare as equal")


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 46 Column: 5

                      self.assertFalse(filecmp.cmp(self.name, self.dir),
                    "File and directory compare as equal")

    def test_cache_clear(self):
        first_compare = filecmp.cmp(self.name, self.name_same, shallow=False)
        second_compare = filecmp.cmp(self.name, self.name_diff, shallow=False)
        filecmp.clear_cache()
        self.assertTrue(len(filecmp._cache) == 0,
                        "Cache not cleared after calling clear_cache")

            

Reported by Pylint.

Lib/test/ssl_servers.py
28 issues
Redefining name 'context' from outer scope (line 197)
Error

Line: 23 Column: 55

              
class HTTPSServer(_HTTPServer):

    def __init__(self, server_address, handler_class, context):
        _HTTPServer.__init__(self, server_address, handler_class)
        self.context = context

    def __str__(self):
        return ('<%s %s:%s>' %

            

Reported by Pylint.

Redefining name 'handler_class' from outer scope (line 193)
Error

Line: 23 Column: 40

              
class HTTPSServer(_HTTPServer):

    def __init__(self, server_address, handler_class, context):
        _HTTPServer.__init__(self, server_address, handler_class)
        self.context = context

    def __str__(self):
        return ('<%s %s:%s>' %

            

Reported by Pylint.

Unused variable 'drive'
Error

Line: 70 Column: 13

                      words = filter(None, words)
        path = self.root
        for word in words:
            drive, word = os.path.splitdrive(word)
            head, word = os.path.split(word)
            path = os.path.join(path, word)
        return path

    def log_message(self, format, *args):

            

Reported by Pylint.

Unused variable 'head'
Error

Line: 71 Column: 13

                      path = self.root
        for word in words:
            drive, word = os.path.splitdrive(word)
            head, word = os.path.split(word)
            path = os.path.join(path, word)
        return path

    def log_message(self, format, *args):
        # we override this to suppress logging unless "verbose"

            

Reported by Pylint.

Redefining built-in 'format'
Error

Line: 75 Column: 27

                          path = os.path.join(path, word)
        return path

    def log_message(self, format, *args):
        # we override this to suppress logging unless "verbose"
        if support.verbose:
            sys.stdout.write(" server (%s:%d %s):\n   [%s] %s\n" %
                             (self.server.server_address,
                              self.server.server_port,

            

Reported by Pylint.

Redefining name 'args' from outer scope (line 189)
Error

Line: 75 Column: 1

                          path = os.path.join(path, word)
        return path

    def log_message(self, format, *args):
        # we override this to suppress logging unless "verbose"
        if support.verbose:
            sys.stdout.write(" server (%s:%d %s):\n   [%s] %s\n" %
                             (self.server.server_address,
                              self.server.server_port,

            

Reported by Pylint.

Access to a protected member _sock of a client class
Error

Line: 95 Column: 16

              
    def do_GET(self, send_body=True):
        """Serve a GET request."""
        sock = self.rfile.raw._sock
        context = sock.context
        stats = {
            'session_cache': context.session_stats(),
            'cipher': sock.cipher(),
            'compression': sock.compression(),

            

Reported by Pylint.

Redefining name 'context' from outer scope (line 197)
Error

Line: 96 Column: 9

                  def do_GET(self, send_body=True):
        """Serve a GET request."""
        sock = self.rfile.raw._sock
        context = sock.context
        stats = {
            'session_cache': context.session_stats(),
            'cipher': sock.cipher(),
            'compression': sock.compression(),
            }

            

Reported by Pylint.

Redefining name 'args' from outer scope (line 189)
Error

Line: 115 Column: 1

                      """Serve a HEAD request."""
        self.do_GET(send_body=False)

    def log_request(self, format, *args):
        if support.verbose:
            BaseHTTPRequestHandler.log_request(self, format, *args)


class HTTPSServerThread(threading.Thread):

            

Reported by Pylint.

Redefining built-in 'format'
Error

Line: 115 Column: 27

                      """Serve a HEAD request."""
        self.do_GET(send_body=False)

    def log_request(self, format, *args):
        if support.verbose:
            BaseHTTPRequestHandler.log_request(self, format, *args)


class HTTPSServerThread(threading.Thread):

            

Reported by Pylint.

Tools/scripts/dutree.py
28 issues
Starting a process with a shell, possible injection detected, security issue.
Security injection

Line: 8
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b605_start_process_with_a_shell.html

              
def main():
    total, d = None, {}
    with os.popen('du ' + ' '.join(sys.argv[1:])) as p:
        for line in p:
            i = 0
            while line[i] in '0123456789': i = i+1
            size = eval(line[:i])
            while line[i] in ' \t': i = i+1

            

Reported by Bandit.

Use of eval
Error

Line: 12 Column: 20

                      for line in p:
            i = 0
            while line[i] in '0123456789': i = i+1
            size = eval(line[:i])
            while line[i] in ' \t': i = i+1
            filename = line[i:-1]
            comps = filename.split('/')
            if comps[0] == '': comps[0] = '/'
            if comps[len(comps)-1] == '': del comps[len(comps)-1]

            

Reported by Pylint.

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

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

                      for line in p:
            i = 0
            while line[i] in '0123456789': i = i+1
            size = eval(line[:i])
            while line[i] in ' \t': i = i+1
            filename = line[i:-1]
            comps = filename.split('/')
            if comps[0] == '': comps[0] = '/'
            if comps[len(comps)-1] == '': del comps[len(comps)-1]

            

Reported by Bandit.

Unused argument 'total'
Error

Line: 37 Column: 10

              def display(total, d):
    show(total, d, '')

def show(total, d, prefix):
    if not d: return
    list = []
    sum = 0
    for key in d.keys():
        tsub, dsub = d[key]

            

Reported by Pylint.

Redefining built-in 'list'
Error

Line: 39 Column: 5

              
def show(total, d, prefix):
    if not d: return
    list = []
    sum = 0
    for key in d.keys():
        tsub, dsub = d[key]
        list.append((tsub, key))
        if tsub is not None: sum = sum + tsub

            

Reported by Pylint.

Redefining built-in 'sum'
Error

Line: 40 Column: 5

              def show(total, d, prefix):
    if not d: return
    list = []
    sum = 0
    for key in d.keys():
        tsub, dsub = d[key]
        list.append((tsub, key))
        if tsub is not None: sum = sum + tsub
##  if sum < total:

            

Reported by Pylint.

Unused variable 'dsub'
Error

Line: 42 Column: 15

                  list = []
    sum = 0
    for key in d.keys():
        tsub, dsub = d[key]
        list.append((tsub, key))
        if tsub is not None: sum = sum + tsub
##  if sum < total:
##      list.append((total - sum, os.curdir))
    list.sort()

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              #! /usr/bin/env python3
# Format du output in a tree shape

import os, sys, errno

def main():
    total, d = None, {}
    with os.popen('du ' + ' '.join(sys.argv[1:])) as p:
        for line in p:

            

Reported by Pylint.

Multiple imports on one line (os, sys, errno)
Error

Line: 4 Column: 1

              #! /usr/bin/env python3
# Format du output in a tree shape

import os, sys, errno

def main():
    total, d = None, {}
    with os.popen('du ' + ' '.join(sys.argv[1:])) as p:
        for line in p:

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 6 Column: 1

              
import os, sys, errno

def main():
    total, d = None, {}
    with os.popen('du ' + ' '.join(sys.argv[1:])) as p:
        for line in p:
            i = 0
            while line[i] in '0123456789': i = i+1

            

Reported by Pylint.

PC/layout/support/logging.py
28 issues
Module 'logging' has no 'getLogger' member
Error

Line: 28 Column: 11

                  if LOG:
        return

    LOG = logging.getLogger("make_layout")
    LOG.level = logging.DEBUG

    if ns.v:
        s_level = max(logging.ERROR - ns.v * 10, logging.DEBUG)
        f_level = max(logging.WARNING - ns.v * 10, logging.DEBUG)

            

Reported by Pylint.

Module 'logging' has no 'DEBUG' member
Error

Line: 29 Column: 17

                      return

    LOG = logging.getLogger("make_layout")
    LOG.level = logging.DEBUG

    if ns.v:
        s_level = max(logging.ERROR - ns.v * 10, logging.DEBUG)
        f_level = max(logging.WARNING - ns.v * 10, logging.DEBUG)
    else:

            

Reported by Pylint.

Module 'logging' has no 'ERROR' member
Error

Line: 32 Column: 23

                  LOG.level = logging.DEBUG

    if ns.v:
        s_level = max(logging.ERROR - ns.v * 10, logging.DEBUG)
        f_level = max(logging.WARNING - ns.v * 10, logging.DEBUG)
    else:
        s_level = logging.ERROR
        f_level = logging.INFO


            

Reported by Pylint.

Module 'logging' has no 'DEBUG' member
Error

Line: 32 Column: 50

                  LOG.level = logging.DEBUG

    if ns.v:
        s_level = max(logging.ERROR - ns.v * 10, logging.DEBUG)
        f_level = max(logging.WARNING - ns.v * 10, logging.DEBUG)
    else:
        s_level = logging.ERROR
        f_level = logging.INFO


            

Reported by Pylint.

Module 'logging' has no 'WARNING' member
Error

Line: 33 Column: 23

              
    if ns.v:
        s_level = max(logging.ERROR - ns.v * 10, logging.DEBUG)
        f_level = max(logging.WARNING - ns.v * 10, logging.DEBUG)
    else:
        s_level = logging.ERROR
        f_level = logging.INFO

    handler = logging.StreamHandler(sys.stdout)

            

Reported by Pylint.

Module 'logging' has no 'DEBUG' member
Error

Line: 33 Column: 52

              
    if ns.v:
        s_level = max(logging.ERROR - ns.v * 10, logging.DEBUG)
        f_level = max(logging.WARNING - ns.v * 10, logging.DEBUG)
    else:
        s_level = logging.ERROR
        f_level = logging.INFO

    handler = logging.StreamHandler(sys.stdout)

            

Reported by Pylint.

Module 'logging' has no 'ERROR' member
Error

Line: 35 Column: 19

                      s_level = max(logging.ERROR - ns.v * 10, logging.DEBUG)
        f_level = max(logging.WARNING - ns.v * 10, logging.DEBUG)
    else:
        s_level = logging.ERROR
        f_level = logging.INFO

    handler = logging.StreamHandler(sys.stdout)
    handler.setFormatter(logging.Formatter("{levelname:8s} {message}", style="{"))
    handler.setLevel(s_level)

            

Reported by Pylint.

Module 'logging' has no 'INFO' member
Error

Line: 36 Column: 19

                      f_level = max(logging.WARNING - ns.v * 10, logging.DEBUG)
    else:
        s_level = logging.ERROR
        f_level = logging.INFO

    handler = logging.StreamHandler(sys.stdout)
    handler.setFormatter(logging.Formatter("{levelname:8s} {message}", style="{"))
    handler.setLevel(s_level)
    LOG.addHandler(handler)

            

Reported by Pylint.

Module 'logging' has no 'StreamHandler' member
Error

Line: 38 Column: 15

                      s_level = logging.ERROR
        f_level = logging.INFO

    handler = logging.StreamHandler(sys.stdout)
    handler.setFormatter(logging.Formatter("{levelname:8s} {message}", style="{"))
    handler.setLevel(s_level)
    LOG.addHandler(handler)

    if ns.log:

            

Reported by Pylint.

Module 'logging' has no 'Formatter' member
Error

Line: 39 Column: 26

                      f_level = logging.INFO

    handler = logging.StreamHandler(sys.stdout)
    handler.setFormatter(logging.Formatter("{levelname:8s} {message}", style="{"))
    handler.setLevel(s_level)
    LOG.addHandler(handler)

    if ns.log:
        handler = logging.FileHandler(ns.log, encoding="utf-8", delay=True)

            

Reported by Pylint.