The following issues were found

Tools/scripts/ndiff.py
17 issues
Redefining name 'args' from outer scope (line 124)
Error

Line: 84 Column: 10

              # crack args (sys.argv[1:] is normal) & compare;
# return false iff a problem

def main(args):
    import getopt
    try:
        opts, args = getopt.getopt(args, "qr:")
    except getopt.error as detail:
        return fail(str(detail))

            

Reported by Pylint.

Multiple imports on one line (difflib, sys)
Error

Line: 51 Column: 1

              
__version__ = 1, 7, 0

import difflib, sys

def fail(msg):
    out = sys.stderr.write
    out(msg + "\n\n")
    out(__doc__)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 53 Column: 1

              
import difflib, sys

def fail(msg):
    out = sys.stderr.write
    out(msg + "\n\n")
    out(__doc__)
    return 0


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 61 Column: 1

              
# open a file & return the file object; gripe and return 0 if it
# couldn't be opened
def fopen(fname):
    try:
        return open(fname)
    except IOError as detail:
        return fail("couldn't open " + fname + ": " + str(detail))


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 68 Column: 1

                      return fail("couldn't open " + fname + ": " + str(detail))

# open two files & spray the diff to stdout; return false iff a problem
def fcompare(f1name, f2name):
    f1 = fopen(f1name)
    f2 = fopen(f2name)
    if not f1 or not f2:
        return 0


            

Reported by Pylint.

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

Line: 69 Column: 5

              
# open two files & spray the diff to stdout; return false iff a problem
def fcompare(f1name, f2name):
    f1 = fopen(f1name)
    f2 = fopen(f2name)
    if not f1 or not f2:
        return 0

    a = f1.readlines(); f1.close()

            

Reported by Pylint.

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

Line: 70 Column: 5

              # open two files & spray the diff to stdout; return false iff a problem
def fcompare(f1name, f2name):
    f1 = fopen(f1name)
    f2 = fopen(f2name)
    if not f1 or not f2:
        return 0

    a = f1.readlines(); f1.close()
    b = f2.readlines(); f2.close()

            

Reported by Pylint.

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

Line: 74 Column: 5

                  if not f1 or not f2:
        return 0

    a = f1.readlines(); f1.close()
    b = f2.readlines(); f2.close()
    for line in difflib.ndiff(a, b):
        print(line, end=' ')

    return 1

            

Reported by Pylint.

More than one statement on a single line
Error

Line: 74 Column: 25

                  if not f1 or not f2:
        return 0

    a = f1.readlines(); f1.close()
    b = f2.readlines(); f2.close()
    for line in difflib.ndiff(a, b):
        print(line, end=' ')

    return 1

            

Reported by Pylint.

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

Line: 75 Column: 5

                      return 0

    a = f1.readlines(); f1.close()
    b = f2.readlines(); f2.close()
    for line in difflib.ndiff(a, b):
        print(line, end=' ')

    return 1


            

Reported by Pylint.

Lib/rlcompleter.py
17 issues
Attribute 'matches' defined outside __init__
Error

Line: 90 Column: 17

              
        if state == 0:
            if "." in text:
                self.matches = self.attr_matches(text)
            else:
                self.matches = self.global_matches(text)
        try:
            return self.matches[state]
        except IndexError:

            

Reported by Pylint.

Attribute 'matches' defined outside __init__
Error

Line: 92 Column: 17

                          if "." in text:
                self.matches = self.attr_matches(text)
            else:
                self.matches = self.global_matches(text)
        try:
            return self.matches[state]
        except IndexError:
            return None


            

Reported by Pylint.

Use of eval
Error

Line: 155 Column: 26

                          return []
        expr, attr = m.group(1, 3)
        try:
            thisobject = eval(expr, self.namespace)
        except Exception:
            return []

        # get the content of the object, except __builtins__
        words = set(dir(thisobject))

            

Reported by Pylint.

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

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

                          return []
        expr, attr = m.group(1, 3)
        try:
            thisobject = eval(expr, self.namespace)
        except Exception:
            return []

        # get the content of the object, except __builtins__
        words = set(dir(thisobject))

            

Reported by Bandit.

Catching too general exception Exception
Error

Line: 156 Column: 16

                      expr, attr = m.group(1, 3)
        try:
            thisobject = eval(expr, self.namespace)
        except Exception:
            return []

        # get the content of the object, except __builtins__
        words = set(dir(thisobject))
        words.discard("__builtins__")

            

Reported by Pylint.

Missing class docstring
Error

Line: 39 Column: 1

              
__all__ = ["Completer"]

class Completer:
    def __init__(self, namespace = None):
        """Create a new completer for the command line.

        Completer([namespace]) -> completer instance.


            

Reported by Pylint.

Unnecessary "else" after "return"
Error

Line: 79 Column: 17

              
        if not text.strip():
            if state == 0:
                if _readline_available:
                    readline.insert_text('\t')
                    readline.redisplay()
                    return ''
                else:
                    return '\t'

            

Reported by Pylint.

Method could be a function
Error

Line: 98 Column: 5

                      except IndexError:
            return None

    def _callable_postfix(self, val, word):
        if callable(val):
            word += "("
            try:
                if not inspect.signature(val).parameters:
                    word += ")"

            

Reported by Pylint.

Import outside toplevel (keyword)
Error

Line: 116 Column: 9

                      defined in self.namespace that match.

        """
        import keyword
        matches = []
        seen = {"__builtins__"}
        n = len(text)
        for word in keyword.kwlist:
            if word[:n] == text:

            

Reported by Pylint.

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

Line: 119 Column: 9

                      import keyword
        matches = []
        seen = {"__builtins__"}
        n = len(text)
        for word in keyword.kwlist:
            if word[:n] == text:
                seen.add(word)
                if word in {'finally', 'try'}:
                    word = word + ':'

            

Reported by Pylint.

Lib/test/test_grp.py
17 issues
Unused variable 'mem'
Error

Line: 60 Column: 23

                      # try to get some errors
        bynames = {}
        bygids = {}
        for (n, p, g, mem) in grp.getgrall():
            if not n or n == '+':
                continue # skip NIS entries etc.
            bynames[n] = g
            bygids[g] = n


            

Reported by Pylint.

Unused variable 'p'
Error

Line: 60 Column: 17

                      # try to get some errors
        bynames = {}
        bygids = {}
        for (n, p, g, mem) in grp.getgrall():
            if not n or n == '+':
                continue # skip NIS entries etc.
            bynames[n] = g
            bygids[g] = n


            

Reported by Pylint.

Missing class docstring
Error

Line: 9 Column: 1

              
grp = import_helper.import_module('grp')

class GroupDatabaseTestCase(unittest.TestCase):

    def check_value(self, value):
        # check that a grp tuple has the entries and
        # attributes promised by the docs
        self.assertEqual(len(value), 4)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 11 Column: 5

              
class GroupDatabaseTestCase(unittest.TestCase):

    def check_value(self, value):
        # check that a grp tuple has the entries and
        # attributes promised by the docs
        self.assertEqual(len(value), 4)
        self.assertEqual(value[0], value.gr_name)
        self.assertIsInstance(value.gr_name, str)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 24 Column: 5

                      self.assertEqual(value[3], value.gr_mem)
        self.assertIsInstance(value.gr_mem, list)

    def test_values(self):
        entries = grp.getgrall()

        for e in entries:
            self.check_value(e)


            

Reported by Pylint.

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

Line: 27 Column: 13

                  def test_values(self):
        entries = grp.getgrall()

        for e in entries:
            self.check_value(e)

    def test_values_extended(self):
        entries = grp.getgrall()
        if len(entries) > 1000:  # Huge group file (NIS?) -- skip the rest

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 30 Column: 5

                      for e in entries:
            self.check_value(e)

    def test_values_extended(self):
        entries = grp.getgrall()
        if len(entries) > 1000:  # Huge group file (NIS?) -- skip the rest
            self.skipTest('huge group file, extended test skipped')

        for e in entries:

            

Reported by Pylint.

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

Line: 35 Column: 13

                      if len(entries) > 1000:  # Huge group file (NIS?) -- skip the rest
            self.skipTest('huge group file, extended test skipped')

        for e in entries:
            e2 = grp.getgrgid(e.gr_gid)
            self.check_value(e2)
            self.assertEqual(e2.gr_gid, e.gr_gid)
            name = e.gr_name
            if name.startswith('+') or name.startswith('-'):

            

Reported by Pylint.

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

Line: 36 Column: 13

                          self.skipTest('huge group file, extended test skipped')

        for e in entries:
            e2 = grp.getgrgid(e.gr_gid)
            self.check_value(e2)
            self.assertEqual(e2.gr_gid, e.gr_gid)
            name = e.gr_name
            if name.startswith('+') or name.startswith('-'):
                # NIS-related entry

            

Reported by Pylint.

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

Line: 43 Column: 13

                          if name.startswith('+') or name.startswith('-'):
                # NIS-related entry
                continue
            e2 = grp.getgrnam(name)
            self.check_value(e2)
            # There are instances where getgrall() returns group names in
            # lowercase while getgrgid() returns proper casing.
            # Discovered on Ubuntu 5.04 (custom).
            self.assertEqual(e2.gr_name.lower(), name.lower())

            

Reported by Pylint.

Lib/test/test_importlib/builtin/test_finder.py
17 issues
Attempted relative import beyond top-level package
Error

Line: 1 Column: 1

              from .. import abc
from .. import util

machinery = util.import_importlib('importlib.machinery')

import sys
import unittest
import warnings


            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 2 Column: 1

              from .. import abc
from .. import util

machinery = util.import_importlib('importlib.machinery')

import sys
import unittest
import warnings


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from .. import abc
from .. import util

machinery = util.import_importlib('importlib.machinery')

import sys
import unittest
import warnings


            

Reported by Pylint.

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

Line: 6 Column: 1

              
machinery = util.import_importlib('importlib.machinery')

import sys
import unittest
import warnings


@unittest.skipIf(util.BUILTINS.good_name is None, 'no reasonable builtin module')

            

Reported by Pylint.

standard import "import sys" should be placed before "from .. import abc"
Error

Line: 6 Column: 1

              
machinery = util.import_importlib('importlib.machinery')

import sys
import unittest
import warnings


@unittest.skipIf(util.BUILTINS.good_name is None, 'no reasonable builtin module')

            

Reported by Pylint.

standard import "import unittest" should be placed before "from .. import abc"
Error

Line: 7 Column: 1

              machinery = util.import_importlib('importlib.machinery')

import sys
import unittest
import warnings


@unittest.skipIf(util.BUILTINS.good_name is None, 'no reasonable builtin module')
class FindSpecTests(abc.FinderTests):

            

Reported by Pylint.

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

Line: 7 Column: 1

              machinery = util.import_importlib('importlib.machinery')

import sys
import unittest
import warnings


@unittest.skipIf(util.BUILTINS.good_name is None, 'no reasonable builtin module')
class FindSpecTests(abc.FinderTests):

            

Reported by Pylint.

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

Line: 8 Column: 1

              
import sys
import unittest
import warnings


@unittest.skipIf(util.BUILTINS.good_name is None, 'no reasonable builtin module')
class FindSpecTests(abc.FinderTests):


            

Reported by Pylint.

standard import "import warnings" should be placed before "from .. import abc"
Error

Line: 8 Column: 1

              
import sys
import unittest
import warnings


@unittest.skipIf(util.BUILTINS.good_name is None, 'no reasonable builtin module')
class FindSpecTests(abc.FinderTests):


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 16 Column: 5

              
    """Test find_spec() for built-in modules."""

    def test_module(self):
        # Common case.
        with util.uncache(util.BUILTINS.good_name):
            found = self.machinery.BuiltinImporter.find_spec(util.BUILTINS.good_name)
            self.assertTrue(found)
            self.assertEqual(found.origin, 'built-in')

            

Reported by Pylint.

Lib/symtable.py
17 issues
Unused USE imported from _symtable
Error

Line: 4 Column: 1

              """Interface to the compiler's internal symbol tables"""

import _symtable
from _symtable import (USE, DEF_GLOBAL, DEF_NONLOCAL, DEF_LOCAL, DEF_PARAM,
     DEF_IMPORT, DEF_BOUND, DEF_ANNOT, SCOPE_OFF, SCOPE_MASK, FREE,
     LOCAL, GLOBAL_IMPLICIT, GLOBAL_EXPLICIT, CELL)

import weakref


            

Reported by Pylint.

Unused DEF_GLOBAL imported from _symtable
Error

Line: 4 Column: 1

              """Interface to the compiler's internal symbol tables"""

import _symtable
from _symtable import (USE, DEF_GLOBAL, DEF_NONLOCAL, DEF_LOCAL, DEF_PARAM,
     DEF_IMPORT, DEF_BOUND, DEF_ANNOT, SCOPE_OFF, SCOPE_MASK, FREE,
     LOCAL, GLOBAL_IMPLICIT, GLOBAL_EXPLICIT, CELL)

import weakref


            

Reported by Pylint.

standard import "import weakref" should be placed before "import _symtable"
Error

Line: 8 Column: 1

                   DEF_IMPORT, DEF_BOUND, DEF_ANNOT, SCOPE_OFF, SCOPE_MASK, FREE,
     LOCAL, GLOBAL_IMPLICIT, GLOBAL_EXPLICIT, CELL)

import weakref

__all__ = ["symtable", "SymbolTable", "Class", "Function", "Symbol"]

def symtable(code, filename, compile_type):
    """ Return the toplevel *SymbolTable* for the source code.

            

Reported by Pylint.

Missing class docstring
Error

Line: 21 Column: 1

                  top = _symtable.symtable(code, filename, compile_type)
    return _newSymbolTable(top, filename)

class SymbolTableFactory:
    def __init__(self):
        self.__memo = weakref.WeakValueDictionary()

    def new(self, table, filename):
        if table.type == _symtable.TYPE_FUNCTION:

            

Reported by Pylint.

Method could be a function
Error

Line: 25 Column: 5

                  def __init__(self):
        self.__memo = weakref.WeakValueDictionary()

    def new(self, table, filename):
        if table.type == _symtable.TYPE_FUNCTION:
            return Function(table, filename)
        if table.type == _symtable.TYPE_CLASS:
            return Class(table, filename)
        return SymbolTable(table, filename)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 25 Column: 5

                  def __init__(self):
        self.__memo = weakref.WeakValueDictionary()

    def new(self, table, filename):
        if table.type == _symtable.TYPE_FUNCTION:
            return Function(table, filename)
        if table.type == _symtable.TYPE_CLASS:
            return Class(table, filename)
        return SymbolTable(table, filename)

            

Reported by Pylint.

Missing class docstring
Error

Line: 42 Column: 1

              _newSymbolTable = SymbolTableFactory()


class SymbolTable:

    def __init__(self, raw_table, filename):
        self._table = raw_table
        self._filename = filename
        self._symbols = {}

            

Reported by Pylint.

Unnecessary "else" after "return"
Error

Line: 55 Column: 9

                      else:
            kind = "%s " % self.__class__.__name__

        if self._table.name == "top":
            return "<{0}SymbolTable for module {1}>".format(kind, self._filename)
        else:
            return "<{0}SymbolTable for {1} in {2}>".format(kind,
                                                            self._table.name,
                                                            self._filename)

            

Reported by Pylint.

Either all return statements in a function should return an expression, or none of them should.
Error

Line: 62 Column: 5

                                                                          self._table.name,
                                                            self._filename)

    def get_type(self):
        """Return the type of the symbol table.

        The values returned are 'class', 'module' and
        'function'.
        """

            

Reported by Pylint.

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

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

                          return "function"
        if self._table.type == _symtable.TYPE_CLASS:
            return "class"
        assert self._table.type in (1, 2, 3), \
               "unexpected type: {0}".format(self._table.type)

    def get_id(self):
        """Return an identifier for the table.
        """

            

Reported by Bandit.

Lib/test/test_asyncio/test_protocols.py
17 issues
Missing module docstring
Error

Line: 1 Column: 1

              import unittest
from unittest import mock

import asyncio


class ProtocolsAbsTests(unittest.TestCase):

    def test_base_protocol(self):

            

Reported by Pylint.

Missing class docstring
Error

Line: 7 Column: 1

              import asyncio


class ProtocolsAbsTests(unittest.TestCase):

    def test_base_protocol(self):
        f = mock.Mock()
        p = asyncio.BaseProtocol()
        self.assertIsNone(p.connection_made(f))

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 9 Column: 5

              
class ProtocolsAbsTests(unittest.TestCase):

    def test_base_protocol(self):
        f = mock.Mock()
        p = asyncio.BaseProtocol()
        self.assertIsNone(p.connection_made(f))
        self.assertIsNone(p.connection_lost(f))
        self.assertIsNone(p.pause_writing())

            

Reported by Pylint.

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

Line: 10 Column: 9

              class ProtocolsAbsTests(unittest.TestCase):

    def test_base_protocol(self):
        f = mock.Mock()
        p = asyncio.BaseProtocol()
        self.assertIsNone(p.connection_made(f))
        self.assertIsNone(p.connection_lost(f))
        self.assertIsNone(p.pause_writing())
        self.assertIsNone(p.resume_writing())

            

Reported by Pylint.

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

Line: 11 Column: 9

              
    def test_base_protocol(self):
        f = mock.Mock()
        p = asyncio.BaseProtocol()
        self.assertIsNone(p.connection_made(f))
        self.assertIsNone(p.connection_lost(f))
        self.assertIsNone(p.pause_writing())
        self.assertIsNone(p.resume_writing())
        self.assertFalse(hasattr(p, '__dict__'))

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 18 Column: 5

                      self.assertIsNone(p.resume_writing())
        self.assertFalse(hasattr(p, '__dict__'))

    def test_protocol(self):
        f = mock.Mock()
        p = asyncio.Protocol()
        self.assertIsNone(p.connection_made(f))
        self.assertIsNone(p.connection_lost(f))
        self.assertIsNone(p.data_received(f))

            

Reported by Pylint.

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

Line: 19 Column: 9

                      self.assertFalse(hasattr(p, '__dict__'))

    def test_protocol(self):
        f = mock.Mock()
        p = asyncio.Protocol()
        self.assertIsNone(p.connection_made(f))
        self.assertIsNone(p.connection_lost(f))
        self.assertIsNone(p.data_received(f))
        self.assertIsNone(p.eof_received())

            

Reported by Pylint.

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

Line: 20 Column: 9

              
    def test_protocol(self):
        f = mock.Mock()
        p = asyncio.Protocol()
        self.assertIsNone(p.connection_made(f))
        self.assertIsNone(p.connection_lost(f))
        self.assertIsNone(p.data_received(f))
        self.assertIsNone(p.eof_received())
        self.assertIsNone(p.pause_writing())

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 29 Column: 5

                      self.assertIsNone(p.resume_writing())
        self.assertFalse(hasattr(p, '__dict__'))

    def test_buffered_protocol(self):
        f = mock.Mock()
        p = asyncio.BufferedProtocol()
        self.assertIsNone(p.connection_made(f))
        self.assertIsNone(p.connection_lost(f))
        self.assertIsNone(p.get_buffer(100))

            

Reported by Pylint.

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

Line: 30 Column: 9

                      self.assertFalse(hasattr(p, '__dict__'))

    def test_buffered_protocol(self):
        f = mock.Mock()
        p = asyncio.BufferedProtocol()
        self.assertIsNone(p.connection_made(f))
        self.assertIsNone(p.connection_lost(f))
        self.assertIsNone(p.get_buffer(100))
        self.assertIsNone(p.buffer_updated(150))

            

Reported by Pylint.

Lib/test/test_importlib/frozen/test_finder.py
17 issues
Attempted relative import beyond top-level package
Error

Line: 1 Column: 1

              from .. import abc
from .. import util

machinery = util.import_importlib('importlib.machinery')

import unittest
import warnings



            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 2 Column: 1

              from .. import abc
from .. import util

machinery = util.import_importlib('importlib.machinery')

import unittest
import warnings



            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from .. import abc
from .. import util

machinery = util.import_importlib('importlib.machinery')

import unittest
import warnings



            

Reported by Pylint.

standard import "import unittest" should be placed before "from .. import abc"
Error

Line: 6 Column: 1

              
machinery = util.import_importlib('importlib.machinery')

import unittest
import warnings


class FindSpecTests(abc.FinderTests):


            

Reported by Pylint.

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

Line: 6 Column: 1

              
machinery = util.import_importlib('importlib.machinery')

import unittest
import warnings


class FindSpecTests(abc.FinderTests):


            

Reported by Pylint.

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

Line: 7 Column: 1

              machinery = util.import_importlib('importlib.machinery')

import unittest
import warnings


class FindSpecTests(abc.FinderTests):

    """Test finding frozen modules."""

            

Reported by Pylint.

standard import "import warnings" should be placed before "from .. import abc"
Error

Line: 7 Column: 1

              machinery = util.import_importlib('importlib.machinery')

import unittest
import warnings


class FindSpecTests(abc.FinderTests):

    """Test finding frozen modules."""

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 14 Column: 5

              
    """Test finding frozen modules."""

    def find(self, name, path=None):
        finder = self.machinery.FrozenImporter
        return finder.find_spec(name, path)

    def test_module(self):
        name = '__hello__'

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 18 Column: 5

                      finder = self.machinery.FrozenImporter
        return finder.find_spec(name, path)

    def test_module(self):
        name = '__hello__'
        spec = self.find(name)
        self.assertEqual(spec.origin, 'frozen')

    def test_package(self):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 23 Column: 5

                      spec = self.find(name)
        self.assertEqual(spec.origin, 'frozen')

    def test_package(self):
        spec = self.find('__phello__')
        self.assertIsNotNone(spec)

    def test_module_in_package(self):
        spec = self.find('__phello__.spam', ['__phello__'])

            

Reported by Pylint.

Lib/test/test_importlib/source/test_case_sensitivity.py
17 issues
Attempted relative import beyond top-level package
Error

Line: 4 Column: 1

              """Test case-sensitivity (PEP 235)."""
import sys

from .. import util

importlib = util.import_importlib('importlib')
machinery = util.import_importlib('importlib.machinery')

import os

            

Reported by Pylint.

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

Line: 9 Column: 1

              importlib = util.import_importlib('importlib')
machinery = util.import_importlib('importlib.machinery')

import os
from test.support import os_helper
import unittest
import warnings



            

Reported by Pylint.

standard import "import os" should be placed before "from .. import util"
Error

Line: 9 Column: 1

              importlib = util.import_importlib('importlib')
machinery = util.import_importlib('importlib.machinery')

import os
from test.support import os_helper
import unittest
import warnings



            

Reported by Pylint.

standard import "from test.support import os_helper" should be placed before "from .. import util"
Error

Line: 10 Column: 1

              machinery = util.import_importlib('importlib.machinery')

import os
from test.support import os_helper
import unittest
import warnings


@util.case_insensitive_tests

            

Reported by Pylint.

Import "from test.support import os_helper" should be placed at the top of the module
Error

Line: 10 Column: 1

              machinery = util.import_importlib('importlib.machinery')

import os
from test.support import os_helper
import unittest
import warnings


@util.case_insensitive_tests

            

Reported by Pylint.

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

Line: 11 Column: 1

              
import os
from test.support import os_helper
import unittest
import warnings


@util.case_insensitive_tests
class CaseSensitivityTest(util.CASEOKTestBase):

            

Reported by Pylint.

standard import "import unittest" should be placed before "from .. import util"
Error

Line: 11 Column: 1

              
import os
from test.support import os_helper
import unittest
import warnings


@util.case_insensitive_tests
class CaseSensitivityTest(util.CASEOKTestBase):

            

Reported by Pylint.

standard import "import warnings" should be placed before "from .. import util"
Error

Line: 12 Column: 1

              import os
from test.support import os_helper
import unittest
import warnings


@util.case_insensitive_tests
class CaseSensitivityTest(util.CASEOKTestBase):


            

Reported by Pylint.

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

Line: 12 Column: 1

              import os
from test.support import os_helper
import unittest
import warnings


@util.case_insensitive_tests
class CaseSensitivityTest(util.CASEOKTestBase):


            

Reported by Pylint.

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

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

                  variable is set."""

    name = 'MoDuLe'
    assert name != name.lower()

    def finder(self, path):
        return self.machinery.FileFinder(path,
                                      (self.machinery.SourceFileLoader,
                                            self.machinery.SOURCE_SUFFIXES),

            

Reported by Bandit.

Lib/test/support/threading_helper.py
17 issues
Access to a protected member _count of a client class
Error

Line: 24 Column: 12

              

def threading_setup():
    return _thread._count(), threading._dangling.copy()


def threading_cleanup(*original_values):
    _MAX_COUNT = 100


            

Reported by Pylint.

Access to a protected member _dangling of a client class
Error

Line: 24 Column: 30

              

def threading_setup():
    return _thread._count(), threading._dangling.copy()


def threading_cleanup(*original_values):
    _MAX_COUNT = 100


            

Reported by Pylint.

Access to a protected member _count of a client class
Error

Line: 31 Column: 18

                  _MAX_COUNT = 100

    for count in range(_MAX_COUNT):
        values = _thread._count(), threading._dangling
        if values == original_values:
            break

        if not count:
            # Display a warning at the first iteration

            

Reported by Pylint.

Access to a protected member _dangling of a client class
Error

Line: 31 Column: 36

                  _MAX_COUNT = 100

    for count in range(_MAX_COUNT):
        values = _thread._count(), threading._dangling
        if values == original_values:
            break

        if not count:
            # Display a warning at the first iteration

            

Reported by Pylint.

Access to a protected member _count of a client class
Error

Line: 85 Column: 17

                  """
    if timeout is None:
        timeout = support.SHORT_TIMEOUT
    old_count = _thread._count()
    try:
        yield
    finally:
        start_time = time.monotonic()
        deadline = start_time + timeout

            

Reported by Pylint.

Access to a protected member _count of a client class
Error

Line: 92 Column: 21

                      start_time = time.monotonic()
        deadline = start_time + timeout
        while True:
            count = _thread._count()
            if count <= old_count:
                break
            if time.monotonic() > deadline:
                dt = time.monotonic() - start_time
                msg = (f"wait_threads() failed to cleanup {count - old_count} "

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import _thread
import contextlib
import functools
import sys
import threading
import time

from test import support


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 23 Column: 1

              # at the end of a test run.


def threading_setup():
    return _thread._count(), threading._dangling.copy()


def threading_cleanup(*original_values):
    _MAX_COUNT = 100

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 27 Column: 1

                  return _thread._count(), threading._dangling.copy()


def threading_cleanup(*original_values):
    _MAX_COUNT = 100

    for count in range(_MAX_COUNT):
        values = _thread._count(), threading._dangling
        if values == original_values:

            

Reported by Pylint.

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

Line: 28 Column: 5

              

def threading_cleanup(*original_values):
    _MAX_COUNT = 100

    for count in range(_MAX_COUNT):
        values = _thread._count(), threading._dangling
        if values == original_values:
            break

            

Reported by Pylint.

Lib/sqlite3/dump.py
17 issues
Unused variable 'type'
Error

Line: 31 Column: 21

                          ORDER BY "name"
        """
    schema_res = cu.execute(q)
    for table_name, type, sql in schema_res.fetchall():
        if table_name == 'sqlite_sequence':
            yield('DELETE FROM "sqlite_sequence";')
        elif table_name == 'sqlite_stat1':
            yield('ANALYZE "sqlite_master";')
        elif table_name.startswith('sqlite_'):

            

Reported by Pylint.

Redefining built-in 'type'
Error

Line: 31 Column: 21

                          ORDER BY "name"
        """
    schema_res = cu.execute(q)
    for table_name, type, sql in schema_res.fetchall():
        if table_name == 'sqlite_sequence':
            yield('DELETE FROM "sqlite_sequence";')
        elif table_name == 'sqlite_stat1':
            yield('ANALYZE "sqlite_master";')
        elif table_name.startswith('sqlite_'):

            

Reported by Pylint.

Possible SQL injection vector through string-based query construction.
Security injection

Line: 52
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b608_hardcoded_sql_expressions.html

                      table_name_ident = table_name.replace('"', '""')
        res = cu.execute('PRAGMA table_info("{0}")'.format(table_name_ident))
        column_names = [str(table_info[1]) for table_info in res.fetchall()]
        q = """SELECT 'INSERT INTO "{0}" VALUES({1})' FROM "{0}";""".format(
            table_name_ident,
            ",".join("""'||quote("{0}")||'""".format(col.replace('"', '""')) for col in column_names))
        query_res = cu.execute(q)
        for row in query_res:
            yield("{0};".format(row[0]))

            

Reported by Bandit.

Unused variable 'name'
Error

Line: 67 Column: 9

                          "type" IN ('index', 'trigger', 'view')
        """
    schema_res = cu.execute(q)
    for name, type, sql in schema_res.fetchall():
        yield('{0};'.format(sql))

    yield('COMMIT;')

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # Mimic the sqlite3 console shell's .dump command
# Author: Paul Kippes <kippesp@gmail.com>

# Every identifier in sql is quoted based on a comment in sqlite
# documentation "SQLite adds new keywords from time to time when it
# takes on new features. So to prevent your code from being broken by
# future enhancements, you should normally quote any identifier that
# is an English language word, even if you do not have to."


            

Reported by Pylint.

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

Line: 19 Column: 5

                  directly but instead called from the Connection method, iterdump().
    """

    cu = connection.cursor()
    yield('BEGIN TRANSACTION;')

    # sqlite_master table contains the SQL CREATE statements for the database.
    q = """
        SELECT "name", "type", "sql"

            

Reported by Pylint.

Unnecessary parens after 'yield' keyword
Error

Line: 20 Column: 1

                  """

    cu = connection.cursor()
    yield('BEGIN TRANSACTION;')

    # sqlite_master table contains the SQL CREATE statements for the database.
    q = """
        SELECT "name", "type", "sql"
        FROM "sqlite_master"

            

Reported by Pylint.

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

Line: 23 Column: 5

                  yield('BEGIN TRANSACTION;')

    # sqlite_master table contains the SQL CREATE statements for the database.
    q = """
        SELECT "name", "type", "sql"
        FROM "sqlite_master"
            WHERE "sql" NOT NULL AND
            "type" == 'table'
            ORDER BY "name"

            

Reported by Pylint.

Unnecessary parens after 'yield' keyword
Error

Line: 33 Column: 1

                  schema_res = cu.execute(q)
    for table_name, type, sql in schema_res.fetchall():
        if table_name == 'sqlite_sequence':
            yield('DELETE FROM "sqlite_sequence";')
        elif table_name == 'sqlite_stat1':
            yield('ANALYZE "sqlite_master";')
        elif table_name.startswith('sqlite_'):
            continue
        # NOTE: Virtual table support not implemented

            

Reported by Pylint.

Unnecessary parens after 'yield' keyword
Error

Line: 35 Column: 1

                      if table_name == 'sqlite_sequence':
            yield('DELETE FROM "sqlite_sequence";')
        elif table_name == 'sqlite_stat1':
            yield('ANALYZE "sqlite_master";')
        elif table_name.startswith('sqlite_'):
            continue
        # NOTE: Virtual table support not implemented
        #elif sql.startswith('CREATE VIRTUAL TABLE'):
        #    qtable = table_name.replace("'", "''")

            

Reported by Pylint.