The following issues were found

Lib/distutils/command/install_egg_info.py
6 issues
Attribute 'target' defined outside __init__
Error

Line: 29 Column: 9

                          to_filename(safe_version(self.distribution.get_version())),
            *sys.version_info[:2]
        )
        self.target = os.path.join(self.install_dir, basename)
        self.outputs = [self.target]

    def run(self):
        target = self.target
        if os.path.isdir(target) and not os.path.islink(target):

            

Reported by Pylint.

Attribute 'outputs' defined outside __init__
Error

Line: 30 Column: 9

                          *sys.version_info[:2]
        )
        self.target = os.path.join(self.install_dir, basename)
        self.outputs = [self.target]

    def run(self):
        target = self.target
        if os.path.isdir(target) and not os.path.islink(target):
            dir_util.remove_tree(target, dry_run=self.dry_run)

            

Reported by Pylint.

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

Line: 9 Column: 1

              
from distutils.cmd import Command
from distutils import log, dir_util
import os, sys, re

class install_egg_info(Command):
    """Install an .egg-info file for the package"""

    description = "Install package's PKG-INFO metadata as an .egg-info file"

            

Reported by Pylint.

Class name "install_egg_info" doesn't conform to PascalCase naming style
Error

Line: 11 Column: 1

              from distutils import log, dir_util
import os, sys, re

class install_egg_info(Command):
    """Install an .egg-info file for the package"""

    description = "Install package's PKG-INFO metadata as an .egg-info file"
    user_options = [
        ('install-dir=', 'd', "directory to install to"),

            

Reported by Pylint.

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

Line: 43 Column: 57

                                       "Creating "+self.install_dir)
        log.info("Writing %s", target)
        if not self.dry_run:
            with open(target, 'w', encoding='UTF-8') as f:
                self.distribution.metadata.write_pkg_file(f)

    def get_outputs(self):
        return self.outputs


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 46 Column: 5

                          with open(target, 'w', encoding='UTF-8') as f:
                self.distribution.metadata.write_pkg_file(f)

    def get_outputs(self):
        return self.outputs


# The following routines are taken from setuptools' pkg_resources module and
# can be replaced by importing them from pkg_resources once it is included

            

Reported by Pylint.

Lib/idlelib/idle_test/test_scrolledlist.py
6 issues
standard import "import unittest" should be placed before "from idlelib.scrolledlist import ScrolledList"
Error

Line: 4 Column: 1

              "Test scrolledlist, coverage 38%."

from idlelib.scrolledlist import ScrolledList
import unittest
from test.support import requires
requires('gui')
from tkinter import Tk



            

Reported by Pylint.

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

Line: 5 Column: 1

              
from idlelib.scrolledlist import ScrolledList
import unittest
from test.support import requires
requires('gui')
from tkinter import Tk


class ScrolledListTest(unittest.TestCase):

            

Reported by Pylint.

standard import "from tkinter import Tk" should be placed before "from idlelib.scrolledlist import ScrolledList"
Error

Line: 7 Column: 1

              import unittest
from test.support import requires
requires('gui')
from tkinter import Tk


class ScrolledListTest(unittest.TestCase):

    @classmethod

            

Reported by Pylint.

Import "from tkinter import Tk" should be placed at the top of the module
Error

Line: 7 Column: 1

              import unittest
from test.support import requires
requires('gui')
from tkinter import Tk


class ScrolledListTest(unittest.TestCase):

    @classmethod

            

Reported by Pylint.

Missing class docstring
Error

Line: 10 Column: 1

              from tkinter import Tk


class ScrolledListTest(unittest.TestCase):

    @classmethod
    def setUpClass(cls):
        cls.root = Tk()


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 22 Column: 5

                      del cls.root


    def test_init(self):
        ScrolledList(self.root)


if __name__ == '__main__':
    unittest.main(verbosity=2)

            

Reported by Pylint.

Lib/asyncio/runners.py
6 issues
Attempted relative import beyond top-level package
Error

Line: 3 Column: 1

              __all__ = 'run',

from . import coroutines
from . import events
from . import tasks


def run(main, *, debug=None):
    """Execute the coroutine and return the result.

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 4 Column: 1

              __all__ = 'run',

from . import coroutines
from . import events
from . import tasks


def run(main, *, debug=None):
    """Execute the coroutine and return the result.

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 5 Column: 1

              
from . import coroutines
from . import events
from . import tasks


def run(main, *, debug=None):
    """Execute the coroutine and return the result.


            

Reported by Pylint.

Access to a protected member _get_running_loop of a client class
Error

Line: 32 Column: 8

              
        asyncio.run(main())
    """
    if events._get_running_loop() is not None:
        raise RuntimeError(
            "asyncio.run() cannot be called from a running event loop")

    if not coroutines.iscoroutine(main):
        raise ValueError("a coroutine was expected, got {!r}".format(main))

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              __all__ = 'run',

from . import coroutines
from . import events
from . import tasks


def run(main, *, debug=None):
    """Execute the coroutine and return the result.

            

Reported by Pylint.

Disallow trailing comma tuple
Error

Line: 1 Column: 1

              __all__ = 'run',

from . import coroutines
from . import events
from . import tasks


def run(main, *, debug=None):
    """Execute the coroutine and return the result.

            

Reported by Pylint.

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

Line: 7 Column: 1

              import inspect
import os
import sys
import traceback
import types


def _is_debug_mode():
    # See: https://docs.python.org/3/library/asyncio-dev.html#asyncio-debug-mode.

            

Reported by Pylint.

Unused import traceback
Error

Line: 7 Column: 1

              import inspect
import os
import sys
import traceback
import types


def _is_debug_mode():
    # See: https://docs.python.org/3/library/asyncio-dev.html#asyncio-debug-mode.

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              __all__ = 'iscoroutinefunction', 'iscoroutine'

import collections.abc
import inspect
import os
import sys
import traceback
import types


            

Reported by Pylint.

Unnecessary "else" after "return"
Error

Line: 39 Column: 5

                  if type(obj) in _iscoroutine_typecache:
        return True

    if isinstance(obj, _COROUTINE_TYPES):
        # Just in case we don't want to cache more than 100
        # positive types.  That shouldn't ever happen, unless
        # someone stressing the system on purpose.
        if len(_iscoroutine_typecache) < 100:
            _iscoroutine_typecache.add(type(obj))

            

Reported by Pylint.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 51
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

              

def _format_coroutine(coro):
    assert iscoroutine(coro)

    def get_name(coro):
        # Coroutines compiled with Cython sometimes don't have
        # proper __qualname__ or __name__.  While that is a bug
        # in Cython, asyncio shouldn't crash with an AttributeError

            

Reported by Bandit.

Unnecessary "else" after "return"
Error

Line: 86 Column: 9

              
    if not coro_code:
        # Built-in types might not have __qualname__ or __name__.
        if is_running(coro):
            return f'{coro_name} running'
        else:
            return coro_name

    coro_frame = None

            

Reported by Pylint.

Lib/antigravity.py
6 issues
Unexpected keyword argument 'usedforsecurity' in constructor call
Error

Line: 15 Column: 9

              
    '''
    # https://xkcd.com/426/
    h = hashlib.md5(datedow, usedforsecurity=False).hexdigest()
    p, q = [('%f' % float.fromhex('0.' + x)) for x in (h[:16], h[16:32])]
    print('%d%s %d%s' % (latitude, p[1:], longitude, q[1:]))

            

Reported by Pylint.

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

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

              
    '''
    # https://xkcd.com/426/
    h = hashlib.md5(datedow, usedforsecurity=False).hexdigest()
    p, q = [('%f' % float.fromhex('0.' + x)) for x in (h[:16], h[16:32])]
    print('%d%s %d%s' % (latitude, p[1:], longitude, q[1:]))

            

Reported by Bandit.

Missing module docstring
Error

Line: 1 Column: 1

              
import webbrowser
import hashlib

webbrowser.open("https://xkcd.com/353/")

def geohash(latitude, longitude, datedow):
    '''Compute geohash() using the Munroe algorithm.


            

Reported by Pylint.

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

Line: 15 Column: 5

              
    '''
    # https://xkcd.com/426/
    h = hashlib.md5(datedow, usedforsecurity=False).hexdigest()
    p, q = [('%f' % float.fromhex('0.' + x)) for x in (h[:16], h[16:32])]
    print('%d%s %d%s' % (latitude, p[1:], longitude, q[1:]))

            

Reported by Pylint.

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

Line: 16 Column: 8

                  '''
    # https://xkcd.com/426/
    h = hashlib.md5(datedow, usedforsecurity=False).hexdigest()
    p, q = [('%f' % float.fromhex('0.' + x)) for x in (h[:16], h[16:32])]
    print('%d%s %d%s' % (latitude, p[1:], longitude, q[1:]))

            

Reported by Pylint.

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

Line: 16 Column: 5

                  '''
    # https://xkcd.com/426/
    h = hashlib.md5(datedow, usedforsecurity=False).hexdigest()
    p, q = [('%f' % float.fromhex('0.' + x)) for x in (h[:16], h[16:32])]
    print('%d%s %d%s' % (latitude, p[1:], longitude, q[1:]))

            

Reported by Pylint.

Lib/_threading_local.py
6 issues
Redefining name 'local' from outer scope (line 204)
Error

Line: 180 Column: 13

                          # Note that this is suboptimal if the thread object gets
            # caught in a reference loop. We would like to be called
            # as soon as the OS-level thread ends instead.
            local = wrlocal()
            if local is not None:
                dct = local.dicts.pop(idt)
        wrlocal = ref(self, local_deleted)
        wrthread = ref(thread, thread_deleted)
        thread.__dict__[key] = wrlocal

            

Reported by Pylint.

Unused variable 'dct'
Error

Line: 182 Column: 17

                          # as soon as the OS-level thread ends instead.
            local = wrlocal()
            if local is not None:
                dct = local.dicts.pop(idt)
        wrlocal = ref(self, local_deleted)
        wrthread = ref(thread, thread_deleted)
        thread.__dict__[key] = wrlocal
        self.dicts[idt] = wrthread, localdict
        return localdict

            

Reported by Pylint.

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

Line: 197 Column: 15

                      dct = impl.get_dict()
    except KeyError:
        dct = impl.create_dict()
        args, kw = impl.localargs
        self.__init__(*args, **kw)
    with impl.locallock:
        object.__setattr__(self, '__dict__', dct)
        yield


            

Reported by Pylint.

Missing class docstring
Error

Line: 204 Column: 1

                      yield


class local:
    __slots__ = '_local__impl', '__dict__'

    def __new__(cls, /, *args, **kw):
        if (args or kw) and (cls.__init__ is object.__init__):
            raise TypeError("Initialization arguments are not supported")

            

Reported by Pylint.

Class name "local" doesn't conform to PascalCase naming style
Error

Line: 204 Column: 1

                      yield


class local:
    __slots__ = '_local__impl', '__dict__'

    def __new__(cls, /, *args, **kw):
        if (args or kw) and (cls.__init__ is object.__init__):
            raise TypeError("Initialization arguments are not supported")

            

Reported by Pylint.

Import "from threading import current_thread, RLock" should be placed at the top of the module
Error

Line: 242 Column: 1

                          return object.__delattr__(self, name)


from threading import current_thread, RLock

            

Reported by Pylint.

Doc/tools/extensions/peg_highlight.py
6 issues
Unable to import 'sphinx.highlighting'
Error

Line: 4 Column: 1

              from pygments.lexer import RegexLexer, bygroups, include
from pygments.token import Comment, Generic, Keyword, Name, Operator, Punctuation, Text

from sphinx.highlighting import lexers


class PEGLexer(RegexLexer):
    """Pygments Lexer for PEG grammar (.gram) files


            

Reported by Pylint.

Unused Generic imported from pygments.token
Error

Line: 2 Column: 1

              from pygments.lexer import RegexLexer, bygroups, include
from pygments.token import Comment, Generic, Keyword, Name, Operator, Punctuation, Text

from sphinx.highlighting import lexers


class PEGLexer(RegexLexer):
    """Pygments Lexer for PEG grammar (.gram) files


            

Reported by Pylint.

Unused argument 'app'
Error

Line: 84 Column: 11

                  }


def setup(app):
    lexers["peg"] = PEGLexer()
    return {"version": "1.0", "parallel_read_safe": True}

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from pygments.lexer import RegexLexer, bygroups, include
from pygments.token import Comment, Generic, Keyword, Name, Operator, Punctuation, Text

from sphinx.highlighting import lexers


class PEGLexer(RegexLexer):
    """Pygments Lexer for PEG grammar (.gram) files


            

Reported by Pylint.

Line too long (114/100)
Error

Line: 56 Column: 1

                      ],
        "variables": [
            (_name + _text_ws + "(=)", bygroups(None, None, None),),
            (_name + _text_ws + r"(\[[\w\d_\*]+?\])" + _text_ws + "(=)", bygroups(None, None, None, None, None),),
        ],
        "invalids": [
            (r"^(\s+\|\s+invalid_\w+\s*\n)", bygroups(None)),
            (r"^(\s+\|\s+incorrect_\w+\s*\n)", bygroups(None)),
            (r"^(#.*invalid syntax.*(?:.|\n)*)", bygroups(None),),

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 84 Column: 1

                  }


def setup(app):
    lexers["peg"] = PEGLexer()
    return {"version": "1.0", "parallel_read_safe": True}

            

Reported by Pylint.

Doc/includes/sqlite3/text_factory.py
6 issues
Missing module docstring
Error

Line: 1 Column: 1

              import sqlite3

con = sqlite3.connect(":memory:")
cur = con.cursor()

AUSTRIA = "\xd6sterreich"

# by default, rows are returned as Unicode
cur.execute("select ?", (AUSTRIA,))

            

Reported by Pylint.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 11
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

              # by default, rows are returned as Unicode
cur.execute("select ?", (AUSTRIA,))
row = cur.fetchone()
assert row[0] == AUSTRIA

# but we can make sqlite3 always return bytestrings ...
con.text_factory = bytes
cur.execute("select ?", (AUSTRIA,))
row = cur.fetchone()

            

Reported by Bandit.

Using type() instead of isinstance() for a typecheck.
Error

Line: 17 Column: 8

              con.text_factory = bytes
cur.execute("select ?", (AUSTRIA,))
row = cur.fetchone()
assert type(row[0]) is bytes
# the bytestrings will be encoded in UTF-8, unless you stored garbage in the
# database ...
assert row[0] == AUSTRIA.encode("utf-8")

# we can also implement a custom text_factory ...

            

Reported by Pylint.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 17
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

              con.text_factory = bytes
cur.execute("select ?", (AUSTRIA,))
row = cur.fetchone()
assert type(row[0]) is bytes
# the bytestrings will be encoded in UTF-8, unless you stored garbage in the
# database ...
assert row[0] == AUSTRIA.encode("utf-8")

# we can also implement a custom text_factory ...

            

Reported by Bandit.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 20
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

              assert type(row[0]) is bytes
# the bytestrings will be encoded in UTF-8, unless you stored garbage in the
# database ...
assert row[0] == AUSTRIA.encode("utf-8")

# we can also implement a custom text_factory ...
# here we implement one that appends "foo" to all strings
con.text_factory = lambda x: x.decode("utf-8") + "foo"
cur.execute("select ?", ("bar",))

            

Reported by Bandit.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 27
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

              con.text_factory = lambda x: x.decode("utf-8") + "foo"
cur.execute("select ?", ("bar",))
row = cur.fetchone()
assert row[0] == "barfoo"

con.close()

            

Reported by Bandit.

Lib/importlib/metadata/_collections.py
6 issues
self.default_factory is not callable
Error

Line: 24 Column: 36

                      return getattr(self, '_frozen', super().__missing__)(key)

    def freeze(self):
        self._frozen = lambda key: self.default_factory()


class Pair(collections.namedtuple('Pair', 'name value')):
    @classmethod
    def parse(cls, text):

            

Reported by Pylint.

Attribute '_frozen' defined outside __init__
Error

Line: 24 Column: 9

                      return getattr(self, '_frozen', super().__missing__)(key)

    def freeze(self):
        self._frozen = lambda key: self.default_factory()


class Pair(collections.namedtuple('Pair', 'name value')):
    @classmethod
    def parse(cls, text):

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import collections


# from jaraco.collections 3.3
class FreezableDefaultDict(collections.defaultdict):
    """
    Often it is desirable to prevent the mutation of
    a default dict after its initial construction, such
    as to prevent mutation during iteration.

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 23 Column: 5

                  def __missing__(self, key):
        return getattr(self, '_frozen', super().__missing__)(key)

    def freeze(self):
        self._frozen = lambda key: self.default_factory()


class Pair(collections.namedtuple('Pair', 'name value')):
    @classmethod

            

Reported by Pylint.

Missing class docstring
Error

Line: 27 Column: 1

                      self._frozen = lambda key: self.default_factory()


class Pair(collections.namedtuple('Pair', 'name value')):
    @classmethod
    def parse(cls, text):
        return cls(*map(str.strip, text.split("=", 1)))

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 29 Column: 5

              
class Pair(collections.namedtuple('Pair', 'name value')):
    @classmethod
    def parse(cls, text):
        return cls(*map(str.strip, text.split("=", 1)))

            

Reported by Pylint.

Lib/importlib/metadata/_meta.py
6 issues
The special method '__div__' expects 1 param(s), 0 was given
Error

Line: 40 Column: 5

                  def joinpath(self) -> 'SimplePath':
        ...  # pragma: no cover

    def __div__(self) -> 'SimplePath':
        ...  # pragma: no cover

    def parent(self) -> 'SimplePath':
        ...  # pragma: no cover


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from typing import Any, Dict, Iterator, List, Protocol, TypeVar, Union


_T = TypeVar("_T")


class PackageMetadata(Protocol):
    def __len__(self) -> int:
        ...  # pragma: no cover

            

Reported by Pylint.

Missing class docstring
Error

Line: 7 Column: 1

              _T = TypeVar("_T")


class PackageMetadata(Protocol):
    def __len__(self) -> int:
        ...  # pragma: no cover

    def __contains__(self, item: str) -> bool:
        ...  # pragma: no cover

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 37 Column: 5

                  A minimal subset of pathlib.Path required by PathDistribution.
    """

    def joinpath(self) -> 'SimplePath':
        ...  # pragma: no cover

    def __div__(self) -> 'SimplePath':
        ...  # pragma: no cover


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 43 Column: 5

                  def __div__(self) -> 'SimplePath':
        ...  # pragma: no cover

    def parent(self) -> 'SimplePath':
        ...  # pragma: no cover

    def read_text(self) -> str:
        ...  # pragma: no cover

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 46 Column: 5

                  def parent(self) -> 'SimplePath':
        ...  # pragma: no cover

    def read_text(self) -> str:
        ...  # pragma: no cover

            

Reported by Pylint.