The following issues were found

Tools/c-analyzer/c_parser/parser/_global.py
16 issues
Attempted relative import beyond top-level package
Error

Line: 3 Column: 1

              import re

from ._regexes import (
    GLOBAL as _GLOBAL,
)
from ._common import (
    log_match,
    parse_var_decl,
    set_capture_groups,

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 6 Column: 1

              from ._regexes import (
    GLOBAL as _GLOBAL,
)
from ._common import (
    log_match,
    parse_var_decl,
    set_capture_groups,
)
from ._compound_decl_body import DECL_BODY_PARSERS

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 11 Column: 1

                  parse_var_decl,
    set_capture_groups,
)
from ._compound_decl_body import DECL_BODY_PARSERS
#from ._func_body import parse_function_body
from ._func_body import parse_function_statics as parse_function_body


GLOBAL = set_capture_groups(_GLOBAL, (

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 13 Column: 1

              )
from ._compound_decl_body import DECL_BODY_PARSERS
#from ._func_body import parse_function_body
from ._func_body import parse_function_statics as parse_function_body


GLOBAL = set_capture_groups(_GLOBAL, (
    'EMPTY',
    'COMPOUND_LEADING',

            

Reported by Pylint.

Else clause on loop without a break statement
Error

Line: 51 Column: 5

                          else:
                yield item
    else:
        # We ran out of lines.
        if srcinfo is not None:
            srcinfo.done()
        return



            

Reported by Pylint.

XXX Maybe return them too (with an "isforward" flag)?
Error

Line: 79 Column: 3

                  elif maybe_inline_actual:
        log_match('maybe_inline_actual', m)
        # Ignore forward declarations.
        # XXX Maybe return them too (with an "isforward" flag)?
        if not maybe_inline_actual.strip().endswith(';'):
            remainder = maybe_inline_actual + remainder
        yield srcinfo.resolve(forward_kind, None, forward_name)
        if maybe_inline_actual.strip().endswith('='):
            # We use a dummy prefix for a fake typedef.

            

Reported by Pylint.

XXX Ideally this case would not be caught by MAYBE_INLINE_ACTUAL.
Error

Line: 85 Column: 3

                      yield srcinfo.resolve(forward_kind, None, forward_name)
        if maybe_inline_actual.strip().endswith('='):
            # We use a dummy prefix for a fake typedef.
            # XXX Ideally this case would not be caught by MAYBE_INLINE_ACTUAL.
            _, name, data = parse_var_decl(f'{forward_kind} {forward_name} fake_typedef_{forward_name}')
            yield srcinfo.resolve('typedef', data, name, parent=None)
            remainder = f'{name} {remainder}'
        srcinfo.advance(remainder)


            

Reported by Pylint.

XXX Should "parent" really be None for inline type decls?
Error

Line: 113 Column: 3

                                  data.append(item)
                else:
                    yield item
            # XXX Should "parent" really be None for inline type decls?
            yield srcinfo.resolve(kind, data, name, parent=None)

            srcinfo.resume()
        yield parse_body


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import re

from ._regexes import (
    GLOBAL as _GLOBAL,
)
from ._common import (
    log_match,
    parse_var_decl,
    set_capture_groups,

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 38 Column: 1

              GLOBAL_RE = re.compile(rf'^ \s* {GLOBAL}', re.VERBOSE)


def parse_globals(source, anon_name):
    for srcinfo in source:
        m = GLOBAL_RE.match(srcinfo.text)
        if not m:
            # We need more text.
            continue

            

Reported by Pylint.

Tools/peg_generator/pegen/__main__.py
16 issues
Catching too general exception Exception
Error

Line: 41 Column: 12

                          skip_actions=args.skip_actions,
        )
        return grammar, parser, tokenizer, gen
    except Exception as err:
        if args.verbose:
            raise  # Show traceback
        traceback.print_exception(err.__class__, err, None)
        sys.stderr.write("For full traceback, use -v\n")
        sys.exit(1)

            

Reported by Pylint.

Catching too general exception Exception
Error

Line: 66 Column: 12

                          skip_actions=args.skip_actions,
        )
        return grammar, parser, tokenizer, gen
    except Exception as err:
        if args.verbose:
            raise  # Show traceback
        traceback.print_exception(err.__class__, err, None)
        sys.stderr.write("For full traceback, use -v\n")
        sys.exit(1)

            

Reported by Pylint.

Access to a protected member _tokens of a client class
Error

Line: 179 Column: 20

                      else:
            print()
        print("Caches sizes:")
        print(f"  token array : {len(tokenizer._tokens):10}")
        print(f"        cache : {len(parser._cache):10}")
        if not print_memstats():
            print("(Can't find psutil; install it for memory stats.)")



            

Reported by Pylint.

Access to a protected member _cache of a client class
Error

Line: 180 Column: 20

                          print()
        print("Caches sizes:")
        print(f"  token array : {len(tokenizer._tokens):10}")
        print(f"        cache : {len(parser._cache):10}")
        if not print_memstats():
            print("(Can't find psutil; install it for memory stats.)")


if __name__ == "__main__":

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 20 Column: 1

              from pegen.validator import validate_grammar


def generate_c_code(
    args: argparse.Namespace,
) -> Tuple[Grammar, Parser, Tokenizer, ParserGenerator]:
    from pegen.build import build_c_parser_and_generator

    verbose = args.verbose

            

Reported by Pylint.

Import outside toplevel (pegen.build.build_c_parser_and_generator)
Error

Line: 23 Column: 5

              def generate_c_code(
    args: argparse.Namespace,
) -> Tuple[Grammar, Parser, Tokenizer, ParserGenerator]:
    from pegen.build import build_c_parser_and_generator

    verbose = args.verbose
    verbose_tokenizer = verbose >= 3
    verbose_parser = verbose == 2 or verbose >= 4
    try:

            

Reported by Pylint.

The if expression can be replaced with 'not test'
Error

Line: 37 Column: 39

                          verbose_tokenizer,
            verbose_parser,
            args.verbose,
            keep_asserts_in_extension=False if args.optimized else True,
            skip_actions=args.skip_actions,
        )
        return grammar, parser, tokenizer, gen
    except Exception as err:
        if args.verbose:

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 49 Column: 1

                      sys.exit(1)


def generate_python_code(
    args: argparse.Namespace,
) -> Tuple[Grammar, Parser, Tokenizer, ParserGenerator]:
    from pegen.build import build_python_parser_and_generator

    verbose = args.verbose

            

Reported by Pylint.

Import outside toplevel (pegen.build.build_python_parser_and_generator)
Error

Line: 52 Column: 5

              def generate_python_code(
    args: argparse.Namespace,
) -> Tuple[Grammar, Parser, Tokenizer, ParserGenerator]:
    from pegen.build import build_python_parser_and_generator

    verbose = args.verbose
    verbose_tokenizer = verbose >= 3
    verbose_parser = verbose == 2 or verbose >= 4
    try:

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 125 Column: 1

              )


def main() -> None:
    from pegen.testutil import print_memstats

    args = argparser.parse_args()
    if "func" not in args:
        argparser.error("Must specify the target language mode ('c' or 'python')")

            

Reported by Pylint.

Lib/test/test_unicode_identifiers.py
16 issues
No name 'badsyntax_3131' in module 'test'
Error

Line: 22 Column: 13

              
    def test_invalid(self):
        try:
            from test import badsyntax_3131
        except SyntaxError as err:
            self.assertEqual(str(err),
              "invalid character '€' (U+20AC) (badsyntax_3131.py, line 2)")
            self.assertEqual(err.lineno, 2)
            self.assertEqual(err.offset, 1)

            

Reported by Pylint.

Unused variable 'Unicode'
Error

Line: 17 Column: 9

                      self.assertEqual(getattr(T, 'x\U000E0100'), 4)

    def test_non_bmp_normalized(self):
        𝔘𝔫𝔦𝔠𝔬𝔡𝔢 = 1
        self.assertIn("Unicode", dir())

    def test_invalid(self):
        try:
            from test import badsyntax_3131

            

Reported by Pylint.

Unused badsyntax_3131 imported from test
Error

Line: 22 Column: 13

              
    def test_invalid(self):
        try:
            from test import badsyntax_3131
        except SyntaxError as err:
            self.assertEqual(str(err),
              "invalid character '€' (U+20AC) (badsyntax_3131.py, line 2)")
            self.assertEqual(err.lineno, 2)
            self.assertEqual(err.offset, 1)

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import unittest

class PEP3131Test(unittest.TestCase):

    def test_valid(self):
        class T:
            ä = 1
            µ = 2 # this is a compatibility character
            蟒 = 3

            

Reported by Pylint.

Missing class docstring
Error

Line: 3 Column: 1

              import unittest

class PEP3131Test(unittest.TestCase):

    def test_valid(self):
        class T:
            ä = 1
            µ = 2 # this is a compatibility character
            蟒 = 3

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 5 Column: 5

              
class PEP3131Test(unittest.TestCase):

    def test_valid(self):
        class T:
            ä = 1
            µ = 2 # this is a compatibility character
            蟒 = 3
            x󠄀 = 4

            

Reported by Pylint.

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

Line: 6 Column: 9

              class PEP3131Test(unittest.TestCase):

    def test_valid(self):
        class T:
            ä = 1
            µ = 2 # this is a compatibility character
            蟒 = 3
            x󠄀 = 4
        self.assertEqual(getattr(T, "\xe4"), 1)

            

Reported by Pylint.

Too few public methods (0/2)
Error

Line: 6 Column: 9

              class PEP3131Test(unittest.TestCase):

    def test_valid(self):
        class T:
            ä = 1
            µ = 2 # this is a compatibility character
            蟒 = 3
            x󠄀 = 4
        self.assertEqual(getattr(T, "\xe4"), 1)

            

Reported by Pylint.

Missing class docstring
Error

Line: 6 Column: 9

              class PEP3131Test(unittest.TestCase):

    def test_valid(self):
        class T:
            ä = 1
            µ = 2 # this is a compatibility character
            蟒 = 3
            x󠄀 = 4
        self.assertEqual(getattr(T, "\xe4"), 1)

            

Reported by Pylint.

Class attribute name "ä" contains a non-ASCII unicode character
Error

Line: 7 Column: 13

              
    def test_valid(self):
        class T:
            ä = 1
            µ = 2 # this is a compatibility character
            蟒 = 3
            x󠄀 = 4
        self.assertEqual(getattr(T, "\xe4"), 1)
        self.assertEqual(getattr(T, "\u03bc"), 2)

            

Reported by Pylint.

Tools/c-analyzer/c_parser/parser/_common.py
16 issues
Attempted relative import beyond top-level package
Error

Line: 3 Column: 1

              import re

from ._regexes import (
    _ind,
    STRING_LITERAL,
    VAR_DECL as _VAR_DECL,
)



            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 11 Column: 5

              

def log_match(group, m):
    from . import _logger
    _logger.debug(f'matched <{group}> ({m.group(0)})')


#############################
# regex utils

            

Reported by Pylint.

Else clause on loop without a break statement
Error

Line: 61 Column: 5

                          depth -= 1
            if depth == 0:
                return pos
    else:
        raise ValueError(f'could not find matching parens for {text!r}')


VAR_DECL = set_capture_groups(_VAR_DECL, (
    'STORAGE',

            

Reported by Pylint.

XXX Drop this or use it!
Error

Line: 106 Column: 3

              #############################
# parser state utils

# XXX Drop this or use it!
def iter_results(results):
    if not results:
        return
    if callable(results):
        results = results()

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import re

from ._regexes import (
    _ind,
    STRING_LITERAL,
    VAR_DECL as _VAR_DECL,
)



            

Reported by Pylint.

Missing function or method docstring
Error

Line: 10 Column: 1

              )


def log_match(group, m):
    from . import _logger
    _logger.debug(f'matched <{group}> ({m.group(0)})')


#############################

            

Reported by Pylint.

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

Line: 10 Column: 1

              )


def log_match(group, m):
    from . import _logger
    _logger.debug(f'matched <{group}> ({m.group(0)})')


#############################

            

Reported by Pylint.

Import outside toplevel (._logger)
Error

Line: 11 Column: 5

              

def log_match(group, m):
    from . import _logger
    _logger.debug(f'matched <{group}> ({m.group(0)})')


#############################
# regex utils

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 18 Column: 1

              #############################
# regex utils

def set_capture_group(pattern, group, *, strict=True):
    old = f'(?:  # <{group}>'
    if strict and f'(?:  # <{group}>' not in pattern:
        raise ValueError(f'{old!r} not found in pattern')
    return pattern.replace(old, f'(  # <{group}>', 1)


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 25 Column: 1

                  return pattern.replace(old, f'(  # <{group}>', 1)


def set_capture_groups(pattern, groups, *, strict=True):
    for group in groups:
        pattern = set_capture_group(pattern, group, strict=strict)
    return pattern



            

Reported by Pylint.

Tools/importbench/importbench.py
16 issues
Unable to import 'test.test_importlib'
Error

Line: 7 Column: 1

              thus has no external changes made to import-related attributes in sys.

"""
from test.test_importlib import util
import decimal
import imp
import importlib
import importlib.machinery
import json

            

Reported by Pylint.

No name 'test_importlib' in module 'test'
Error

Line: 7 Column: 1

              thus has no external changes made to import-related attributes in sys.

"""
from test.test_importlib import util
import decimal
import imp
import importlib
import importlib.machinery
import json

            

Reported by Pylint.

Unused variable 'x'
Error

Line: 25 Column: 9

                  executions take one second."""
    stmt = "__import__({!r})".format(name)
    timer = timeit.Timer(stmt)
    for x in range(repeat):
        total_time = 0
        count = 0
        while total_time < seconds:
            try:
                total_time += timer.timeit(1)

            

Reported by Pylint.

Else clause on loop without a break statement
Error

Line: 35 Column: 9

                              cleanup()
            count += 1
        else:
            # One execution too far
            if total_time > seconds:
                count -= 1
        yield count // seconds

def from_cache(seconds, repeat):

            

Reported by Pylint.

Redefining name 'options' from outer scope (line 239)
Error

Line: 165 Column: 19

              decimal_using_bytecode = _using_bytecode(decimal)


def main(import_, options):
    if options.source_file:
        with options.source_file:
            prev_results = json.load(options.source_file)
    else:
        prev_results = {}

            

Reported by Pylint.

Redefining name 'import_' from outer scope (line 240)
Error

Line: 165 Column: 10

              decimal_using_bytecode = _using_bytecode(decimal)


def main(import_, options):
    if options.source_file:
        with options.source_file:
            prev_results = json.load(options.source_file)
    else:
        prev_results = {}

            

Reported by Pylint.

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

Line: 25 Column: 9

                  executions take one second."""
    stmt = "__import__({!r})".format(name)
    timer = timeit.Timer(stmt)
    for x in range(repeat):
        total_time = 0
        count = 0
        while total_time < seconds:
            try:
                total_time += timer.timeit(1)

            

Reported by Pylint.

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

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

                      name = '__importlib_test_benchmark__'
        # Clears out sys.modules and puts an entry at the front of sys.path.
        with util.create_modules(name) as mapping:
            assert not os.path.exists(imp.cache_from_source(mapping[name]))
            sys.meta_path.append(importlib.machinery.PathFinder)
            loader = (importlib.machinery.SourceFileLoader,
                      importlib.machinery.SOURCE_SUFFIXES)
            sys.path_hooks.append(importlib.machinery.FileFinder.path_hook(loader))
            yield from bench(name, lambda: sys.modules.pop(name), repeat=repeat,

            

Reported by Bandit.

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

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

              
def source_writing_bytecode(seconds, repeat):
    """Source writing bytecode: small"""
    assert not sys.dont_write_bytecode
    name = '__importlib_test_benchmark__'
    with util.create_modules(name) as mapping:
        sys.meta_path.append(importlib.machinery.PathFinder)
        loader = (importlib.machinery.SourceFileLoader,
                  importlib.machinery.SOURCE_SUFFIXES)

            

Reported by Bandit.

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

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

                          sys.modules.pop(name)
            os.unlink(imp.cache_from_source(mapping[name]))
        for result in bench(name, cleanup, repeat=repeat, seconds=seconds):
            assert not os.path.exists(imp.cache_from_source(mapping[name]))
            yield result


def _writing_bytecode(module):
    name = module.__name__

            

Reported by Bandit.

Lib/tkinter/test/test_tkinter/test_colorchooser.py
16 issues
Access to a protected member _fixoptions of a client class
Error

Line: 21 Column: 9

              
    def test_fixoptions(self):
        cc = self.cc
        cc._fixoptions()
        self.assertEqual(cc.options['initialcolor'], 'dark blue slate')

        cc.options['initialcolor'] = '#D2D269691E1E'
        cc._fixoptions()
        self.assertEqual(cc.options['initialcolor'], '#D2D269691E1E')

            

Reported by Pylint.

Access to a protected member _fixoptions of a client class
Error

Line: 25 Column: 9

                      self.assertEqual(cc.options['initialcolor'], 'dark blue slate')

        cc.options['initialcolor'] = '#D2D269691E1E'
        cc._fixoptions()
        self.assertEqual(cc.options['initialcolor'], '#D2D269691E1E')

        cc.options['initialcolor'] = (210, 105, 30)
        cc._fixoptions()
        self.assertEqual(cc.options['initialcolor'], '#d2691e')

            

Reported by Pylint.

Access to a protected member _fixoptions of a client class
Error

Line: 29 Column: 9

                      self.assertEqual(cc.options['initialcolor'], '#D2D269691E1E')

        cc.options['initialcolor'] = (210, 105, 30)
        cc._fixoptions()
        self.assertEqual(cc.options['initialcolor'], '#d2691e')

    def test_fixresult(self):
        cc = self.cc
        self.assertEqual(cc._fixresult(self.root, ()), (None, None))

            

Reported by Pylint.

Access to a protected member _fixresult of a client class
Error

Line: 34 Column: 26

              
    def test_fixresult(self):
        cc = self.cc
        self.assertEqual(cc._fixresult(self.root, ()), (None, None))
        self.assertEqual(cc._fixresult(self.root, ''), (None, None))
        self.assertEqual(cc._fixresult(self.root, 'chocolate'),
                         ((210, 105, 30), 'chocolate'))
        self.assertEqual(cc._fixresult(self.root, '#4a3c8c'),
                         ((74, 60, 140), '#4a3c8c'))

            

Reported by Pylint.

Access to a protected member _fixresult of a client class
Error

Line: 35 Column: 26

                  def test_fixresult(self):
        cc = self.cc
        self.assertEqual(cc._fixresult(self.root, ()), (None, None))
        self.assertEqual(cc._fixresult(self.root, ''), (None, None))
        self.assertEqual(cc._fixresult(self.root, 'chocolate'),
                         ((210, 105, 30), 'chocolate'))
        self.assertEqual(cc._fixresult(self.root, '#4a3c8c'),
                         ((74, 60, 140), '#4a3c8c'))


            

Reported by Pylint.

Access to a protected member _fixresult of a client class
Error

Line: 36 Column: 26

                      cc = self.cc
        self.assertEqual(cc._fixresult(self.root, ()), (None, None))
        self.assertEqual(cc._fixresult(self.root, ''), (None, None))
        self.assertEqual(cc._fixresult(self.root, 'chocolate'),
                         ((210, 105, 30), 'chocolate'))
        self.assertEqual(cc._fixresult(self.root, '#4a3c8c'),
                         ((74, 60, 140), '#4a3c8c'))



            

Reported by Pylint.

Access to a protected member _fixresult of a client class
Error

Line: 38 Column: 26

                      self.assertEqual(cc._fixresult(self.root, ''), (None, None))
        self.assertEqual(cc._fixresult(self.root, 'chocolate'),
                         ((210, 105, 30), 'chocolate'))
        self.assertEqual(cc._fixresult(self.root, '#4a3c8c'),
                         ((74, 60, 140), '#4a3c8c'))


class DefaultRootTest(AbstractDefaultRootTest, unittest.TestCase):


            

Reported by Pylint.

Unused argument 'dialog'
Error

Line: 45 Column: 27

              class DefaultRootTest(AbstractDefaultRootTest, unittest.TestCase):

    def test_askcolor(self):
        def test_callback(dialog, master):
            nonlocal ismapped
            master.update()
            ismapped = master.winfo_ismapped()
            raise ZeroDivisionError


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import unittest
import tkinter
from test.support import requires, run_unittest, swap_attr
from tkinter.test.support import AbstractDefaultRootTest, AbstractTkTest
from tkinter import colorchooser
from tkinter.colorchooser import askcolor
from tkinter.commondialog import Dialog

requires('gui')

            

Reported by Pylint.

Missing class docstring
Error

Line: 12 Column: 1

              requires('gui')


class ChooserTest(AbstractTkTest, unittest.TestCase):

    @classmethod
    def setUpClass(cls):
        AbstractTkTest.setUpClass.__func__(cls)
        cls.cc = colorchooser.Chooser(initialcolor='dark blue slate')

            

Reported by Pylint.

Lib/dbm/__init__.py
16 issues
Redefining built-in 'open'
Error

Line: 53 Column: 1

                  ndbm = None


def open(file, flag='r', mode=0o666):
    """Open or create database at path given by *file*.

    Optional argument *flag* can be 'r' (default) for read-only access, 'w'
    for read-write access of an existing database, 'c' for read-write access
    to a new or existing database, and 'n' for read-write access to a new

            

Reported by Pylint.

Using the global statement
Error

Line: 64 Column: 5

                  Note: 'r' and 'w' fail if the database doesn't exist; 'c' creates it
    only if it doesn't exist; and 'n' always creates a new database.
    """
    global _defaultmod
    if _defaultmod is None:
        for name in _names:
            try:
                mod = __import__(name, fromlist=['open'])
            except ImportError:

            

Reported by Pylint.

Redefining name 'filename' from outer scope (line 188)
Error

Line: 98 Column: 13

                  return mod.open(file, flag, mode)


def whichdb(filename):
    """Guess which db package to use to open a db file.

    Return values:

    - None if the database file can't be read;

            

Reported by Pylint.

Missing class docstring
Error

Line: 38 Column: 1

              import sys


class error(Exception):
    pass

_names = ['dbm.gnu', 'dbm.ndbm', 'dbm.dumb']
_defaultmod = None
_modules = {}

            

Reported by Pylint.

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

Line: 38 Column: 1

              import sys


class error(Exception):
    pass

_names = ['dbm.gnu', 'dbm.ndbm', 'dbm.dumb']
_defaultmod = None
_modules = {}

            

Reported by Pylint.

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

Line: 42 Column: 1

                  pass

_names = ['dbm.gnu', 'dbm.ndbm', 'dbm.dumb']
_defaultmod = None
_modules = {}

error = (error, OSError)

try:

            

Reported by Pylint.

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

Line: 64 Column: 5

                  Note: 'r' and 'w' fail if the database doesn't exist; 'c' creates it
    only if it doesn't exist; and 'n' always creates a new database.
    """
    global _defaultmod
    if _defaultmod is None:
        for name in _names:
            try:
                mod = __import__(name, fromlist=['open'])
            except ImportError:

            

Reported by Pylint.

Too many branches (13/12)
Error

Line: 98 Column: 1

                  return mod.open(file, flag, mode)


def whichdb(filename):
    """Guess which db package to use to open a db file.

    Return values:

    - None if the database file can't be read;

            

Reported by Pylint.

Too many return statements (10/6)
Error

Line: 98 Column: 1

                  return mod.open(file, flag, mode)


def whichdb(filename):
    """Guess which db package to use to open a db file.

    Return values:

    - None if the database file can't be read;

            

Reported by Pylint.

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

Line: 113 Column: 9

              
    # Check for ndbm first -- this has a .pag and a .dir file
    try:
        f = io.open(filename + ".pag", "rb")
        f.close()
        f = io.open(filename + ".dir", "rb")
        f.close()
        return "dbm.ndbm"
    except OSError:

            

Reported by Pylint.

Lib/curses/__init__.py
16 issues
function already defined line 13
Error

Line: 25 Column: 1

              # _curses module to the curses package's dictionary.  Don't do 'from
# curses import *' if you'll be needing the ACS_* constants.

def initscr():
    import _curses, curses
    # we call setupterm() here because it raises an error
    # instead of calling exit() in error cases.
    setupterm(term=_os.environ.get("TERM", "unknown"),
              fd=_sys.__stdout__.fileno())

            

Reported by Pylint.

function already defined line 13
Error

Line: 42 Column: 1

              # COLOR_PAIRS variables which are only available after start_color() is
# called.

def start_color():
    import _curses, curses
    retval = _curses.start_color()
    if hasattr(_curses, 'COLORS'):
        curses.COLORS = _curses.COLORS
    if hasattr(_curses, 'COLOR_PAIRS'):

            

Reported by Pylint.

Module '_curses' has no 'COLORS' member
Error

Line: 46 Column: 25

                  import _curses, curses
    retval = _curses.start_color()
    if hasattr(_curses, 'COLORS'):
        curses.COLORS = _curses.COLORS
    if hasattr(_curses, 'COLOR_PAIRS'):
        curses.COLOR_PAIRS = _curses.COLOR_PAIRS
    return retval

# Import Python has_key() implementation if _curses doesn't contain has_key()

            

Reported by Pylint.

Module '_curses' has no 'COLOR_PAIRS' member
Error

Line: 48 Column: 30

                  if hasattr(_curses, 'COLORS'):
        curses.COLORS = _curses.COLORS
    if hasattr(_curses, 'COLOR_PAIRS'):
        curses.COLOR_PAIRS = _curses.COLOR_PAIRS
    return retval

# Import Python has_key() implementation if _curses doesn't contain has_key()

try:

            

Reported by Pylint.

Unable to import '__init__.has_key'
Error

Line: 56 Column: 5

              try:
    has_key
except NameError:
    from .has_key import has_key

# Wrapper for the entire curses-based application.  Runs a function which
# should be the rest of your curses-based application.  If the application
# raises an exception, wrapper() will restore the terminal to a sane state so
# you can read the resulting traceback.

            

Reported by Pylint.

Redefining built-in 'filter'
Error

Line: 13 Column: 1

              
"""

from _curses import *
import os as _os
import sys as _sys

# Some constants, most notably the ACS_* ones, are only added to the C
# _curses module's dictionary after initscr() is called.  (Some

            

Reported by Pylint.

No exception type(s) specified
Error

Line: 91 Column: 9

                      # module -- the error return from C start_color() is ignorable.
        try:
            start_color()
        except:
            pass

        return func(stdscr, *args, **kwds)
    finally:
        # Set everything back to normal

            

Reported by Pylint.

standard import "import os as _os" should be placed before "from _curses import *"
Error

Line: 14 Column: 1

              """

from _curses import *
import os as _os
import sys as _sys

# Some constants, most notably the ACS_* ones, are only added to the C
# _curses module's dictionary after initscr() is called.  (Some
# versions of SGI's curses don't define values for those constants

            

Reported by Pylint.

standard import "import sys as _sys" should be placed before "from _curses import *"
Error

Line: 15 Column: 1

              
from _curses import *
import os as _os
import sys as _sys

# Some constants, most notably the ACS_* ones, are only added to the C
# _curses module's dictionary after initscr() is called.  (Some
# versions of SGI's curses don't define values for those constants
# until initscr() has been called.)  This wrapper function calls the

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 25 Column: 1

              # _curses module to the curses package's dictionary.  Don't do 'from
# curses import *' if you'll be needing the ACS_* constants.

def initscr():
    import _curses, curses
    # we call setupterm() here because it raises an error
    # instead of calling exit() in error cases.
    setupterm(term=_os.environ.get("TERM", "unknown"),
              fd=_sys.__stdout__.fileno())

            

Reported by Pylint.

Lib/idlelib/zoomheight.py
16 issues
Unused argument 'event'
Error

Line: 21 Column: 33

                      self.editwin = editwin
        self.top = self.editwin.top

    def zoom_height_event(self, event=None):
        zoomed = self.zoom_height()

        if zoomed is None:
            self.top.bell()
        else:

            

Reported by Pylint.

Unused variable 'y'
Error

Line: 36 Column: 27

                  def zoom_height(self):
        top = self.top

        width, height, x, y = get_window_geometry(top)

        if top.wm_state() != 'normal':
            # Can't zoom/restore window height for windows not in the 'normal'
            # state, e.g. maximized and full-screen windows.
            return None

            

Reported by Pylint.

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

Line: 74 Column: 17

                          except tkinter.TclError:
                # The 'zoomed' state is not supported by some esoteric WMs,
                # such as Xvfb.
                raise WmInfoGatheringError(
                    'Failed getting geometry of maximized windows, because ' +
                    'the "zoomed" window state is unavailable.')
            top.update()
            maxwidth, maxheight, maxx, maxy = get_window_geometry(top)
            if sys.platform == 'win32':

            

Reported by Pylint.

Unused variable 'maxwidth'
Error

Line: 78 Column: 13

                                  'Failed getting geometry of maximized windows, because ' +
                    'the "zoomed" window state is unavailable.')
            top.update()
            maxwidth, maxheight, maxx, maxy = get_window_geometry(top)
            if sys.platform == 'win32':
                # On Windows, the returned Y coordinate is the one before
                # maximizing, so we use 0 which is correct unless a user puts
                # their dock on the top of the screen (very rare).
                maxy = 0

            

Reported by Pylint.

Unused variable 'maxx'
Error

Line: 78 Column: 34

                                  'Failed getting geometry of maximized windows, because ' +
                    'the "zoomed" window state is unavailable.')
            top.update()
            maxwidth, maxheight, maxx, maxy = get_window_geometry(top)
            if sys.platform == 'win32':
                # On Windows, the returned Y coordinate is the one before
                # maximizing, so we use 0 which is correct unless a user puts
                # their dock on the top of the screen (very rare).
                maxy = 0

            

Reported by Pylint.

Missing class docstring
Error

Line: 8 Column: 1

              import tkinter


class WmInfoGatheringError(Exception):
    pass


class ZoomHeight:
    # Cached values for maximized window dimensions, one for each set

            

Reported by Pylint.

Missing class docstring
Error

Line: 12 Column: 1

                  pass


class ZoomHeight:
    # Cached values for maximized window dimensions, one for each set
    # of screen dimensions.
    _max_height_and_y_coords = {}

    def __init__(self, editwin):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 21 Column: 5

                      self.editwin = editwin
        self.top = self.editwin.top

    def zoom_height_event(self, event=None):
        zoomed = self.zoom_height()

        if zoomed is None:
            self.top.bell()
        else:

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 33 Column: 5

              
        return "break"

    def zoom_height(self):
        top = self.top

        width, height, x, y = get_window_geometry(top)

        if top.wm_state() != 'normal':

            

Reported by Pylint.

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

Line: 36 Column: 24

                  def zoom_height(self):
        top = self.top

        width, height, x, y = get_window_geometry(top)

        if top.wm_state() != 'normal':
            # Can't zoom/restore window height for windows not in the 'normal'
            # state, e.g. maximized and full-screen windows.
            return None

            

Reported by Pylint.

Lib/idlelib/idle_test/htest.py
16 issues
Non-mapping value test_kwds is used in a mapping context
Error

Line: 423 Column: 36

                      text.configure(state='disabled') # preserve read-only property

    def run_test(_=None):
        widget = callable_object(**test_kwds)
        try:
            print(widget.result)
        except AttributeError:
            pass


            

Reported by Pylint.

callable_object is not callable
Error

Line: 423 Column: 18

                      text.configure(state='disabled') # preserve read-only property

    def run_test(_=None):
        widget = callable_object(**test_kwds)
        try:
            print(widget.result)
        except AttributeError:
            pass


            

Reported by Pylint.

Unused import idlelib.pyshell
Error

Line: 68 Column: 1

              outwin.OutputWindow (indirectly being tested with grep test)
'''

import idlelib.pyshell  # Set Windows DPI awareness before Tk().
from importlib import import_module
import textwrap
import tkinter as tk
from tkinter.ttk import Scrollbar
tk.NoDefaultRoot()

            

Reported by Pylint.

TODO implement ^\; adding '<Control-Key-\\>' to function does not work.
Error

Line: 84 Column: 3

                         "are correctly displayed.\n [Close] to exit.",
    }

# TODO implement ^\; adding '<Control-Key-\\>' to function does not work.
_calltip_window_spec = {
    'file': 'calltip_w',
    'kwds': {},
    'msg': "Typing '(' should display a calltip.\n"
           "Typing ') should hide the calltip.\n"

            

Reported by Pylint.

TODO Improve message
Error

Line: 138 Column: 3

                         "changes made have persisted."
    }

# TODO Improve message
_dyn_option_menu_spec = {
    'file': 'dynoption',
    'kwds': {},
    'msg': "Select one of the many options in the 'old option set'.\n"
           "Click the button to change the option set.\n"

            

Reported by Pylint.

TODO edit wrapper
Error

Line: 147 Column: 3

                         "Select one of the many options in the 'new option set'."
    }

# TODO edit wrapper
_editor_window_spec = {
   'file': 'editor',
    'kwds': {},
    'msg': "Test editor functions of interest.\n"
           "Best to close editor first."

            

Reported by Pylint.

Unused variable 'callable_object'
Error

Line: 412 Column: 20

                      nonlocal test_name, callable_object, test_kwds
        if len(test_list) == 1:
            next_button.pack_forget()
        test_spec, callable_object = test_list.pop()
        test_kwds = test_spec['kwds']
        test_kwds['parent'] = root
        test_name.set('Test ' + test_spec['name'])

        text.configure(state='normal') # enable text editing

            

Reported by Pylint.

standard import "from importlib import import_module" should be placed before "import idlelib.pyshell"
Error

Line: 69 Column: 1

              '''

import idlelib.pyshell  # Set Windows DPI awareness before Tk().
from importlib import import_module
import textwrap
import tkinter as tk
from tkinter.ttk import Scrollbar
tk.NoDefaultRoot()


            

Reported by Pylint.

standard import "import textwrap" should be placed before "import idlelib.pyshell"
Error

Line: 70 Column: 1

              
import idlelib.pyshell  # Set Windows DPI awareness before Tk().
from importlib import import_module
import textwrap
import tkinter as tk
from tkinter.ttk import Scrollbar
tk.NoDefaultRoot()

AboutDialog_spec = {

            

Reported by Pylint.

standard import "import tkinter as tk" should be placed before "import idlelib.pyshell"
Error

Line: 71 Column: 1

              import idlelib.pyshell  # Set Windows DPI awareness before Tk().
from importlib import import_module
import textwrap
import tkinter as tk
from tkinter.ttk import Scrollbar
tk.NoDefaultRoot()

AboutDialog_spec = {
    'file': 'help_about',

            

Reported by Pylint.