The following issues were found

Lib/test/libregrtest/runtest_mp.py
58 issues
Cannot import 'traceback' due to syntax error 'invalid syntax (<unknown>, line 576)'
Error

Line: 11 Column: 1

              import sys
import threading
import time
import traceback
from typing import NamedTuple, NoReturn, Literal, Any

from test import support
from test.support import os_helper


            

Reported by Pylint.

Value 'tuple' is unsubscriptable
Error

Line: 49 Column: 39

                  return False


def parse_worker_args(worker_args) -> tuple[Namespace, str]:
    ns_dict, test_name = json.loads(worker_args)
    ns = Namespace(**ns_dict)
    return (ns, test_name)



            

Reported by Pylint.

Value 'tuple' is unsubscriptable
Error

Line: 123 Column: 15

              

ExcStr = str
QueueOutput = tuple[Literal[False], MultiprocessResult] | tuple[Literal[True], ExcStr]


class ExitThread(Exception):
    pass


            

Reported by Pylint.

Value 'tuple' is unsubscriptable
Error

Line: 123 Column: 59

              

ExcStr = str
QueueOutput = tuple[Literal[False], MultiprocessResult] | tuple[Literal[True], ExcStr]


class ExitThread(Exception):
    pass


            

Reported by Pylint.

Value 'tuple' is unsubscriptable
Error

Line: 204 Column: 47

                      test_result.duration_sec = time.monotonic() - self.start_time
        return MultiprocessResult(test_result, stdout, stderr, err_msg)

    def _run_process(self, test_name: str) -> tuple[int, str, str]:
        self.start_time = time.monotonic()

        self.current_test_name = test_name
        try:
            popen = run_test_in_subprocess(test_name, self.ns)

            

Reported by Pylint.

Value 'list' is unsubscriptable
Error

Line: 348 Column: 54

                              break


def get_running(workers: list[TestWorkerProcess]) -> list[TestWorkerProcess]:
    running = []
    for worker in workers:
        current_test_name = worker.current_test_name
        if not current_test_name:
            continue

            

Reported by Pylint.

Value 'list' is unsubscriptable
Error

Line: 348 Column: 26

                              break


def get_running(workers: list[TestWorkerProcess]) -> list[TestWorkerProcess]:
    running = []
    for worker in workers:
        current_test_name = worker.current_test_name
        if not current_test_name:
            continue

            

Reported by Pylint.

Value 'dict' is unsubscriptable
Error

Line: 493 Column: 34

              class EncodeTestResult(json.JSONEncoder):
    """Encode a TestResult (sub)class object into a JSON dict."""

    def default(self, o: Any) -> dict[str, Any]:
        if isinstance(o, TestResult):
            result = vars(o)
            result["__test_result__"] = o.__class__.__name__
            return result


            

Reported by Pylint.

Value 'dict' is unsubscriptable
Error

Line: 502 Column: 27

                      return super().default(o)


def decode_test_result(d: dict[str, Any]) -> TestResult | dict[str, Any]:
    """Decode a TestResult (sub)class object from a JSON dict."""

    if "__test_result__" not in d:
        return d


            

Reported by Pylint.

unsupported operand type(s) for |
Error

Line: 502 Column: 46

                      return super().default(o)


def decode_test_result(d: dict[str, Any]) -> TestResult | dict[str, Any]:
    """Decode a TestResult (sub)class object from a JSON dict."""

    if "__test_result__" not in d:
        return d


            

Reported by Pylint.

Lib/distutils/_msvccompiler.py
58 issues
Unable to import 'winreg'
Error

Line: 18 Column: 1

              
import os
import subprocess
import winreg

from distutils.errors import DistutilsExecError, DistutilsPlatformError, \
                             CompileError, LibError, LinkError
from distutils.ccompiler import CCompiler, gen_lib_options
from distutils import log

            

Reported by Pylint.

Unused argument 'plat_spec'
Error

Line: 95 Column: 21

                  'x86_arm64' : 'arm64'
}

def _find_vcvarsall(plat_spec):
    # bpo-38597: Removed vcruntime return value
    _, best_dir = _find_vc2017()

    if not best_dir:
        best_version, best_dir = _find_vc2015()

            

Reported by Pylint.

Unused variable 'best_version'
Error

Line: 100 Column: 9

                  _, best_dir = _find_vc2017()

    if not best_dir:
        best_version, best_dir = _find_vc2015()

    if not best_dir:
        log.debug("No suitable Visual C++ version found")
        return None, None


            

Reported by Pylint.

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

Line: 131 Column: 9

                      ).decode('utf-16le', errors='replace')
    except subprocess.CalledProcessError as exc:
        log.error(exc.output)
        raise DistutilsPlatformError("Error executing {}"
                .format(exc.cmd))

    env = {
        key.lower(): value
        for key, _, value in

            

Reported by Pylint.

Attribute '_paths' defined outside __init__
Error

Line: 225 Column: 9

                          raise DistutilsPlatformError("Unable to find a compatible "
                "Visual Studio installation.")

        self._paths = vc_env.get('path', '')
        paths = self._paths.split(os.pathsep)
        self.cc = _find_exe("cl.exe", paths)
        self.linker = _find_exe("link.exe", paths)
        self.lib = _find_exe("lib.exe", paths)
        self.rc = _find_exe("rc.exe", paths)   # resource compiler

            

Reported by Pylint.

Attribute 'cc' defined outside __init__
Error

Line: 227 Column: 9

              
        self._paths = vc_env.get('path', '')
        paths = self._paths.split(os.pathsep)
        self.cc = _find_exe("cl.exe", paths)
        self.linker = _find_exe("link.exe", paths)
        self.lib = _find_exe("lib.exe", paths)
        self.rc = _find_exe("rc.exe", paths)   # resource compiler
        self.mc = _find_exe("mc.exe", paths)   # message compiler
        self.mt = _find_exe("mt.exe", paths)   # message compiler

            

Reported by Pylint.

Attribute 'linker' defined outside __init__
Error

Line: 228 Column: 9

                      self._paths = vc_env.get('path', '')
        paths = self._paths.split(os.pathsep)
        self.cc = _find_exe("cl.exe", paths)
        self.linker = _find_exe("link.exe", paths)
        self.lib = _find_exe("lib.exe", paths)
        self.rc = _find_exe("rc.exe", paths)   # resource compiler
        self.mc = _find_exe("mc.exe", paths)   # message compiler
        self.mt = _find_exe("mt.exe", paths)   # message compiler


            

Reported by Pylint.

Attribute 'lib' defined outside __init__
Error

Line: 229 Column: 9

                      paths = self._paths.split(os.pathsep)
        self.cc = _find_exe("cl.exe", paths)
        self.linker = _find_exe("link.exe", paths)
        self.lib = _find_exe("lib.exe", paths)
        self.rc = _find_exe("rc.exe", paths)   # resource compiler
        self.mc = _find_exe("mc.exe", paths)   # message compiler
        self.mt = _find_exe("mt.exe", paths)   # message compiler

        for dir in vc_env.get('include', '').split(os.pathsep):

            

Reported by Pylint.

Attribute 'rc' defined outside __init__
Error

Line: 230 Column: 9

                      self.cc = _find_exe("cl.exe", paths)
        self.linker = _find_exe("link.exe", paths)
        self.lib = _find_exe("lib.exe", paths)
        self.rc = _find_exe("rc.exe", paths)   # resource compiler
        self.mc = _find_exe("mc.exe", paths)   # message compiler
        self.mt = _find_exe("mt.exe", paths)   # message compiler

        for dir in vc_env.get('include', '').split(os.pathsep):
            if dir:

            

Reported by Pylint.

Attribute 'mc' defined outside __init__
Error

Line: 231 Column: 9

                      self.linker = _find_exe("link.exe", paths)
        self.lib = _find_exe("lib.exe", paths)
        self.rc = _find_exe("rc.exe", paths)   # resource compiler
        self.mc = _find_exe("mc.exe", paths)   # message compiler
        self.mt = _find_exe("mt.exe", paths)   # message compiler

        for dir in vc_env.get('include', '').split(os.pathsep):
            if dir:
                self.add_include_dir(dir.rstrip(os.sep))

            

Reported by Pylint.

Lib/asyncio/sslproto.py
58 issues
Attempted relative import beyond top-level package
Error

Line: 8 Column: 1

              except ImportError:  # pragma: no cover
    ssl = None

from . import constants
from . import protocols
from . import transports
from .log import logger



            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 9 Column: 1

                  ssl = None

from . import constants
from . import protocols
from . import transports
from .log import logger


def _create_transport_context(server_side, server_hostname):

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 10 Column: 1

              
from . import constants
from . import protocols
from . import transports
from .log import logger


def _create_transport_context(server_side, server_hostname):
    if server_side:

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 11 Column: 1

              from . import constants
from . import protocols
from . import transports
from .log import logger


def _create_transport_context(server_side, server_hostname):
    if server_side:
        raise ValueError('Server side SSL needs a valid SSLContext')

            

Reported by Pylint.

Unused variable 'ssldata'
Error

Line: 153 Column: 9

                      unexpected.
        """
        self._incoming.write_eof()
        ssldata, appdata = self.feed_ssldata(b'')
        assert appdata == [] or appdata == [b'']

    def feed_ssldata(self, data, only_handshake=False):
        """Feed SSL record level data into the pipe.


            

Reported by Pylint.

Using a conditional statement with a constant value
Error

Line: 227 Column: 9

              
        # Check for record level data that needs to be sent back.
        # Happens for the initial handshake and renegotiations.
        if self._outgoing.pending:
            ssldata.append(self._outgoing.read())
        return (ssldata, appdata)

    def feed_appdata(self, data, offset=0):
        """Feed plaintext data into the pipe.

            

Reported by Pylint.

Using a conditional statement with a constant value
Error

Line: 276 Column: 13

                              self._need_ssldata = (exc_errno == ssl.SSL_ERROR_WANT_READ)

            # See if there's any record level data back for us.
            if self._outgoing.pending:
                ssldata.append(self._outgoing.read())
            if offset == len(view) or self._need_ssldata:
                break
        return (ssldata, offset)


            

Reported by Pylint.

Access to a protected member _FlowControlMixin of a client class
Error

Line: 283 Column: 29

                      return (ssldata, offset)


class _SSLProtocolTransport(transports._FlowControlMixin,
                            transports.Transport):

    _sendfile_compatible = constants._SendfileMode.FALLBACK

    def __init__(self, loop, ssl_protocol):

            

Reported by Pylint.

Access to a protected member _SendfileMode of a client class
Error

Line: 286 Column: 28

              class _SSLProtocolTransport(transports._FlowControlMixin,
                            transports.Transport):

    _sendfile_compatible = constants._SendfileMode.FALLBACK

    def __init__(self, loop, ssl_protocol):
        self._loop = loop
        # SSLProtocol instance
        self._ssl_protocol = ssl_protocol

            

Reported by Pylint.

Access to a protected member _get_extra_info of a client class
Error

Line: 296 Column: 16

              
    def get_extra_info(self, name, default=None):
        """Get optional transport information."""
        return self._ssl_protocol._get_extra_info(name, default)

    def set_protocol(self, protocol):
        self._ssl_protocol._set_app_protocol(protocol)

    def get_protocol(self):

            

Reported by Pylint.

Lib/test/test_json/test_fail.py
58 issues
Instance of 'TestFail' has no 'loads' member
Error

Line: 85 Column: 17

                      for idx, doc in enumerate(JSONDOCS):
            idx = idx + 1
            if idx in SKIPS:
                self.loads(doc)
                continue
            try:
                self.loads(doc)
            except self.JSONDecodeError:
                pass

            

Reported by Pylint.

Instance of 'TestFail' has no 'loads' member
Error

Line: 88 Column: 17

                              self.loads(doc)
                continue
            try:
                self.loads(doc)
            except self.JSONDecodeError:
                pass
            else:
                self.fail("Expected failure for fail{0}.json: {1!r}".format(idx, doc))


            

Reported by Pylint.

Instance of 'TestFail' has no 'JSONDecodeError' member
Error

Line: 89 Column: 20

                              continue
            try:
                self.loads(doc)
            except self.JSONDecodeError:
                pass
            else:
                self.fail("Expected failure for fail{0}.json: {1!r}".format(idx, doc))

    def test_non_string_keys_dict(self):

            

Reported by Pylint.

Instance of 'TestFail' has no 'fail' member
Error

Line: 92 Column: 17

                          except self.JSONDecodeError:
                pass
            else:
                self.fail("Expected failure for fail{0}.json: {1!r}".format(idx, doc))

    def test_non_string_keys_dict(self):
        data = {'a' : 1, (1, 2) : 2}
        with self.assertRaisesRegex(TypeError,
                'keys must be str, int, float, bool or None, not tuple'):

            

Reported by Pylint.

Instance of 'TestFail' has no 'assertRaisesRegex' member
Error

Line: 96 Column: 14

              
    def test_non_string_keys_dict(self):
        data = {'a' : 1, (1, 2) : 2}
        with self.assertRaisesRegex(TypeError,
                'keys must be str, int, float, bool or None, not tuple'):
            self.dumps(data)

    def test_not_serializable(self):
        import sys

            

Reported by Pylint.

Instance of 'TestFail' has no 'dumps' member
Error

Line: 98 Column: 13

                      data = {'a' : 1, (1, 2) : 2}
        with self.assertRaisesRegex(TypeError,
                'keys must be str, int, float, bool or None, not tuple'):
            self.dumps(data)

    def test_not_serializable(self):
        import sys
        with self.assertRaisesRegex(TypeError,
                'Object of type module is not JSON serializable'):

            

Reported by Pylint.

Instance of 'TestFail' has no 'assertRaisesRegex' member
Error

Line: 102 Column: 14

              
    def test_not_serializable(self):
        import sys
        with self.assertRaisesRegex(TypeError,
                'Object of type module is not JSON serializable'):
            self.dumps(sys)

    def test_truncated_input(self):
        test_cases = [

            

Reported by Pylint.

Instance of 'TestFail' has no 'dumps' member
Error

Line: 104 Column: 13

                      import sys
        with self.assertRaisesRegex(TypeError,
                'Object of type module is not JSON serializable'):
            self.dumps(sys)

    def test_truncated_input(self):
        test_cases = [
            ('', 'Expecting value', 0),
            ('[', 'Expecting value', 1),

            

Reported by Pylint.

Instance of 'TestFail' has no 'assertRaises' member
Error

Line: 129 Column: 18

                          ('"spam', 'Unterminated string starting at', 0),
        ]
        for data, msg, idx in test_cases:
            with self.assertRaises(self.JSONDecodeError) as cm:
                self.loads(data)
            err = cm.exception
            self.assertEqual(err.msg, msg)
            self.assertEqual(err.pos, idx)
            self.assertEqual(err.lineno, 1)

            

Reported by Pylint.

Instance of 'TestFail' has no 'JSONDecodeError' member
Error

Line: 129 Column: 36

                          ('"spam', 'Unterminated string starting at', 0),
        ]
        for data, msg, idx in test_cases:
            with self.assertRaises(self.JSONDecodeError) as cm:
                self.loads(data)
            err = cm.exception
            self.assertEqual(err.msg, msg)
            self.assertEqual(err.pos, idx)
            self.assertEqual(err.lineno, 1)

            

Reported by Pylint.

Lib/test/test_importlib/extension/test_loader.py
58 issues
Attempted relative import beyond top-level package
Error

Line: 2 Column: 1

              from warnings import catch_warnings
from .. import abc
from .. import util

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

import os.path
import sys
import types

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 3 Column: 1

              from warnings import catch_warnings
from .. import abc
from .. import util

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

import os.path
import sys
import types

            

Reported by Pylint.

Unused catch_warnings imported from warnings
Error

Line: 1 Column: 1

              from warnings import catch_warnings
from .. import abc
from .. import util

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

import os.path
import sys
import types

            

Reported by Pylint.

Unused assert_python_failure imported from test.support.script_helper
Error

Line: 14 Column: 1

              import warnings
import importlib.util
import importlib
from test.support.script_helper import assert_python_failure

class LoaderTests(abc.LoaderTests):

    """Test load_module() for extension modules."""


            

Reported by Pylint.

Unused variable 'finder'
Error

Line: 96 Column: 9

              
    def setUp(self):
        self.name = '_testmultiphase'
        finder = self.machinery.FileFinder(None)
        self.spec = importlib.util.find_spec(self.name)
        assert self.spec
        self.loader = self.machinery.ExtensionFileLoader(
            self.name, self.spec.origin)


            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 135 Column: 17

                                              ('__package__', '')]:
                self.assertEqual(getattr(module, attr), value)
            with self.assertRaises(AttributeError):
                module.__path__
            self.assertIs(module, sys.modules[self.name])
            self.assertIsInstance(module.__loader__,
                                  self.machinery.ExtensionFileLoader)

    def test_functionality(self):

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 149 Column: 17

                          self.assertEqual(ex.demo('abcd'), 'abcd')
            self.assertEqual(ex.demo(), None)
            with self.assertRaises(AttributeError):
                ex.abc
            ex.abc = 0
            self.assertEqual(ex.abc, 0)
            self.assertEqual(module.foo(9, 9), 18)
            self.assertIsInstance(module.Str(), str)
            self.assertEqual(module.Str(1) + '23', '123')

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from warnings import catch_warnings
from .. import abc
from .. import util

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

import os.path
import sys
import types

            

Reported by Pylint.

standard import "import os.path" should be placed before "from .. import abc"
Error

Line: 7 Column: 1

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

import os.path
import sys
import types
import unittest
import warnings
import importlib.util

            

Reported by Pylint.

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

Line: 7 Column: 1

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

import os.path
import sys
import types
import unittest
import warnings
import importlib.util

            

Reported by Pylint.

Lib/lib2to3/fixer_util.py
58 issues
Attempted relative import beyond top-level package
Error

Line: 5 Column: 1

              # Author: Collin Winter

# Local imports
from .pgen2 import token
from .pytree import Leaf, Node
from .pygram import python_symbols as syms
from . import patcomp



            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 6 Column: 1

              
# Local imports
from .pgen2 import token
from .pytree import Leaf, Node
from .pygram import python_symbols as syms
from . import patcomp


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

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 7 Column: 1

              # Local imports
from .pgen2 import token
from .pytree import Leaf, Node
from .pygram import python_symbols as syms
from . import patcomp


###########################################################
### Common node-construction "macros"

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 8 Column: 1

              from .pgen2 import token
from .pytree import Leaf, Node
from .pygram import python_symbols as syms
from . import patcomp


###########################################################
### Common node-construction "macros"
###########################################################

            

Reported by Pylint.

XXX: May not handle dotted imports properly (eg, package_name='foo.bar')
Error

Line: 114 Column: 3

              def FromImport(package_name, name_leafs):
    """ Return an import statement in the form:
        from package import name_leafs"""
    # XXX: May not handle dotted imports properly (eg, package_name='foo.bar')
    #assert package_name == '.' or '.' not in package_name, "FromImport has "\
    #       "not been tested with dotted package names -- use at your own "\
    #       "peril!"

    for leaf in name_leafs:

            

Reported by Pylint.

Redefining built-in 'next'
Error

Line: 205 Column: 5

                  Yields:
        Each successive object in the chain.
    """
    next = getattr(obj, attr)
    while next:
        yield next
        next = getattr(next, attr)

p0 = """for_stmt< 'for' any 'in' node=any ':' any* >

            

Reported by Pylint.

Using the global statement
Error

Line: 235 Column: 5

                      or an iterator).
        See test_map_nochange in test_fixers.py for some examples and tests.
        """
    global p0, p1, p2, pats_built
    if not pats_built:
        p0 = patcomp.compile_pattern(p0)
        p1 = patcomp.compile_pattern(p1)
        p2 = patcomp.compile_pattern(p2)
        pats_built = True

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 15 Column: 1

              ### Common node-construction "macros"
###########################################################

def KeywordArg(keyword, value):
    return Node(syms.argument,
                [keyword, Leaf(token.EQUAL, "="), value])

def LParen():
    return Leaf(token.LPAR, "(")

            

Reported by Pylint.

Function name "KeywordArg" doesn't conform to snake_case naming style
Error

Line: 15 Column: 1

              ### Common node-construction "macros"
###########################################################

def KeywordArg(keyword, value):
    return Node(syms.argument,
                [keyword, Leaf(token.EQUAL, "="), value])

def LParen():
    return Leaf(token.LPAR, "(")

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 19 Column: 1

                  return Node(syms.argument,
                [keyword, Leaf(token.EQUAL, "="), value])

def LParen():
    return Leaf(token.LPAR, "(")

def RParen():
    return Leaf(token.RPAR, ")")


            

Reported by Pylint.

Lib/unittest/test/testmock/testsealable.py
58 issues
m.test is not callable
Error

Line: 18 Column: 31

                      m = mock.Mock()

        self.assertIsInstance(m.test, mock.Mock)
        self.assertIsInstance(m.test(), mock.Mock)
        self.assertIsInstance(m.test().test2(), mock.Mock)

    def test_new_attributes_cannot_be_accessed_on_seal(self):
        m = mock.Mock()


            

Reported by Pylint.

m.test is not callable
Error

Line: 19 Column: 31

              
        self.assertIsInstance(m.test, mock.Mock)
        self.assertIsInstance(m.test(), mock.Mock)
        self.assertIsInstance(m.test().test2(), mock.Mock)

    def test_new_attributes_cannot_be_accessed_on_seal(self):
        m = mock.Mock()

        mock.seal(m)

            

Reported by Pylint.

Instance of 'int' has no 'test2' member
Error

Line: 43 Column: 26

              
        mock.seal(m)
        m.test.test2 = 2
        self.assertEqual(m.test.test2, 2)

    def test_new_attributes_cannot_be_set_on_child_of_seal(self):
        m = mock.Mock()
        m.test.test2 = 1


            

Reported by Pylint.

m.test is not callable
Error

Line: 59 Column: 26

                      m.test.return_value = 3

        mock.seal(m)
        self.assertEqual(m.test(), 3)

    def test_initialized_attributes_allowed_after_seal(self):
        m = mock.Mock(test_value=1)

        mock.seal(m)

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 26 Column: 13

              
        mock.seal(m)
        with self.assertRaises(AttributeError):
            m.test
        with self.assertRaises(AttributeError):
            m()

    def test_new_attributes_cannot_be_set_on_seal(self):
        m = mock.Mock()

            

Reported by Pylint.

Expression "m.test1.test2().test4" is assigned to nothing
Error

Line: 88 Column: 13

                      mock.seal(m)
        self.assertEqual(m.test1.test2().test3, 4)
        with self.assertRaises(AttributeError):
            m.test1.test2().test4
        with self.assertRaises(AttributeError):
            m.test1.test3

    def test_seals_recurse_on_magic_methods(self):
        m = mock.MagicMock()

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 90 Column: 13

                      with self.assertRaises(AttributeError):
            m.test1.test2().test4
        with self.assertRaises(AttributeError):
            m.test1.test3

    def test_seals_recurse_on_magic_methods(self):
        m = mock.MagicMock()

        m.test1.test2["a"].test3 = 4

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 102 Column: 13

                      self.assertEqual(m.test1.test2["a"].test3, 4)
        self.assertEqual(m.test1.test2[2:5].test3, 4)
        with self.assertRaises(AttributeError):
            m.test1.test2["a"].test4
        with self.assertRaises(AttributeError):
            m.test1.test3[2:5].test4

    def test_seals_dont_recurse_on_manual_attributes(self):
        m = mock.Mock(name="root_mock")

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 104 Column: 13

                      with self.assertRaises(AttributeError):
            m.test1.test2["a"].test4
        with self.assertRaises(AttributeError):
            m.test1.test3[2:5].test4

    def test_seals_dont_recurse_on_manual_attributes(self):
        m = mock.Mock(name="root_mock")

        m.test1.test2 = mock.Mock(name="not_sealed")

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 114 Column: 9

              
        mock.seal(m)
        self.assertEqual(m.test1.test2.test3, 4)
        m.test1.test2.test4  # Does not raise
        m.test1.test2.test4 = 1  # Does not raise

    def test_integration_with_spec_att_definition(self):
        """You are not restricted when using mock with spec"""
        m = mock.Mock(SampleObject)

            

Reported by Pylint.

Lib/test/test_email/test_utils.py
58 issues
XXX: Need a more robust test for Olson's tzdata
Error

Line: 136 Column: 3

                      t2 = utils.localtime(t0.replace(tzinfo=None))
        self.assertEqual(t1, t2)

    # XXX: Need a more robust test for Olson's tzdata
    @unittest.skipIf(sys.platform.startswith('win'),
                     "Windows does not use Olson's TZ database")
    @unittest.skipUnless(os.path.exists('/usr/share/zoneinfo') or
                         os.path.exists('/usr/lib/zoneinfo'),
                         "Can't find the Olson's TZ database")

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import datetime
from email import utils
import test.support
import time
import unittest
import sys
import os.path

class DateTimeTests(unittest.TestCase):

            

Reported by Pylint.

Missing class docstring
Error

Line: 9 Column: 1

              import sys
import os.path

class DateTimeTests(unittest.TestCase):

    datestring = 'Sun, 23 Sep 2001 20:10:55'
    dateargs = (2001, 9, 23, 20, 10, 55)
    offsetstring = ' -0700'
    utcoffset = datetime.timedelta(hours=-7)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 19 Column: 5

                  naive_dt = datetime.datetime(*dateargs)
    aware_dt = datetime.datetime(*dateargs, tzinfo=tz)

    def test_naive_datetime(self):
        self.assertEqual(utils.format_datetime(self.naive_dt),
                         self.datestring + ' -0000')

    def test_aware_datetime(self):
        self.assertEqual(utils.format_datetime(self.aware_dt),

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 23 Column: 5

                      self.assertEqual(utils.format_datetime(self.naive_dt),
                         self.datestring + ' -0000')

    def test_aware_datetime(self):
        self.assertEqual(utils.format_datetime(self.aware_dt),
                         self.datestring + self.offsetstring)

    def test_usegmt(self):
        utc_dt = datetime.datetime(*self.dateargs,

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 27 Column: 5

                      self.assertEqual(utils.format_datetime(self.aware_dt),
                         self.datestring + self.offsetstring)

    def test_usegmt(self):
        utc_dt = datetime.datetime(*self.dateargs,
                                   tzinfo=datetime.timezone.utc)
        self.assertEqual(utils.format_datetime(utc_dt, usegmt=True),
                         self.datestring + ' GMT')


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 33 Column: 5

                      self.assertEqual(utils.format_datetime(utc_dt, usegmt=True),
                         self.datestring + ' GMT')

    def test_usegmt_with_naive_datetime_raises(self):
        with self.assertRaises(ValueError):
            utils.format_datetime(self.naive_dt, usegmt=True)

    def test_usegmt_with_non_utc_datetime_raises(self):
        with self.assertRaises(ValueError):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 37 Column: 5

                      with self.assertRaises(ValueError):
            utils.format_datetime(self.naive_dt, usegmt=True)

    def test_usegmt_with_non_utc_datetime_raises(self):
        with self.assertRaises(ValueError):
            utils.format_datetime(self.aware_dt, usegmt=True)

    def test_parsedate_to_datetime(self):
        self.assertEqual(

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 41 Column: 5

                      with self.assertRaises(ValueError):
            utils.format_datetime(self.aware_dt, usegmt=True)

    def test_parsedate_to_datetime(self):
        self.assertEqual(
            utils.parsedate_to_datetime(self.datestring + self.offsetstring),
            self.aware_dt)

    def test_parsedate_to_datetime_naive(self):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 46 Column: 5

                          utils.parsedate_to_datetime(self.datestring + self.offsetstring),
            self.aware_dt)

    def test_parsedate_to_datetime_naive(self):
        self.assertEqual(
            utils.parsedate_to_datetime(self.datestring + ' -0000'),
            self.naive_dt)

    def test_parsedate_to_datetime_with_invalid_raises_valueerror(self):

            

Reported by Pylint.

Lib/idlelib/idle_test/test_hyperparser.py
58 issues
Access to a protected member _build_char_in_string_func of a client class
Error

Line: 17 Column: 34

                      self.prompt_last_line = '>>>'
        self.num_context_lines = 50, 500, 1000

    _build_char_in_string_func = EditorWindow._build_char_in_string_func
    is_char_in_string = EditorWindow.is_char_in_string


class HyperParserTest(unittest.TestCase):
    code = (

            

Reported by Pylint.

Access to a protected member _eat_identifier of a client class
Error

Line: 205 Column: 22

              
    def test_eat_identifier(self):
        def is_valid_id(candidate):
            result = HyperParser._eat_identifier(candidate, 0, len(candidate))
            if result == len(candidate):
                return True
            elif result == 0:
                return False
            else:

            

Reported by Pylint.

Access to a protected member _eat_identifier of a client class
Error

Line: 246 Column: 26

                      self.assertFalse(is_valid_id('a²'))

        # valid identifier after "punctuation"
        self.assertEqual(HyperParser._eat_identifier('+ var', 0, 5), len('var'))
        self.assertEqual(HyperParser._eat_identifier('+var', 0, 4), len('var'))
        self.assertEqual(HyperParser._eat_identifier('.var', 0, 4), len('var'))

        # invalid identifiers
        self.assertFalse(is_valid_id('+'))

            

Reported by Pylint.

Access to a protected member _eat_identifier of a client class
Error

Line: 247 Column: 26

              
        # valid identifier after "punctuation"
        self.assertEqual(HyperParser._eat_identifier('+ var', 0, 5), len('var'))
        self.assertEqual(HyperParser._eat_identifier('+var', 0, 4), len('var'))
        self.assertEqual(HyperParser._eat_identifier('.var', 0, 4), len('var'))

        # invalid identifiers
        self.assertFalse(is_valid_id('+'))
        self.assertFalse(is_valid_id(' '))

            

Reported by Pylint.

Access to a protected member _eat_identifier of a client class
Error

Line: 248 Column: 26

                      # valid identifier after "punctuation"
        self.assertEqual(HyperParser._eat_identifier('+ var', 0, 5), len('var'))
        self.assertEqual(HyperParser._eat_identifier('+var', 0, 4), len('var'))
        self.assertEqual(HyperParser._eat_identifier('.var', 0, 4), len('var'))

        # invalid identifiers
        self.assertFalse(is_valid_id('+'))
        self.assertFalse(is_valid_id(' '))
        self.assertFalse(is_valid_id(':'))

            

Reported by Pylint.

Access to a protected member _eat_identifier of a client class
Error

Line: 261 Column: 18

                      self.assertFalse(is_valid_id('"a string"'))

    def test_eat_identifier_various_lengths(self):
        eat_id = HyperParser._eat_identifier

        for length in range(1, 21):
            self.assertEqual(eat_id('a' * length, 0, length), length)
            self.assertEqual(eat_id('é' * length, 0, length), length)
            self.assertEqual(eat_id('a' + '2' * (length - 1), 0, length), length)

            

Reported by Pylint.

standard import "import unittest" should be placed before "from idlelib.hyperparser import HyperParser"
Error

Line: 4 Column: 1

              "Test hyperparser, coverage 98%."

from idlelib.hyperparser import HyperParser
import unittest
from test.support import requires
from tkinter import Tk, Text
from idlelib.editor import EditorWindow

class DummyEditwin:

            

Reported by Pylint.

standard import "from test.support import requires" should be placed before "from idlelib.hyperparser import HyperParser"
Error

Line: 5 Column: 1

              
from idlelib.hyperparser import HyperParser
import unittest
from test.support import requires
from tkinter import Tk, Text
from idlelib.editor import EditorWindow

class DummyEditwin:
    def __init__(self, text):

            

Reported by Pylint.

standard import "from tkinter import Tk, Text" should be placed before "from idlelib.hyperparser import HyperParser"
Error

Line: 6 Column: 1

              from idlelib.hyperparser import HyperParser
import unittest
from test.support import requires
from tkinter import Tk, Text
from idlelib.editor import EditorWindow

class DummyEditwin:
    def __init__(self, text):
        self.text = text

            

Reported by Pylint.

Missing class docstring
Error

Line: 9 Column: 1

              from tkinter import Tk, Text
from idlelib.editor import EditorWindow

class DummyEditwin:
    def __init__(self, text):
        self.text = text
        self.indentwidth = 8
        self.tabwidth = 8
        self.prompt_last_line = '>>>'

            

Reported by Pylint.

Lib/idlelib/idle_test/test_colorizer.py
58 issues
Unused argument 'mock_notify'
Error

Line: 377 Column: 36

                      self.assertIsNone(color.after_id)

    @mock.patch.object(colorizer.ColorDelegator, 'notify_range')
    def test_recolorize_main(self, mock_notify):
        text = self.text
        color = self.color
        eq = self.assertEqual

        text.insert('insert', source)

            

Reported by Pylint.

Redefining name 'source' from outer scope (line 23)
Error

Line: 438 Column: 36

                      eq(text.tag_nextrange('SYNC', '8.0'), ('8.26', '9.0'))
        eq(text.tag_nextrange('SYNC', '30.0'), ('30.10', '32.0'))

    def _assert_highlighting(self, source, tag_ranges):
        """Check highlighting of a given piece of code.

        This inserts just this code into the Text widget. It will then
        check that the resulting highlighting tag ranges exactly match
        those described in the given `tag_ranges` dict.

            

Reported by Pylint.

Redefining name 'source' from outer scope (line 23)
Error

Line: 545 Column: 9

                                                                        ('1.5', '1.6')]})

    def test_long_multiline_string(self):
        source = textwrap.dedent('''\
            """a
            b
            c
            d
            e"""

            

Reported by Pylint.

Unused argument 'mock_recolorize'
Error

Line: 601 Column: 46

              
    @mock.patch.object(colorizer.ColorDelegator, 'recolorize')
    @mock.patch.object(colorizer.ColorDelegator, 'notify_range')
    def test_removecolors(self, mock_notify, mock_recolorize):
        text = self.text
        color = self.color
        text.insert('insert', source)

        color.recolorize_main()

            

Reported by Pylint.

Unused argument 'mock_notify'
Error

Line: 601 Column: 33

              
    @mock.patch.object(colorizer.ColorDelegator, 'recolorize')
    @mock.patch.object(colorizer.ColorDelegator, 'notify_range')
    def test_removecolors(self, mock_notify, mock_recolorize):
        text = self.text
        color = self.color
        text.insert('insert', source)

        color.recolorize_main()

            

Reported by Pylint.

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

Line: 3 Column: 1

              "Test colorizer, coverage 99%."
from idlelib import colorizer
from test.support import requires
import unittest
from unittest import mock
from idlelib.idle_test.tkinter_testing_utils import run_in_tk_mainloop

from functools import partial
import textwrap

            

Reported by Pylint.

standard import "import unittest" should be placed before "from idlelib import colorizer"
Error

Line: 4 Column: 1

              "Test colorizer, coverage 99%."
from idlelib import colorizer
from test.support import requires
import unittest
from unittest import mock
from idlelib.idle_test.tkinter_testing_utils import run_in_tk_mainloop

from functools import partial
import textwrap

            

Reported by Pylint.

standard import "from unittest import mock" should be placed before "from idlelib import colorizer"
Error

Line: 5 Column: 1

              from idlelib import colorizer
from test.support import requires
import unittest
from unittest import mock
from idlelib.idle_test.tkinter_testing_utils import run_in_tk_mainloop

from functools import partial
import textwrap
from tkinter import Tk, Text

            

Reported by Pylint.

standard import "from functools import partial" should be placed before "from idlelib import colorizer"
Error

Line: 8 Column: 1

              from unittest import mock
from idlelib.idle_test.tkinter_testing_utils import run_in_tk_mainloop

from functools import partial
import textwrap
from tkinter import Tk, Text
from idlelib import config
from idlelib.percolator import Percolator


            

Reported by Pylint.

standard import "import textwrap" should be placed before "from idlelib import colorizer"
Error

Line: 9 Column: 1

              from idlelib.idle_test.tkinter_testing_utils import run_in_tk_mainloop

from functools import partial
import textwrap
from tkinter import Tk, Text
from idlelib import config
from idlelib.percolator import Percolator



            

Reported by Pylint.