The following issues were found

Doc/includes/email-unpack.py
4 issues
Module name "email-unpack" doesn't conform to snake_case naming style
Error

Line: 1 Column: 1

              #!/usr/bin/env python3

"""Unpack a MIME message into a directory of files."""

import os
import email
import mimetypes

from email.policy import default

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 14 Column: 1

              from argparse import ArgumentParser


def main():
    parser = ArgumentParser(description="""\
Unpack a MIME message into a directory of files.
""")
    parser.add_argument('-d', '--directory', required=True,
                        help="""Unpack the MIME message into the named

            

Reported by Pylint.

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

Line: 25 Column: 38

                  parser.add_argument('msgfile')
    args = parser.parse_args()

    with open(args.msgfile, 'rb') as fp:
        msg = email.message_from_binary_file(fp, policy=default)

    try:
        os.mkdir(args.directory)
    except FileExistsError:

            

Reported by Pylint.

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

Line: 48 Column: 68

                              ext = '.bin'
            filename = f'part-{counter:03d}{ext}'
        counter += 1
        with open(os.path.join(args.directory, filename), 'wb') as fp:
            fp.write(part.get_payload(decode=True))


if __name__ == '__main__':
    main()

            

Reported by Pylint.

Doc/includes/sqlite3/mysumaggr.py
4 issues
Missing module docstring
Error

Line: 1 Column: 1

              import sqlite3

class MySum:
    def __init__(self):
        self.count = 0

    def step(self, value):
        self.count += value


            

Reported by Pylint.

Missing class docstring
Error

Line: 3 Column: 1

              import sqlite3

class MySum:
    def __init__(self):
        self.count = 0

    def step(self, value):
        self.count += value


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 7 Column: 5

                  def __init__(self):
        self.count = 0

    def step(self, value):
        self.count += value

    def finalize(self):
        return self.count


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 10 Column: 5

                  def step(self, value):
        self.count += value

    def finalize(self):
        return self.count

con = sqlite3.connect(":memory:")
con.create_aggregate("mysum", 1, MySum)
cur = con.cursor()

            

Reported by Pylint.

Doc/includes/sqlite3/md5func.py
4 issues
Use of insecure MD2, MD4, MD5, or SHA1 hash function.
Security blacklist

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

              import hashlib

def md5sum(t):
    return hashlib.md5(t).hexdigest()

con = sqlite3.connect(":memory:")
con.create_function("md5", 1, md5sum)
cur = con.cursor()
cur.execute("select md5(?)", (b"foo",))

            

Reported by Bandit.

Missing module docstring
Error

Line: 1 Column: 1

              import sqlite3
import hashlib

def md5sum(t):
    return hashlib.md5(t).hexdigest()

con = sqlite3.connect(":memory:")
con.create_function("md5", 1, md5sum)
cur = con.cursor()

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 4 Column: 1

              import sqlite3
import hashlib

def md5sum(t):
    return hashlib.md5(t).hexdigest()

con = sqlite3.connect(":memory:")
con.create_function("md5", 1, md5sum)
cur = con.cursor()

            

Reported by Pylint.

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

Line: 4 Column: 1

              import sqlite3
import hashlib

def md5sum(t):
    return hashlib.md5(t).hexdigest()

con = sqlite3.connect(":memory:")
con.create_function("md5", 1, md5sum)
cur = con.cursor()

            

Reported by Pylint.

Lib/distutils/tests/test_install_data.py
4 issues
Unused variable 'inst3'
Error

Line: 56 Column: 9

              
        # now using root and empty dir
        cmd.root = os.path.join(pkg_dir, 'root')
        inst3 = os.path.join(cmd.install_dir, 'inst3')
        inst4 = os.path.join(pkg_dir, 'inst4')
        three = os.path.join(cmd.install_dir, 'three')
        self.write_file(three, 'xx')
        cmd.data_files = [one, (inst2, [two]),
                          ('inst3', [three]),

            

Reported by Pylint.

Missing class docstring
Error

Line: 9 Column: 1

              from distutils.tests import support
from test.support import run_unittest

class InstallDataTestCase(support.TempdirManager,
                          support.LoggingSilencer,
                          support.EnvironGuard,
                          unittest.TestCase):

    def test_simple_run(self):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 14 Column: 5

                                        support.EnvironGuard,
                          unittest.TestCase):

    def test_simple_run(self):
        pkg_dir, dist = self.create_dist()
        cmd = install_data(dist)
        cmd.install_dir = inst = os.path.join(pkg_dir, 'inst')

        # data_files can contain

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 71 Column: 1

                      self.assertTrue(os.path.exists(os.path.join(inst2, rtwo)))
        self.assertTrue(os.path.exists(os.path.join(inst, rone)))

def test_suite():
    return unittest.makeSuite(InstallDataTestCase)

if __name__ == "__main__":
    run_unittest(test_suite())

            

Reported by Pylint.

Tools/scripts/lfcr.py
4 issues
Multiple imports on one line (sys, re, os)
Error

Line: 5 Column: 1

              
"Replace LF with CRLF in argument files.  Print names of changed files."

import sys, re, os

def main():
    for filename in sys.argv[1:]:
        if os.path.isdir(filename):
            print(filename, "Directory!")

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 7 Column: 1

              
import sys, re, os

def main():
    for filename in sys.argv[1:]:
        if os.path.isdir(filename):
            print(filename, "Directory!")
            continue
        with open(filename, "rb") as f:

            

Reported by Pylint.

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

Line: 12 Column: 38

                      if os.path.isdir(filename):
            print(filename, "Directory!")
            continue
        with open(filename, "rb") as f:
            data = f.read()
        if b'\0' in data:
            print(filename, "Binary!")
            continue
        newdata = re.sub(b"\r?\n", b"\r\n", data)

            

Reported by Pylint.

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

Line: 20 Column: 42

                      newdata = re.sub(b"\r?\n", b"\r\n", data)
        if newdata != data:
            print(filename)
            with open(filename, "wb") as f:
                f.write(newdata)

if __name__ == '__main__':
    main()

            

Reported by Pylint.

Tools/scripts/fixps.py
4 issues
Missing module docstring
Error

Line: 1 Column: 1

              #!/usr/bin/env python3

# Fix Python script(s) to reference the interpreter via /usr/bin/env python.
# Warning: this overwrites the file without making a backup.

import sys
import re



            

Reported by Pylint.

Missing function or method docstring
Error

Line: 10 Column: 1

              import re


def main():
    for filename in sys.argv[1:]:
        try:
            f = open(filename, 'r')
        except IOError as msg:
            print(filename, ': can\'t open :', msg)

            

Reported by Pylint.

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

Line: 13 Column: 13

              def main():
    for filename in sys.argv[1:]:
        try:
            f = open(filename, 'r')
        except IOError as msg:
            print(filename, ': can\'t open :', msg)
            continue
        with f:
            line = f.readline()

            

Reported by Pylint.

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

Line: 26 Column: 37

                      line = re.sub('/usr/local/bin/python',
                      '/usr/bin/env python', line)
        print(filename, ':', repr(line))
        with open(filename, "w") as f:
            f.write(line)
            f.write(rest)

if __name__ == '__main__':
    main()

            

Reported by Pylint.

Tools/scripts/untabify.py
4 issues
Missing function or method docstring
Error

Line: 10 Column: 1

              import getopt
import tokenize

def main():
    tabsize = 8
    try:
        opts, args = getopt.getopt(sys.argv[1:], "t:")
        if not args:
            raise getopt.error("At least one file argument required")

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 28 Column: 1

                      process(filename, tabsize)


def process(filename, tabsize, verbose=True):
    try:
        with tokenize.open(filename) as f:
            text = f.read()
            encoding = f.encoding
    except IOError as msg:

            

Reported by Pylint.

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

Line: 30 Column: 41

              
def process(filename, tabsize, verbose=True):
    try:
        with tokenize.open(filename) as f:
            text = f.read()
            encoding = f.encoding
    except IOError as msg:
        print("%r: I/O error: %s" % (filename, msg))
        return

            

Reported by Pylint.

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

Line: 48 Column: 52

                      os.rename(filename, backup)
    except OSError:
        pass
    with open(filename, "w", encoding=encoding) as f:
        f.write(newtext)
    if verbose:
        print(filename)



            

Reported by Pylint.

Tools/scripts/suff.py
4 issues
Unused variable 'name'
Error

Line: 21 Column: 5

              

def getsuffix(filename):
    name, sep, suff = filename.rpartition('.')
    return sep + suff if sep else ''


if __name__ == '__main__':
    main()

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              #! /usr/bin/env python3

# suff
#
# show different suffixes amongst arguments

import sys



            

Reported by Pylint.

Missing function or method docstring
Error

Line: 10 Column: 1

              import sys


def main():
    files = sys.argv[1:]
    suffixes = {}
    for filename in files:
        suff = getsuffix(filename)
        suffixes.setdefault(suff, []).append(filename)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 20 Column: 1

                      print(repr(suff), len(filenames))


def getsuffix(filename):
    name, sep, suff = filename.rpartition('.')
    return sep + suff if sep else ''


if __name__ == '__main__':

            

Reported by Pylint.

Tools/unicode/gencjkcodecs.py
4 issues
Multiple imports on one line (os, string)
Error

Line: 1 Column: 1

              import os, string

codecs = {
    'cn': ('gb2312', 'gbk', 'gb18030', 'hz'),
    'tw': ('big5', 'cp950'),
    'hk': ('big5hkscs',),
    'jp': ('cp932', 'shift_jis', 'euc_jp', 'euc_jisx0213', 'shift_jisx0213',
           'euc_jis_2004', 'shift_jis_2004'),
    'kr': ('cp949', 'euc_kr', 'johab'),

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import os, string

codecs = {
    'cn': ('gb2312', 'gbk', 'gb18030', 'hz'),
    'tw': ('big5', 'cp950'),
    'hk': ('big5hkscs',),
    'jp': ('cp932', 'shift_jis', 'euc_jp', 'euc_jisx0213', 'shift_jisx0213',
           'euc_jis_2004', 'shift_jis_2004'),
    'kr': ('cp949', 'euc_kr', 'johab'),

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 57 Column: 1

                  )
""")

def gencodecs(prefix):
    for loc, encodings in codecs.items():
        for enc in encodings:
            code = TEMPLATE.substitute(ENCODING=enc.upper(),
                                       encoding=enc.lower(),
                                       owner=loc)

            

Reported by Pylint.

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

Line: 64 Column: 42

                                                     encoding=enc.lower(),
                                       owner=loc)
            codecpath = os.path.join(prefix, enc + '.py')
            with open(codecpath, 'w') as f:
                f.write(code)

if __name__ == '__main__':
    import sys
    gencodecs(sys.argv[1])

            

Reported by Pylint.

Tools/peg_generator/scripts/find_max_nesting.py
4 issues
Catching too general exception Exception
Error

Line: 34 Column: 12

                      ast.parse(expr)
        print(f"Nesting depth of {nesting_depth} is successful")
        return True
    except Exception as err:
        print(f"{FAIL}(Failed with nesting depth of {nesting_depth}{ENDC}")
        print(f"{FAIL}\t{err}{ENDC}")
        return False



            

Reported by Pylint.

Unused variable 'expr'
Error

Line: 46 Column: 9

                  nesting_depth = INITIAL_NESTING_DEPTH
    succeeded = True
    while succeeded:
        expr = f"{'(' * nesting_depth}0{')' * nesting_depth}"
        if succeeded:
            succeeded = check_nested_expr(nesting_depth)
        nesting_depth += NESTED_INCR_AMT

    sys.exit(1)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 28 Column: 1

              ENDC = "\033[0m"


def check_nested_expr(nesting_depth: int) -> bool:
    expr = f"{'(' * nesting_depth}0{')' * nesting_depth}"
    try:
        ast.parse(expr)
        print(f"Nesting depth of {nesting_depth} is successful")
        return True

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 40 Column: 1

                      return False


def main() -> None:
    print(f"Testing {GRAMMAR_FILE} starting at nesting depth of {INITIAL_NESTING_DEPTH}...")

    nesting_depth = INITIAL_NESTING_DEPTH
    succeeded = True
    while succeeded:

            

Reported by Pylint.