The following issues were found

Lib/test/test_sunau.py
20 issues
Missing module docstring
Error

Line: 1 Column: 1

              import unittest
from test import audiotests
from audioop import byteswap
import io
import struct
import sys
import sunau



            

Reported by Pylint.

Missing class docstring
Error

Line: 10 Column: 1

              import sunau


class SunauTest(audiotests.AudioWriteTests,
                audiotests.AudioTestsWithSourceFile):
    module = sunau


class SunauPCM8Test(SunauTest, unittest.TestCase):

            

Reported by Pylint.

Missing class docstring
Error

Line: 15 Column: 1

                  module = sunau


class SunauPCM8Test(SunauTest, unittest.TestCase):
    sndfilename = 'pluck-pcm8.au'
    sndfilenframes = 3307
    nchannels = 2
    sampwidth = 1
    framerate = 11025

            

Reported by Pylint.

Missing class docstring
Error

Line: 32 Column: 1

                    """)


class SunauPCM16Test(SunauTest, unittest.TestCase):
    sndfilename = 'pluck-pcm16.au'
    sndfilenframes = 3307
    nchannels = 2
    sampwidth = 2
    framerate = 11025

            

Reported by Pylint.

Missing class docstring
Error

Line: 51 Column: 1

                    """)


class SunauPCM24Test(SunauTest, unittest.TestCase):
    sndfilename = 'pluck-pcm24.au'
    sndfilenframes = 3307
    nchannels = 2
    sampwidth = 3
    framerate = 11025

            

Reported by Pylint.

Missing class docstring
Error

Line: 76 Column: 1

                    """)


class SunauPCM32Test(SunauTest, unittest.TestCase):
    sndfilename = 'pluck-pcm32.au'
    sndfilenframes = 3307
    nchannels = 2
    sampwidth = 4
    framerate = 11025

            

Reported by Pylint.

Missing class docstring
Error

Line: 101 Column: 1

                    """)


class SunauULAWTest(SunauTest, unittest.TestCase):
    sndfilename = 'pluck-ulaw.au'
    sndfilenframes = 3307
    nchannels = 2
    sampwidth = 2
    framerate = 11025

            

Reported by Pylint.

Missing class docstring
Error

Line: 122 Column: 1

                      frames = byteswap(frames, 2)


class SunauLowLevelTest(unittest.TestCase):

    def test_read_bad_magic_number(self):
        b = b'SPA'
        with self.assertRaises(EOFError):
            sunau.open(io.BytesIO(b))

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 124 Column: 5

              
class SunauLowLevelTest(unittest.TestCase):

    def test_read_bad_magic_number(self):
        b = b'SPA'
        with self.assertRaises(EOFError):
            sunau.open(io.BytesIO(b))
        b = b'SPAM'
        with self.assertRaisesRegex(sunau.Error, 'bad magic number'):

            

Reported by Pylint.

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

Line: 125 Column: 9

              class SunauLowLevelTest(unittest.TestCase):

    def test_read_bad_magic_number(self):
        b = b'SPA'
        with self.assertRaises(EOFError):
            sunau.open(io.BytesIO(b))
        b = b'SPAM'
        with self.assertRaisesRegex(sunau.Error, 'bad magic number'):
            sunau.open(io.BytesIO(b))

            

Reported by Pylint.

Lib/test/test_tools/test_md5sum.py
20 issues
Unused variable 'err'
Error

Line: 45 Column: 18

                      self.assertFalse(err)

    def test_dash_l(self):
        rc, out, err = assert_python_ok(self.script, '-l', self.fodder)
        self.assertEqual(rc, 0)
        self.assertIn(self.fodder_md5, out)
        parts = self.fodder.split(os.path.sep)
        self.assertIn(parts[-1].encode(), out)
        self.assertNotIn(parts[-2].encode(), out)

            

Reported by Pylint.

Unused variable 'err'
Error

Line: 53 Column: 18

                      self.assertNotIn(parts[-2].encode(), out)

    def test_dash_t(self):
        rc, out, err = assert_python_ok(self.script, '-t', self.fodder)
        self.assertEqual(rc, 0)
        self.assertTrue(out.startswith(self.fodder_textmode_md5))
        self.assertNotIn(self.fodder_md5, out)

    def test_dash_s(self):

            

Reported by Pylint.

Unused variable 'err'
Error

Line: 59 Column: 18

                      self.assertNotIn(self.fodder_md5, out)

    def test_dash_s(self):
        rc, out, err = assert_python_ok(self.script, '-s', '512', self.fodder)
        self.assertEqual(rc, 0)
        self.assertIn(self.fodder_md5, out)

    def test_multiple_files(self):
        rc, out, err = assert_python_ok(self.script, self.fodder, self.fodder)

            

Reported by Pylint.

Unused variable 'err'
Error

Line: 64 Column: 18

                      self.assertIn(self.fodder_md5, out)

    def test_multiple_files(self):
        rc, out, err = assert_python_ok(self.script, self.fodder, self.fodder)
        self.assertEqual(rc, 0)
        lines = out.splitlines()
        self.assertEqual(len(lines), 2)
        self.assertEqual(*lines)


            

Reported by Pylint.

Missing class docstring
Error

Line: 14 Column: 1

              skip_if_missing()

@hashlib_helper.requires_hashdigest('md5')
class MD5SumTests(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        cls.script = os.path.join(scriptsdir, 'md5sum.py')
        os.mkdir(os_helper.TESTFN)
        cls.fodder = os.path.join(os_helper.TESTFN, 'md5sum.fodder')

            

Reported by Pylint.

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

Line: 20 Column: 40

                      cls.script = os.path.join(scriptsdir, 'md5sum.py')
        os.mkdir(os_helper.TESTFN)
        cls.fodder = os.path.join(os_helper.TESTFN, 'md5sum.fodder')
        with open(cls.fodder, 'wb') as f:
            f.write(b'md5sum\r\ntest file\r\n')
        cls.fodder_md5 = b'd38dae2eb1ab346a292ef6850f9e1a0d'
        cls.fodder_textmode_md5 = b'a8b07894e2ca3f2a4c3094065fa6e0a5'

    @classmethod

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 29 Column: 5

                  def tearDownClass(cls):
        os_helper.rmtree(os_helper.TESTFN)

    def test_noargs(self):
        rc, out, err = assert_python_ok(self.script)
        self.assertEqual(rc, 0)
        self.assertTrue(
            out.startswith(b'd41d8cd98f00b204e9800998ecf8427e <stdin>'))
        self.assertFalse(err)

            

Reported by Pylint.

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

Line: 30 Column: 9

                      os_helper.rmtree(os_helper.TESTFN)

    def test_noargs(self):
        rc, out, err = assert_python_ok(self.script)
        self.assertEqual(rc, 0)
        self.assertTrue(
            out.startswith(b'd41d8cd98f00b204e9800998ecf8427e <stdin>'))
        self.assertFalse(err)


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 36 Column: 5

                          out.startswith(b'd41d8cd98f00b204e9800998ecf8427e <stdin>'))
        self.assertFalse(err)

    def test_checksum_fodder(self):
        rc, out, err = assert_python_ok(self.script, self.fodder)
        self.assertEqual(rc, 0)
        self.assertTrue(out.startswith(self.fodder_md5))
        for part in self.fodder.split(os.path.sep):
            self.assertIn(part.encode(), out)

            

Reported by Pylint.

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

Line: 37 Column: 9

                      self.assertFalse(err)

    def test_checksum_fodder(self):
        rc, out, err = assert_python_ok(self.script, self.fodder)
        self.assertEqual(rc, 0)
        self.assertTrue(out.startswith(self.fodder_md5))
        for part in self.fodder.split(os.path.sep):
            self.assertIn(part.encode(), out)
        self.assertFalse(err)

            

Reported by Pylint.

Tools/scripts/patchcheck.py
20 issues
Redefining name 'args' from outer scope (line 306)
Error

Line: 32 Column: 1

              def status(message, modal=False, info=None):
    """Decorator to output status info to stdout."""
    def decorated_fxn(fxn):
        def call_fxn(*args, **kwargs):
            sys.stdout.write(message + ' ... ')
            sys.stdout.flush()
            result = fxn(*args, **kwargs)
            if not modal and not info:
                print("done")

            

Reported by Pylint.

Redefining name 'status' from outer scope (line 29)
Error

Line: 136 Column: 17

                          for line in st.stdout:
                line = line.decode().rstrip()
                status_text, filename = line.split(maxsplit=1)
                status = set(status_text)
                # modified, added or unmerged files
                if not status.intersection('MAU'):
                    continue
                if ' -> ' in filename:
                    # file is renamed

            

Reported by Pylint.

Catching too general exception Exception
Error

Line: 209 Column: 16

                              with open(abspath, 'wb') as f:
                    f.writelines(new_lines)
                fixed.append(path)
        except Exception as err:
            print('Cannot fix %s: %s' % (path, err))
    return fixed


@status("Docs modified", modal=True)

            

Reported by Pylint.

Consider possible security implications associated with subprocess module.
Security blacklist

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

              import sys
import shutil
import os.path
import subprocess
import sysconfig

import reindent
import untabify


            

Reported by Bandit.

subprocess call - check for execution of untrusted input.
Security injection

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

                  """Get the symbolic name for the current git branch"""
    cmd = "git rev-parse --abbrev-ref HEAD".split()
    try:
        return subprocess.check_output(cmd,
                                       stderr=subprocess.DEVNULL,
                                       cwd=SRCDIR,
                                       encoding='UTF-8')
    except subprocess.CalledProcessError:
        return None

            

Reported by Bandit.

subprocess call - check for execution of untrusted input.
Security injection

Line: 66
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b603_subprocess_without_shell_equals_true.html

                  """
    cmd = "git remote get-url upstream".split()
    try:
        subprocess.check_output(cmd,
                                stderr=subprocess.DEVNULL,
                                cwd=SRCDIR,
                                encoding='UTF-8')
    except subprocess.CalledProcessError:
        return "origin"

            

Reported by Bandit.

subprocess call - check for execution of untrusted input.
Security injection

Line: 84
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b603_subprocess_without_shell_equals_true.html

                  env = os.environ.copy()
    env['LANG'] = 'C'
    try:
        remote_info = subprocess.check_output(cmd,
                                              stderr=subprocess.DEVNULL,
                                              cwd=SRCDIR,
                                              encoding='UTF-8',
                                              env=env)
    except subprocess.CalledProcessError:

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 100 Column: 1

              
@status("Getting base branch for PR",
        info=lambda x: x if x is not None else "not a PR branch")
def get_base_branch():
    if not os.path.exists(os.path.join(SRCDIR, '.git')):
        # Not a git checkout, so there's no base branch
        return None
    upstream_remote = get_git_upstream_remote()
    version = sys.version_info

            

Reported by Pylint.

subprocess call - check for execution of untrusted input.
Security injection

Line: 130
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b603_subprocess_without_shell_equals_true.html

                      else:
            cmd = 'git status --porcelain'
        filenames = []
        with subprocess.Popen(cmd.split(),
                              stdout=subprocess.PIPE,
                              cwd=SRCDIR) as st:
            for line in st.stdout:
                line = line.decode().rstrip()
                status_text, filename = line.split(maxsplit=1)

            

Reported by Bandit.

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

Line: 132 Column: 46

                      filenames = []
        with subprocess.Popen(cmd.split(),
                              stdout=subprocess.PIPE,
                              cwd=SRCDIR) as st:
            for line in st.stdout:
                line = line.decode().rstrip()
                status_text, filename = line.split(maxsplit=1)
                status = set(status_text)
                # modified, added or unmerged files

            

Reported by Pylint.

Tools/scripts/highlight.py
20 issues
Redefining name 'source' from outer scope (line 245)
Error

Line: 27 Column: 20

                  rows = [lines[srow-1][scol:]] + lines[srow: erow-1] + [lines[erow-1][:ecol]]
    return ''.join(rows), end

def analyze_python(source):
    '''Generate and classify chunks of Python for syntax highlighting.
       Yields tuples in the form: (category, categorized_text).
    '''
    lines = source.splitlines(True)
    lines.append('')

            

Reported by Pylint.

Unused variable 'logical_lineno'
Error

Line: 39 Column: 56

                  written = (1, 0)
    for tok in tokenize.generate_tokens(readline):
        prev_tok_type, prev_tok_str = tok_type, tok_str
        tok_type, tok_str, (srow, scol), (erow, ecol), logical_lineno = tok
        kind = ''
        if tok_type == tokenize.COMMENT:
            kind = 'comment'
        elif tok_type == tokenize.OP and tok_str[:1] not in '{}[](),.:;@':
            kind = 'operator'

            

Reported by Pylint.

Redefining name 'classified_text' from outer scope (line 246)
Error

Line: 68 Column: 19

              
#### Raw Output  ###########################################

def raw_highlight(classified_text):
    'Straight text display of text classifications'
    result = []
    for kind, text in classified_text:
        result.append('%15s:  %r\n' % (kind or 'plain', text))
    return ''.join(result)

            

Reported by Pylint.

Dangerous default value default_ansi (builtins.dict) as argument
Error

Line: 88 Column: 1

                  'operator': ('\033[0;33m', '\033[0m'),
}

def ansi_highlight(classified_text, colors=default_ansi):
    'Add syntax highlighting to source code using ANSI escape sequences'
    # http://en.wikipedia.org/wiki/ANSI_escape_code
    result = []
    for kind, text in classified_text:
        opener, closer = colors.get(kind, ('', ''))

            

Reported by Pylint.

Redefining name 'classified_text' from outer scope (line 246)
Error

Line: 88 Column: 20

                  'operator': ('\033[0;33m', '\033[0m'),
}

def ansi_highlight(classified_text, colors=default_ansi):
    'Add syntax highlighting to source code using ANSI escape sequences'
    # http://en.wikipedia.org/wiki/ANSI_escape_code
    result = []
    for kind, text in classified_text:
        opener, closer = colors.get(kind, ('', ''))

            

Reported by Pylint.

Redefining name 'classified_text' from outer scope (line 246)
Error

Line: 99 Column: 20

              
#### HTML Output ###########################################

def html_highlight(classified_text,opener='<pre class="python">\n', closer='</pre>\n'):
    'Convert classified text to an HTML fragment'
    result = [opener]
    for kind, text in classified_text:
        if kind:
            result.append('<span class="%s">' % kind)

            

Reported by Pylint.

Dangerous default value default_css (builtins.dict) as argument
Error

Line: 139 Column: 1

              </html>
'''

def build_html_page(classified_text, title='python',
                    css=default_css, html=default_html):
    'Create a complete HTML page with colorized source code'
    css_str = '\n'.join(['%s %s' % item for item in css.items()])
    result = html_highlight(classified_text)
    title = html_module.escape(title)

            

Reported by Pylint.

Redefining name 'classified_text' from outer scope (line 246)
Error

Line: 139 Column: 21

              </html>
'''

def build_html_page(classified_text, title='python',
                    css=default_css, html=default_html):
    'Create a complete HTML page with colorized source code'
    css_str = '\n'.join(['%s %s' % item for item in css.items()])
    result = html_highlight(classified_text)
    title = html_module.escape(title)

            

Reported by Pylint.

Redefining name 'classified_text' from outer scope (line 246)
Error

Line: 181 Column: 21

                  xlat = {'{': r'\{', '}': r'\}', '\\': r'\textbackslash{}'}
    return re.sub(r'[\\{}]', lambda mo: xlat[mo.group()], s)

def latex_highlight(classified_text, title = 'python',
                    commands = default_latex_commands,
                    document = default_latex_document):
    'Create a complete LaTeX document with colorized source code'
    macros = '\n'.join(r'\newcommand{\py%s}[1]{%s}' % c for c in commands.items())
    result = []

            

Reported by Pylint.

Dangerous default value default_latex_commands (builtins.dict) as argument
Error

Line: 181 Column: 1

                  xlat = {'{': r'\{', '}': r'\}', '\\': r'\textbackslash{}'}
    return re.sub(r'[\\{}]', lambda mo: xlat[mo.group()], s)

def latex_highlight(classified_text, title = 'python',
                    commands = default_latex_commands,
                    document = default_latex_document):
    'Create a complete LaTeX document with colorized source code'
    macros = '\n'.join(r'\newcommand{\py%s}[1]{%s}' % c for c in commands.items())
    result = []

            

Reported by Pylint.

Lib/test/support/socket_helper.py
20 issues
Attempted relative import beyond top-level package
Error

Line: 7 Column: 1

              import unittest
import sys

from .. import support


HOST = "localhost"
HOSTv4 = "127.0.0.1"
HOSTv6 = "::1"

            

Reported by Pylint.

Module 'socket' has no 'SO_EXCLUSIVEADDRUSE' member
Error

Line: 109 Column: 48

                              # under an older kernel that does not support SO_REUSEPORT.
                pass
        if hasattr(socket, 'SO_EXCLUSIVEADDRUSE'):
            sock.setsockopt(socket.SOL_SOCKET, socket.SO_EXCLUSIVEADDRUSE, 1)

    sock.bind((host, 0))
    port = sock.getsockname()[1]
    return port


            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 149 Column: 9

                      return unittest.skip('No UNIX Sockets')(test)
    global _bind_nix_socket_error
    if _bind_nix_socket_error is None:
        from .os_helper import TESTFN, unlink
        path = TESTFN + "can_bind_unix_socket"
        with socket.socket(socket.AF_UNIX) as sock:
            try:
                sock.bind(path)
                _bind_nix_socket_error = False

            

Reported by Pylint.

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

Line: 122 Column: 9

                      sock.bind(addr)
    except PermissionError:
        sock.close()
        raise unittest.SkipTest('cannot bind AF_UNIX sockets')

def _is_ipv6_enabled():
    """Check whether IPv6 is enabled on this host."""
    if socket.has_ipv6:
        sock = None

            

Reported by Pylint.

Using the global statement
Error

Line: 147 Column: 5

                  """Decorator for tests requiring a functional bind() for unix sockets."""
    if not hasattr(socket, 'AF_UNIX'):
        return unittest.skip('No UNIX Sockets')(test)
    global _bind_nix_socket_error
    if _bind_nix_socket_error is None:
        from .os_helper import TESTFN, unlink
        path = TESTFN + "can_bind_unix_socket"
        with socket.socket(socket.AF_UNIX) as sock:
            try:

            

Reported by Pylint.

XXX should we catch generic exceptions and look for their
Error

Line: 266 Column: 3

                              break
        filter_error(err)
        raise
    # XXX should we catch generic exceptions and look for their
    # __cause__ or __context__?
    finally:
        socket.setdefaulttimeout(old_timeout)

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import contextlib
import errno
import socket
import unittest
import sys

from .. import support



            

Reported by Pylint.

Constant name "HOSTv4" doesn't conform to UPPER_CASE naming style
Error

Line: 11 Column: 1

              

HOST = "localhost"
HOSTv4 = "127.0.0.1"
HOSTv6 = "::1"


def find_unused_port(family=socket.AF_INET, socktype=socket.SOCK_STREAM):
    """Returns an unused port that should be suitable for binding.  This is

            

Reported by Pylint.

Constant name "HOSTv6" doesn't conform to UPPER_CASE naming style
Error

Line: 12 Column: 1

              
HOST = "localhost"
HOSTv4 = "127.0.0.1"
HOSTv6 = "::1"


def find_unused_port(family=socket.AF_INET, socktype=socket.SOCK_STREAM):
    """Returns an unused port that should be suitable for binding.  This is
    achieved by creating a temporary socket with the same family and type as

            

Reported by Pylint.

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

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

              
def bind_unix_socket(sock, addr):
    """Bind a unix socket, raising SkipTest if PermissionError is raised."""
    assert sock.family == socket.AF_UNIX
    try:
        sock.bind(addr)
    except PermissionError:
        sock.close()
        raise unittest.SkipTest('cannot bind AF_UNIX sockets')

            

Reported by Bandit.

Lib/test/test_importlib/test_zip.py
20 issues
Access to a protected member _normalized_name of a client class
Error

Line: 82 Column: 16

              
    def test_normalized_name(self):
        dist = distribution('example')
        assert dist._normalized_name == 'example'

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import sys
import unittest

from contextlib import ExitStack
from importlib.metadata import (
    PackageNotFoundError,
    distribution,
    distributions,
    entry_points,

            

Reported by Pylint.

Missing class docstring
Error

Line: 19 Column: 1

              

@requires_zlib()
class TestZip(unittest.TestCase):
    root = 'test.test_importlib.data'

    def _fixture_on_path(self, filename):
        pkg_file = resources.files(self.root).joinpath(filename)
        file = self.resources.enter_context(resources.as_file(pkg_file))

            

Reported by Pylint.

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

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

                  def _fixture_on_path(self, filename):
        pkg_file = resources.files(self.root).joinpath(filename)
        file = self.resources.enter_context(resources.as_file(pkg_file))
        assert file.name.startswith('example-'), file.name
        sys.path.insert(0, str(file))
        self.resources.callback(sys.path.pop, 0)

    def setUp(self):
        # Find the path to the example-*.whl so we can add it to the front of

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 36 Column: 5

                      self.addCleanup(self.resources.close)
        self._fixture_on_path('example-21.12-py3-none-any.whl')

    def test_zip_version(self):
        self.assertEqual(version('example'), '21.12')

    def test_zip_version_does_not_match(self):
        with self.assertRaises(PackageNotFoundError):
            version('definitely-not-installed')

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 39 Column: 5

                  def test_zip_version(self):
        self.assertEqual(version('example'), '21.12')

    def test_zip_version_does_not_match(self):
        with self.assertRaises(PackageNotFoundError):
            version('definitely-not-installed')

    def test_zip_entry_points(self):
        scripts = entry_points(group='console_scripts')

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 43 Column: 5

                      with self.assertRaises(PackageNotFoundError):
            version('definitely-not-installed')

    def test_zip_entry_points(self):
        scripts = entry_points(group='console_scripts')
        entry_point = scripts['example']
        self.assertEqual(entry_point.value, 'example:main')
        entry_point = scripts['Example']
        self.assertEqual(entry_point.value, 'example:main')

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 50 Column: 5

                      entry_point = scripts['Example']
        self.assertEqual(entry_point.value, 'example:main')

    def test_missing_metadata(self):
        self.assertIsNone(distribution('example').read_text('does not exist'))

    def test_case_insensitive(self):
        self.assertEqual(version('Example'), '21.12')


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 53 Column: 5

                  def test_missing_metadata(self):
        self.assertIsNone(distribution('example').read_text('does not exist'))

    def test_case_insensitive(self):
        self.assertEqual(version('Example'), '21.12')

    def test_files(self):
        for file in files('example'):
            path = str(file.dist.locate_file(file))

            

Reported by Pylint.

Method could be a function
Error

Line: 56 Column: 5

                  def test_case_insensitive(self):
        self.assertEqual(version('Example'), '21.12')

    def test_files(self):
        for file in files('example'):
            path = str(file.dist.locate_file(file))
            assert '.whl/' in path, path

    def test_one_distribution(self):

            

Reported by Pylint.

Lib/test/libregrtest/win_utils.py
20 issues
Unable to import '_winapi'
Error

Line: 1 Column: 1

              import _winapi
import math
import msvcrt
import os
import subprocess
import uuid
import winreg
from test.support import os_helper
from test.libregrtest.utils import print_warning

            

Reported by Pylint.

Unable to import 'msvcrt'
Error

Line: 3 Column: 1

              import _winapi
import math
import msvcrt
import os
import subprocess
import uuid
import winreg
from test.support import os_helper
from test.libregrtest.utils import print_warning

            

Reported by Pylint.

Unable to import 'winreg'
Error

Line: 7 Column: 1

              import os
import subprocess
import uuid
import winreg
from test.support import os_helper
from test.libregrtest.utils import print_warning


# Max size of asynchronous reads

            

Reported by Pylint.

Unused variable 'bytes_read'
Error

Line: 124 Column: 9

              
    def _read_lines(self):
        overlapped, _ = _winapi.ReadFile(self.pipe, BUFSIZE, True)
        bytes_read, res = overlapped.GetOverlappedResult(False)
        if res != 0:
            return ()

        output = overlapped.getbuffer()
        output = output.decode('oem', 'replace')

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import _winapi
import math
import msvcrt
import os
import subprocess
import uuid
import winreg
from test.support import os_helper
from test.libregrtest.utils import print_warning

            

Reported by Pylint.

standard import "import math" should be placed before "import _winapi"
Error

Line: 2 Column: 1

              import _winapi
import math
import msvcrt
import os
import subprocess
import uuid
import winreg
from test.support import os_helper
from test.libregrtest.utils import print_warning

            

Reported by Pylint.

standard import "import msvcrt" should be placed before "import _winapi"
Error

Line: 3 Column: 1

              import _winapi
import math
import msvcrt
import os
import subprocess
import uuid
import winreg
from test.support import os_helper
from test.libregrtest.utils import print_warning

            

Reported by Pylint.

standard import "import os" should be placed before "import _winapi"
Error

Line: 4 Column: 1

              import _winapi
import math
import msvcrt
import os
import subprocess
import uuid
import winreg
from test.support import os_helper
from test.libregrtest.utils import print_warning

            

Reported by Pylint.

Consider possible security implications associated with subprocess module.
Security blacklist

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

              import math
import msvcrt
import os
import subprocess
import uuid
import winreg
from test.support import os_helper
from test.libregrtest.utils import print_warning


            

Reported by Bandit.

standard import "import subprocess" should be placed before "import _winapi"
Error

Line: 5 Column: 1

              import math
import msvcrt
import os
import subprocess
import uuid
import winreg
from test.support import os_helper
from test.libregrtest.utils import print_warning


            

Reported by Pylint.

Lib/test/test_colorsys.py
20 issues
Missing module docstring
Error

Line: 1 Column: 1

              import unittest
import colorsys

def frange(start, stop, step):
    while start <= stop:
        yield start
        start += step

class ColorsysTest(unittest.TestCase):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 4 Column: 1

              import unittest
import colorsys

def frange(start, stop, step):
    while start <= stop:
        yield start
        start += step

class ColorsysTest(unittest.TestCase):

            

Reported by Pylint.

Missing class docstring
Error

Line: 9 Column: 1

                      yield start
        start += step

class ColorsysTest(unittest.TestCase):

    def assertTripleEqual(self, tr1, tr2):
        self.assertEqual(len(tr1), 3)
        self.assertEqual(len(tr2), 3)
        self.assertAlmostEqual(tr1[0], tr2[0])

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 11 Column: 5

              
class ColorsysTest(unittest.TestCase):

    def assertTripleEqual(self, tr1, tr2):
        self.assertEqual(len(tr1), 3)
        self.assertEqual(len(tr2), 3)
        self.assertAlmostEqual(tr1[0], tr2[0])
        self.assertAlmostEqual(tr1[1], tr2[1])
        self.assertAlmostEqual(tr1[2], tr2[2])

            

Reported by Pylint.

Method name "assertTripleEqual" doesn't conform to snake_case naming style
Error

Line: 11 Column: 5

              
class ColorsysTest(unittest.TestCase):

    def assertTripleEqual(self, tr1, tr2):
        self.assertEqual(len(tr1), 3)
        self.assertEqual(len(tr2), 3)
        self.assertAlmostEqual(tr1[0], tr2[0])
        self.assertAlmostEqual(tr1[1], tr2[1])
        self.assertAlmostEqual(tr1[2], tr2[2])

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 18 Column: 5

                      self.assertAlmostEqual(tr1[1], tr2[1])
        self.assertAlmostEqual(tr1[2], tr2[2])

    def test_hsv_roundtrip(self):
        for r in frange(0.0, 1.0, 0.2):
            for g in frange(0.0, 1.0, 0.2):
                for b in frange(0.0, 1.0, 0.2):
                    rgb = (r, g, b)
                    self.assertTripleEqual(

            

Reported by Pylint.

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

Line: 19 Column: 13

                      self.assertAlmostEqual(tr1[2], tr2[2])

    def test_hsv_roundtrip(self):
        for r in frange(0.0, 1.0, 0.2):
            for g in frange(0.0, 1.0, 0.2):
                for b in frange(0.0, 1.0, 0.2):
                    rgb = (r, g, b)
                    self.assertTripleEqual(
                        rgb,

            

Reported by Pylint.

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

Line: 20 Column: 17

              
    def test_hsv_roundtrip(self):
        for r in frange(0.0, 1.0, 0.2):
            for g in frange(0.0, 1.0, 0.2):
                for b in frange(0.0, 1.0, 0.2):
                    rgb = (r, g, b)
                    self.assertTripleEqual(
                        rgb,
                        colorsys.hsv_to_rgb(*colorsys.rgb_to_hsv(*rgb))

            

Reported by Pylint.

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

Line: 21 Column: 21

                  def test_hsv_roundtrip(self):
        for r in frange(0.0, 1.0, 0.2):
            for g in frange(0.0, 1.0, 0.2):
                for b in frange(0.0, 1.0, 0.2):
                    rgb = (r, g, b)
                    self.assertTripleEqual(
                        rgb,
                        colorsys.hsv_to_rgb(*colorsys.rgb_to_hsv(*rgb))
                    )

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 28 Column: 5

                                      colorsys.hsv_to_rgb(*colorsys.rgb_to_hsv(*rgb))
                    )

    def test_hsv_values(self):
        values = [
            # rgb, hsv
            ((0.0, 0.0, 0.0), (  0  , 0.0, 0.0)), # black
            ((0.0, 0.0, 1.0), (4./6., 1.0, 1.0)), # blue
            ((0.0, 1.0, 0.0), (2./6., 1.0, 1.0)), # green

            

Reported by Pylint.

Lib/netrc.py
20 issues
Multiple imports on one line (os, shlex, stat)
Error

Line: 5 Column: 1

              
# Module and documentation by Eric S. Raymond, 21 Dec 1998

import os, shlex, stat

__all__ = ["netrc", "NetrcParseError"]


class NetrcParseError(Exception):

            

Reported by Pylint.

Missing class docstring
Error

Line: 22 Column: 1

                      return "%s (%s, line %s)" % (self.msg, self.filename, self.lineno)


class netrc:
    def __init__(self, file=None):
        default_netrc = file is None
        if file is None:
            file = os.path.join(os.path.expanduser("~"), ".netrc")
        self.hosts = {}

            

Reported by Pylint.

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

Line: 22 Column: 1

                      return "%s (%s, line %s)" % (self.msg, self.filename, self.lineno)


class netrc:
    def __init__(self, file=None):
        default_netrc = file is None
        if file is None:
            file = os.path.join(os.path.expanduser("~"), ".netrc")
        self.hosts = {}

            

Reported by Pylint.

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

Line: 30 Column: 50

                      self.hosts = {}
        self.macros = {}
        try:
            with open(file, encoding="utf-8") as fp:
                self._parse(file, fp, default_netrc)
        except UnicodeDecodeError:
            with open(file, encoding="locale") as fp:
                self._parse(file, fp, default_netrc)


            

Reported by Pylint.

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

Line: 33 Column: 51

                          with open(file, encoding="utf-8") as fp:
                self._parse(file, fp, default_netrc)
        except UnicodeDecodeError:
            with open(file, encoding="locale") as fp:
                self._parse(file, fp, default_netrc)

    def _parse(self, file, fp, default_netrc):
        lexer = shlex.shlex(fp)
        lexer.wordchars += r"""!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~"""

            

Reported by Pylint.

Too many branches (23/12)
Error

Line: 36 Column: 5

                          with open(file, encoding="locale") as fp:
                self._parse(file, fp, default_netrc)

    def _parse(self, file, fp, default_netrc):
        lexer = shlex.shlex(fp)
        lexer.wordchars += r"""!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~"""
        lexer.commenters = lexer.commenters.replace('#', '')
        while 1:
            # Look for a machine, default, or macdef top-level keyword

            

Reported by Pylint.

Too many local variables (17/15)
Error

Line: 36 Column: 5

                          with open(file, encoding="locale") as fp:
                self._parse(file, fp, default_netrc)

    def _parse(self, file, fp, default_netrc):
        lexer = shlex.shlex(fp)
        lexer.wordchars += r"""!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~"""
        lexer.commenters = lexer.commenters.replace('#', '')
        while 1:
            # Look for a machine, default, or macdef top-level keyword

            

Reported by Pylint.

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

Line: 36 Column: 5

                          with open(file, encoding="locale") as fp:
                self._parse(file, fp, default_netrc)

    def _parse(self, file, fp, default_netrc):
        lexer = shlex.shlex(fp)
        lexer.wordchars += r"""!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~"""
        lexer.commenters = lexer.commenters.replace('#', '')
        while 1:
            # Look for a machine, default, or macdef top-level keyword

            

Reported by Pylint.

Too many statements (62/50)
Error

Line: 36 Column: 5

                          with open(file, encoding="locale") as fp:
                self._parse(file, fp, default_netrc)

    def _parse(self, file, fp, default_netrc):
        lexer = shlex.shlex(fp)
        lexer.wordchars += r"""!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~"""
        lexer.commenters = lexer.commenters.replace('#', '')
        while 1:
            # Look for a machine, default, or macdef top-level keyword

            

Reported by Pylint.

Too many nested blocks (6/5)
Error

Line: 40 Column: 9

                      lexer = shlex.shlex(fp)
        lexer.wordchars += r"""!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~"""
        lexer.commenters = lexer.commenters.replace('#', '')
        while 1:
            # Look for a machine, default, or macdef top-level keyword
            saved_lineno = lexer.lineno
            toplevel = tt = lexer.get_token()
            if not tt:
                break

            

Reported by Pylint.

Lib/test/test_json/test_speedups.py
20 issues
Statement seems to have no effect
Error

Line: 6 Column: 9

              
class BadBool:
    def __bool__(self):
        1/0


class TestSpeedups(CTest):
    def test_scanstring(self):
        self.assertEqual(self.json.decoder.scanstring.__module__, "_json")

            

Reported by Pylint.

Unused argument 'args'
Error

Line: 44 Column: 1

                  def test_bad_str_encoder(self):
        # Issue #31505: There shouldn't be an assertion failure in case
        # c_make_encoder() receives a bad encoder() argument.
        def bad_encoder1(*args):
            return None
        enc = self.json.encoder.c_make_encoder(None, lambda obj: str(obj),
                                               bad_encoder1, None, ': ', ', ',
                                               False, False, False)
        with self.assertRaises(TypeError):

            

Reported by Pylint.

Lambda may not be necessary
Error

Line: 46 Column: 54

                      # c_make_encoder() receives a bad encoder() argument.
        def bad_encoder1(*args):
            return None
        enc = self.json.encoder.c_make_encoder(None, lambda obj: str(obj),
                                               bad_encoder1, None, ': ', ', ',
                                               False, False, False)
        with self.assertRaises(TypeError):
            enc('spam', 4)
        with self.assertRaises(TypeError):

            

Reported by Pylint.

Unused argument 'args'
Error

Line: 54 Column: 1

                      with self.assertRaises(TypeError):
            enc({'spam': 42}, 4)

        def bad_encoder2(*args):
            1/0
        enc = self.json.encoder.c_make_encoder(None, lambda obj: str(obj),
                                               bad_encoder2, None, ': ', ', ',
                                               False, False, False)
        with self.assertRaises(ZeroDivisionError):

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 55 Column: 13

                          enc({'spam': 42}, 4)

        def bad_encoder2(*args):
            1/0
        enc = self.json.encoder.c_make_encoder(None, lambda obj: str(obj),
                                               bad_encoder2, None, ': ', ', ',
                                               False, False, False)
        with self.assertRaises(ZeroDivisionError):
            enc('spam', 4)

            

Reported by Pylint.

Lambda may not be necessary
Error

Line: 56 Column: 54

              
        def bad_encoder2(*args):
            1/0
        enc = self.json.encoder.c_make_encoder(None, lambda obj: str(obj),
                                               bad_encoder2, None, ': ', ', ',
                                               False, False, False)
        with self.assertRaises(ZeroDivisionError):
            enc('spam', 4)


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from test.test_json import CTest


class BadBool:
    def __bool__(self):
        1/0


class TestSpeedups(CTest):

            

Reported by Pylint.

Missing class docstring
Error

Line: 4 Column: 1

              from test.test_json import CTest


class BadBool:
    def __bool__(self):
        1/0


class TestSpeedups(CTest):

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 4 Column: 1

              from test.test_json import CTest


class BadBool:
    def __bool__(self):
        1/0


class TestSpeedups(CTest):

            

Reported by Pylint.

Missing class docstring
Error

Line: 9 Column: 1

                      1/0


class TestSpeedups(CTest):
    def test_scanstring(self):
        self.assertEqual(self.json.decoder.scanstring.__module__, "_json")
        self.assertIs(self.json.decoder.scanstring, self.json.decoder.c_scanstring)

    def test_encode_basestring_ascii(self):

            

Reported by Pylint.