The following issues were found

Lib/unittest/test/_test_warnings.py
18 issues
Using deprecated method assertEquals()
Error

Line: 24 Column: 9

                  # unittest warnings will be printed at most once per type (max one message
    # for the fail* methods, and one for the assert* methods)
    def test_assert(self):
        self.assertEquals(2+2, 4)
        self.assertEquals(2*2, 4)
        self.assertEquals(2**2, 4)

    def test_fail(self):
        self.failUnless(1)

            

Reported by Pylint.

Using deprecated method assertEquals()
Error

Line: 25 Column: 9

                  # for the fail* methods, and one for the assert* methods)
    def test_assert(self):
        self.assertEquals(2+2, 4)
        self.assertEquals(2*2, 4)
        self.assertEquals(2**2, 4)

    def test_fail(self):
        self.failUnless(1)
        self.failUnless(True)

            

Reported by Pylint.

Using deprecated method assertEquals()
Error

Line: 26 Column: 9

                  def test_assert(self):
        self.assertEquals(2+2, 4)
        self.assertEquals(2*2, 4)
        self.assertEquals(2**2, 4)

    def test_fail(self):
        self.failUnless(1)
        self.failUnless(True)


            

Reported by Pylint.

Using deprecated method failUnless()
Error

Line: 29 Column: 9

                      self.assertEquals(2**2, 4)

    def test_fail(self):
        self.failUnless(1)
        self.failUnless(True)

    def test_other_unittest(self):
        self.assertAlmostEqual(2+2, 4)
        self.assertNotAlmostEqual(4+4, 2)

            

Reported by Pylint.

Using deprecated method failUnless()
Error

Line: 30 Column: 9

              
    def test_fail(self):
        self.failUnless(1)
        self.failUnless(True)

    def test_other_unittest(self):
        self.assertAlmostEqual(2+2, 4)
        self.assertNotAlmostEqual(4+4, 2)


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 17 Column: 1

              import unittest
import warnings

def warnfun():
    warnings.warn('rw', RuntimeWarning)

class TestWarnings(unittest.TestCase):
    # unittest warnings will be printed at most once per type (max one message
    # for the fail* methods, and one for the assert* methods)

            

Reported by Pylint.

Missing class docstring
Error

Line: 20 Column: 1

              def warnfun():
    warnings.warn('rw', RuntimeWarning)

class TestWarnings(unittest.TestCase):
    # unittest warnings will be printed at most once per type (max one message
    # for the fail* methods, and one for the assert* methods)
    def test_assert(self):
        self.assertEquals(2+2, 4)
        self.assertEquals(2*2, 4)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 23 Column: 5

              class TestWarnings(unittest.TestCase):
    # unittest warnings will be printed at most once per type (max one message
    # for the fail* methods, and one for the assert* methods)
    def test_assert(self):
        self.assertEquals(2+2, 4)
        self.assertEquals(2*2, 4)
        self.assertEquals(2**2, 4)

    def test_fail(self):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 28 Column: 5

                      self.assertEquals(2*2, 4)
        self.assertEquals(2**2, 4)

    def test_fail(self):
        self.failUnless(1)
        self.failUnless(True)

    def test_other_unittest(self):
        self.assertAlmostEqual(2+2, 4)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 32 Column: 5

                      self.failUnless(1)
        self.failUnless(True)

    def test_other_unittest(self):
        self.assertAlmostEqual(2+2, 4)
        self.assertNotAlmostEqual(4+4, 2)

    # these warnings are normally silenced, but they are printed in unittest
    def test_deprecation(self):

            

Reported by Pylint.

Modules/_decimal/_decimal.c
18 issues
snprintf - If format strings can be influenced by an attacker, they can be exploited, and note that sprintf variations do not always \0-terminate
Security

Line: 2547 Column: 13 CWE codes: 134
Suggestion: Use a constant for the format specification

                  if (sign_special[1] == '\0') {
        /* not a special number */
        *cp++ = 'E';
        n = snprintf(cp, MPD_EXPDIGITS+2, "%" PRI_mpd_ssize_t, exp);
        if (n < 0 || n >= MPD_EXPDIGITS+2) {
            PyErr_SetString(PyExc_RuntimeError,
                "internal error in dec_sequence_as_str");
            goto error;
        }

            

Reported by FlawFinder.

char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 191 Column: 14 CWE codes: 119 120
Suggestion: Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length

                {NULL}
};

static const char *dec_signal_string[MPD_NUM_FLAGS] = {
    "Clamped",
    "InvalidOperation",
    "DivisionByZero",
    "InvalidOperation",
    "InvalidOperation",

            

Reported by FlawFinder.

char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 608 Column: 11 CWE codes: 119 120
Suggestion: Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length

              signaldict_repr(PyObject *self)
{
    DecCondMap *cm;
    const char *n[SIGNAL_MAP_LEN]; /* name */
    const char *b[SIGNAL_MAP_LEN]; /* bool */
    int i;

    assert(SIGNAL_MAP_LEN == 9);


            

Reported by FlawFinder.

char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 609 Column: 11 CWE codes: 119 120
Suggestion: Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length

              {
    DecCondMap *cm;
    const char *n[SIGNAL_MAP_LEN]; /* name */
    const char *b[SIGNAL_MAP_LEN]; /* bool */
    int i;

    assert(SIGNAL_MAP_LEN == 9);

    for (cm=signal_map, i=0; cm->name != NULL; cm++, i++) {

            

Reported by FlawFinder.

char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 1326 Column: 5 CWE codes: 119 120
Suggestion: Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length

              context_repr(PyDecContextObject *self)
{
    mpd_context_t *ctx;
    char flags[MPD_MAX_SIGNAL_LIST];
    char traps[MPD_MAX_SIGNAL_LIST];
    int n, mem;

    assert(PyDecContext_Check(self));
    ctx = CTX(self);

            

Reported by FlawFinder.

char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 1327 Column: 5 CWE codes: 119 120
Suggestion: Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length

              {
    mpd_context_t *ctx;
    char flags[MPD_MAX_SIGNAL_LIST];
    char traps[MPD_MAX_SIGNAL_LIST];
    int n, mem;

    assert(PyDecContext_Check(self));
    ctx = CTX(self);


            

Reported by FlawFinder.

char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 2422 Column: 5 CWE codes: 119 120
Suggestion: Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length

              {
    PyObject *digits = NULL, *tmp;
    char *decstring = NULL;
    char sign_special[6];
    char *cp;
    long sign, l;
    mpd_ssize_t exp = 0;
    Py_ssize_t i, mem, tsize;
    int is_infinite = 0;

            

Reported by FlawFinder.

strcat - Does not check for buffer overflows when concatenating to destination [MS-banned]
Security

Line: 2462 Column: 13 CWE codes: 120
Suggestion: Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused)

                  if (PyUnicode_Check(tmp)) {
        /* special */
        if (PyUnicode_CompareWithASCIIString(tmp, "F") == 0) {
            strcat(sign_special, "Inf");
            is_infinite = 1;
        }
        else if (PyUnicode_CompareWithASCIIString(tmp, "n") == 0) {
            strcat(sign_special, "NaN");
        }

            

Reported by FlawFinder.

strcat - Does not check for buffer overflows when concatenating to destination [MS-banned]
Security

Line: 2466 Column: 13 CWE codes: 120
Suggestion: Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused)

                          is_infinite = 1;
        }
        else if (PyUnicode_CompareWithASCIIString(tmp, "n") == 0) {
            strcat(sign_special, "NaN");
        }
        else if (PyUnicode_CompareWithASCIIString(tmp, "N") == 0) {
            strcat(sign_special, "sNaN");
        }
        else {

            

Reported by FlawFinder.

strcat - Does not check for buffer overflows when concatenating to destination [MS-banned]
Security

Line: 2469 Column: 13 CWE codes: 120
Suggestion: Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused)

                          strcat(sign_special, "NaN");
        }
        else if (PyUnicode_CompareWithASCIIString(tmp, "N") == 0) {
            strcat(sign_special, "sNaN");
        }
        else {
            PyErr_SetString(PyExc_ValueError,
                "string argument in the third position "
                "must be 'F', 'n' or 'N'");

            

Reported by FlawFinder.

Lib/test/test_fork1.py
18 issues
Access to a protected member _exit of a client class
Error

Line: 45 Column: 21

                          if not pid:
                m = __import__(fake_module_name)
                if m == complete_module:
                    os._exit(exitcode)
                else:
                    if support.verbose > 1:
                        print("Child encountered partial module")
                    os._exit(1)
            else:

            

Reported by Pylint.

Access to a protected member _exit of a client class
Error

Line: 49 Column: 21

                              else:
                    if support.verbose > 1:
                        print("Child encountered partial module")
                    os._exit(1)
            else:
                t.join()
                # Exitcode 1 means the child got a partial module (bad.) No
                # exitcode (but a hang, which manifests as 'got pid 0')
                # means the child deadlocked (also bad.)

            

Reported by Pylint.

Unused variable 'i'
Error

Line: 72 Column: 25

                          in_child = False
            try:
                try:
                    for i in range(level):
                        imp.acquire_lock()
                        release += 1
                    pid = os.fork()
                    in_child = not pid
                finally:

            

Reported by Pylint.

Access to a protected member _exit of a client class
Error

Line: 84 Column: 21

                              if in_child:
                    if support.verbose > 1:
                        print("RuntimeError in child")
                    os._exit(1)
                raise
            if in_child:
                os._exit(exitcode)
            self.wait_impl(pid, exitcode=exitcode)


            

Reported by Pylint.

Access to a protected member _exit of a client class
Error

Line: 87 Column: 17

                                  os._exit(1)
                raise
            if in_child:
                os._exit(exitcode)
            self.wait_impl(pid, exitcode=exitcode)

        # Check this works with various levels of nested
        # import in the main thread
        for level in range(5):

            

Reported by Pylint.

standard import "import os" should be placed before "import _imp as imp"
Error

Line: 5 Column: 1

              """

import _imp as imp
import os
import signal
import sys
import threading
import time
import unittest

            

Reported by Pylint.

standard import "import signal" should be placed before "import _imp as imp"
Error

Line: 6 Column: 1

              
import _imp as imp
import os
import signal
import sys
import threading
import time
import unittest


            

Reported by Pylint.

standard import "import sys" should be placed before "import _imp as imp"
Error

Line: 7 Column: 1

              import _imp as imp
import os
import signal
import sys
import threading
import time
import unittest

from test.fork_wait import ForkWait

            

Reported by Pylint.

standard import "import threading" should be placed before "import _imp as imp"
Error

Line: 8 Column: 1

              import os
import signal
import sys
import threading
import time
import unittest

from test.fork_wait import ForkWait
from test import support

            

Reported by Pylint.

standard import "import time" should be placed before "import _imp as imp"
Error

Line: 9 Column: 1

              import signal
import sys
import threading
import time
import unittest

from test.fork_wait import ForkWait
from test import support


            

Reported by Pylint.

Lib/test/test_email/__init__.py
18 issues
Unused argument 'msg'
Error

Line: 64 Column: 47

                  def _bytes_repr(self, b):
        return [repr(x) for x in b.splitlines(keepends=True)]

    def assertBytesEqual(self, first, second, msg):
        """Our byte strings are really encoded strings; improve diff output"""
        self.assertEqual(self._bytes_repr(first), self._bytes_repr(second))

    def assertDefectsEqual(self, actual, expected):
        self.assertEqual(len(actual), len(expected), actual)

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import os
import unittest
import collections
import email
from email.message import Message
from email._policybase import compat32
from test.support import load_package_tests
from test.test_email import __file__ as landmark


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 11 Column: 1

              from test.test_email import __file__ as landmark

# Load all tests in package
def load_tests(*args):
    return load_package_tests(os.path.dirname(__file__), *args)


# helper code used by a number of test modules.


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 17 Column: 1

              
# helper code used by a number of test modules.

def openfile(filename, *args, **kws):
    path = os.path.join(os.path.dirname(landmark), 'data', filename)
    return open(path, *args, **kws)


# Base test class

            

Reported by Pylint.

Missing class docstring
Error

Line: 23 Column: 1

              

# Base test class
class TestEmailBase(unittest.TestCase):

    maxDiff = None
    # Currently the default policy is compat32.  By setting that as the default
    # here we make minimal changes in the test_email tests compared to their
    # pre-3.3 state.

            

Reported by Pylint.

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

Line: 41 Column: 54

                  ndiffAssertEqual = unittest.TestCase.assertEqual

    def _msgobj(self, filename):
        with openfile(filename, encoding="utf-8") as fp:
            return email.message_from_file(fp, policy=self.policy)

    def _str_msg(self, string, message=None, policy=None):
        if policy is None:
            policy = self.policy

            

Reported by Pylint.

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

Line: 61 Column: 5

                  def _make_message(self):
        return self.message(policy=self.policy)

    def _bytes_repr(self, b):
        return [repr(x) for x in b.splitlines(keepends=True)]

    def assertBytesEqual(self, first, second, msg):
        """Our byte strings are really encoded strings; improve diff output"""
        self.assertEqual(self._bytes_repr(first), self._bytes_repr(second))

            

Reported by Pylint.

Method could be a function
Error

Line: 61 Column: 5

                  def _make_message(self):
        return self.message(policy=self.policy)

    def _bytes_repr(self, b):
        return [repr(x) for x in b.splitlines(keepends=True)]

    def assertBytesEqual(self, first, second, msg):
        """Our byte strings are really encoded strings; improve diff output"""
        self.assertEqual(self._bytes_repr(first), self._bytes_repr(second))

            

Reported by Pylint.

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

Line: 64 Column: 5

                  def _bytes_repr(self, b):
        return [repr(x) for x in b.splitlines(keepends=True)]

    def assertBytesEqual(self, first, second, msg):
        """Our byte strings are really encoded strings; improve diff output"""
        self.assertEqual(self._bytes_repr(first), self._bytes_repr(second))

    def assertDefectsEqual(self, actual, expected):
        self.assertEqual(len(actual), len(expected), actual)

            

Reported by Pylint.

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

Line: 68 Column: 5

                      """Our byte strings are really encoded strings; improve diff output"""
        self.assertEqual(self._bytes_repr(first), self._bytes_repr(second))

    def assertDefectsEqual(self, actual, expected):
        self.assertEqual(len(actual), len(expected), actual)
        for i in range(len(actual)):
            self.assertIsInstance(actual[i], expected[i],
                                    'item {}'.format(i))


            

Reported by Pylint.

Lib/test/test_importlib/test_path.py
18 issues
Attempted relative import beyond top-level package
Error

Line: 5 Column: 1

              import unittest

from importlib import resources
from . import data01
from .resources import util


class CommonTests(util.CommonTests, unittest.TestCase):
    def execute(self, package, path):

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 6 Column: 1

              
from importlib import resources
from . import data01
from .resources import util


class CommonTests(util.CommonTests, unittest.TestCase):
    def execute(self, package, path):
        with resources.path(package, path):

            

Reported by Pylint.

Instance of 'PathTests' has no 'data' member
Error

Line: 20 Column: 29

                      # Path should be readable.
        # Test also implicitly verifies the returned object is a pathlib.Path
        # instance.
        with resources.path(self.data, 'utf-8.file') as path:
            self.assertTrue(path.name.endswith("utf-8.file"), repr(path))
            # pathlib.Path.read_text() was introduced in Python 3.5.
            with path.open('r', encoding='utf-8') as file:
                text = file.read()
            self.assertEqual('Hello, UTF-8 world!\n', text)

            

Reported by Pylint.

Instance of 'PathTests' has no 'assertTrue' member
Error

Line: 21 Column: 13

                      # Test also implicitly verifies the returned object is a pathlib.Path
        # instance.
        with resources.path(self.data, 'utf-8.file') as path:
            self.assertTrue(path.name.endswith("utf-8.file"), repr(path))
            # pathlib.Path.read_text() was introduced in Python 3.5.
            with path.open('r', encoding='utf-8') as file:
                text = file.read()
            self.assertEqual('Hello, UTF-8 world!\n', text)


            

Reported by Pylint.

Instance of 'PathTests' has no 'assertEqual' member
Error

Line: 25 Column: 13

                          # pathlib.Path.read_text() was introduced in Python 3.5.
            with path.open('r', encoding='utf-8') as file:
                text = file.read()
            self.assertEqual('Hello, UTF-8 world!\n', text)


class PathDiskTests(PathTests, unittest.TestCase):
    data = data01


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import io
import unittest

from importlib import resources
from . import data01
from .resources import util


class CommonTests(util.CommonTests, unittest.TestCase):

            

Reported by Pylint.

Missing class docstring
Error

Line: 9 Column: 1

              from .resources import util


class CommonTests(util.CommonTests, unittest.TestCase):
    def execute(self, package, path):
        with resources.path(package, path):
            pass



            

Reported by Pylint.

Missing function or method docstring
Error

Line: 10 Column: 5

              

class CommonTests(util.CommonTests, unittest.TestCase):
    def execute(self, package, path):
        with resources.path(package, path):
            pass


class PathTests:

            

Reported by Pylint.

Method could be a function
Error

Line: 10 Column: 5

              

class CommonTests(util.CommonTests, unittest.TestCase):
    def execute(self, package, path):
        with resources.path(package, path):
            pass


class PathTests:

            

Reported by Pylint.

Missing class docstring
Error

Line: 15 Column: 1

                          pass


class PathTests:
    def test_reading(self):
        # Path should be readable.
        # Test also implicitly verifies the returned object is a pathlib.Path
        # instance.
        with resources.path(self.data, 'utf-8.file') as path:

            

Reported by Pylint.

Lib/test/test_crypt.py
18 issues
Access to a protected member _saltchars of a client class
Error

Line: 36 Column: 30

                          self.assertEqual(cr2, cr)

    def test_salt(self):
        self.assertEqual(len(crypt._saltchars), 64)
        for method in crypt.methods:
            salt = crypt.mksalt(method)
            self.assertIn(len(salt) - method.salt_chars, {0, 1, 3, 4, 6, 7})
            if method.ident:
                self.assertIn(method.ident, salt[:len(salt)-method.salt_chars])

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import sys
import unittest


try:
    import crypt
    IMPORT_ERROR = None
except ImportError as ex:
    if sys.platform != 'win32':

            

Reported by Pylint.

Missing class docstring
Error

Line: 17 Column: 1

              
@unittest.skipUnless(sys.platform == 'win32', 'This should only run on windows')
@unittest.skipIf(crypt, 'import succeeded')
class TestWhyCryptDidNotImport(unittest.TestCase):

    def test_import_failure_message(self):
        self.assertIn('not supported', IMPORT_ERROR)



            

Reported by Pylint.

Missing function or method docstring
Error

Line: 19 Column: 5

              @unittest.skipIf(crypt, 'import succeeded')
class TestWhyCryptDidNotImport(unittest.TestCase):

    def test_import_failure_message(self):
        self.assertIn('not supported', IMPORT_ERROR)


@unittest.skipUnless(crypt, 'crypt module is required')
class CryptTestCase(unittest.TestCase):

            

Reported by Pylint.

Missing class docstring
Error

Line: 24 Column: 1

              

@unittest.skipUnless(crypt, 'crypt module is required')
class CryptTestCase(unittest.TestCase):

    def test_crypt(self):
        cr = crypt.crypt('mypassword')
        cr2 = crypt.crypt('mypassword', cr)
        self.assertEqual(cr2, cr)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 26 Column: 5

              @unittest.skipUnless(crypt, 'crypt module is required')
class CryptTestCase(unittest.TestCase):

    def test_crypt(self):
        cr = crypt.crypt('mypassword')
        cr2 = crypt.crypt('mypassword', cr)
        self.assertEqual(cr2, cr)
        cr = crypt.crypt('mypassword', 'ab')
        if cr is not None:

            

Reported by Pylint.

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

Line: 27 Column: 9

              class CryptTestCase(unittest.TestCase):

    def test_crypt(self):
        cr = crypt.crypt('mypassword')
        cr2 = crypt.crypt('mypassword', cr)
        self.assertEqual(cr2, cr)
        cr = crypt.crypt('mypassword', 'ab')
        if cr is not None:
            cr2 = crypt.crypt('mypassword', cr)

            

Reported by Pylint.

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

Line: 30 Column: 9

                      cr = crypt.crypt('mypassword')
        cr2 = crypt.crypt('mypassword', cr)
        self.assertEqual(cr2, cr)
        cr = crypt.crypt('mypassword', 'ab')
        if cr is not None:
            cr2 = crypt.crypt('mypassword', cr)
            self.assertEqual(cr2, cr)

    def test_salt(self):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 35 Column: 5

                          cr2 = crypt.crypt('mypassword', cr)
            self.assertEqual(cr2, cr)

    def test_salt(self):
        self.assertEqual(len(crypt._saltchars), 64)
        for method in crypt.methods:
            salt = crypt.mksalt(method)
            self.assertIn(len(salt) - method.salt_chars, {0, 1, 3, 4, 6, 7})
            if method.ident:

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 43 Column: 5

                          if method.ident:
                self.assertIn(method.ident, salt[:len(salt)-method.salt_chars])

    def test_saltedcrypt(self):
        for method in crypt.methods:
            cr = crypt.crypt('assword', method)
            self.assertEqual(len(cr), method.total_size)
            cr2 = crypt.crypt('assword', cr)
            self.assertEqual(cr2, cr)

            

Reported by Pylint.

Lib/test/test_importlib/test_files.py
18 issues
Attempted relative import beyond top-level package
Error

Line: 6 Column: 1

              
from importlib import resources
from importlib.abc import Traversable
from . import data01
from .resources import util


class FilesTests:
    def test_read_bytes(self):

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 7 Column: 1

              from importlib import resources
from importlib.abc import Traversable
from . import data01
from .resources import util


class FilesTests:
    def test_read_bytes(self):
        files = resources.files(self.data)

            

Reported by Pylint.

Instance of 'FilesTests' has no 'data' member
Error

Line: 12 Column: 33

              
class FilesTests:
    def test_read_bytes(self):
        files = resources.files(self.data)
        actual = files.joinpath('utf-8.file').read_bytes()
        assert actual == b'Hello, UTF-8 world!\n'

    def test_read_text(self):
        files = resources.files(self.data)

            

Reported by Pylint.

Instance of 'FilesTests' has no 'data' member
Error

Line: 17 Column: 33

                      assert actual == b'Hello, UTF-8 world!\n'

    def test_read_text(self):
        files = resources.files(self.data)
        actual = files.joinpath('utf-8.file').read_text(encoding='utf-8')
        assert actual == 'Hello, UTF-8 world!\n'

    @unittest.skipUnless(
        hasattr(typing, 'runtime_checkable'),

            

Reported by Pylint.

Instance of 'FilesTests' has no 'data' member
Error

Line: 26 Column: 43

                      "Only suitable when typing supports runtime_checkable",
    )
    def test_traversable(self):
        assert isinstance(resources.files(self.data), Traversable)


class OpenDiskTests(FilesTests, unittest.TestCase):
    def setUp(self):
        self.data = data01

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 40 Column: 9

              
class OpenNamespaceTests(FilesTests, unittest.TestCase):
    def setUp(self):
        from . import namespacedata01

        self.data = namespacedata01


if __name__ == '__main__':

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import typing
import unittest

from importlib import resources
from importlib.abc import Traversable
from . import data01
from .resources import util



            

Reported by Pylint.

Missing class docstring
Error

Line: 10 Column: 1

              from .resources import util


class FilesTests:
    def test_read_bytes(self):
        files = resources.files(self.data)
        actual = files.joinpath('utf-8.file').read_bytes()
        assert actual == b'Hello, UTF-8 world!\n'


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 11 Column: 5

              

class FilesTests:
    def test_read_bytes(self):
        files = resources.files(self.data)
        actual = files.joinpath('utf-8.file').read_bytes()
        assert actual == b'Hello, UTF-8 world!\n'

    def test_read_text(self):

            

Reported by Pylint.

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

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

                  def test_read_bytes(self):
        files = resources.files(self.data)
        actual = files.joinpath('utf-8.file').read_bytes()
        assert actual == b'Hello, UTF-8 world!\n'

    def test_read_text(self):
        files = resources.files(self.data)
        actual = files.joinpath('utf-8.file').read_text(encoding='utf-8')
        assert actual == 'Hello, UTF-8 world!\n'

            

Reported by Bandit.

Lib/io.py
18 issues
No name 'text_encoding' in module '_io'
Error

Line: 54 Column: 1

              import _io
import abc

from _io import (DEFAULT_BUFFER_SIZE, BlockingIOError, UnsupportedOperation,
                 open, open_code, FileIO, BytesIO, StringIO, BufferedReader,
                 BufferedWriter, BufferedRWPair, BufferedRandom,
                 IncrementalNewlineDecoder, text_encoding, TextIOWrapper)



            

Reported by Pylint.

Unused text_encoding imported from _io
Error

Line: 54 Column: 1

              import _io
import abc

from _io import (DEFAULT_BUFFER_SIZE, BlockingIOError, UnsupportedOperation,
                 open, open_code, FileIO, BytesIO, StringIO, BufferedReader,
                 BufferedWriter, BufferedRWPair, BufferedRandom,
                 IncrementalNewlineDecoder, text_encoding, TextIOWrapper)



            

Reported by Pylint.

Redefining built-in 'BlockingIOError'
Error

Line: 54 Column: 1

              import _io
import abc

from _io import (DEFAULT_BUFFER_SIZE, BlockingIOError, UnsupportedOperation,
                 open, open_code, FileIO, BytesIO, StringIO, BufferedReader,
                 BufferedWriter, BufferedRWPair, BufferedRandom,
                 IncrementalNewlineDecoder, text_encoding, TextIOWrapper)



            

Reported by Pylint.

Redefining built-in 'open'
Error

Line: 54 Column: 1

              import _io
import abc

from _io import (DEFAULT_BUFFER_SIZE, BlockingIOError, UnsupportedOperation,
                 open, open_code, FileIO, BytesIO, StringIO, BufferedReader,
                 BufferedWriter, BufferedRWPair, BufferedRandom,
                 IncrementalNewlineDecoder, text_encoding, TextIOWrapper)



            

Reported by Pylint.

Unused DEFAULT_BUFFER_SIZE imported from _io
Error

Line: 54 Column: 1

              import _io
import abc

from _io import (DEFAULT_BUFFER_SIZE, BlockingIOError, UnsupportedOperation,
                 open, open_code, FileIO, BytesIO, StringIO, BufferedReader,
                 BufferedWriter, BufferedRWPair, BufferedRandom,
                 IncrementalNewlineDecoder, text_encoding, TextIOWrapper)



            

Reported by Pylint.

Unused IncrementalNewlineDecoder imported from _io
Error

Line: 54 Column: 1

              import _io
import abc

from _io import (DEFAULT_BUFFER_SIZE, BlockingIOError, UnsupportedOperation,
                 open, open_code, FileIO, BytesIO, StringIO, BufferedReader,
                 BufferedWriter, BufferedRWPair, BufferedRandom,
                 IncrementalNewlineDecoder, text_encoding, TextIOWrapper)



            

Reported by Pylint.

Global variable 'OpenWrapper' undefined at the module level
Error

Line: 70 Column: 9

                      import warnings
        warnings.warn('OpenWrapper is deprecated, use open instead',
                      DeprecationWarning, stacklevel=2)
        global OpenWrapper
        OpenWrapper = open
        return OpenWrapper
    raise AttributeError(name)



            

Reported by Pylint.

Access to a protected member _IOBase of a client class
Error

Line: 87 Column: 14

              # Declaring ABCs in C is tricky so we do it here.
# Method descriptions and default implementations are inherited from the C
# version however.
class IOBase(_io._IOBase, metaclass=abc.ABCMeta):
    __doc__ = _io._IOBase.__doc__

class RawIOBase(_io._RawIOBase, IOBase):
    __doc__ = _io._RawIOBase.__doc__


            

Reported by Pylint.

Access to a protected member _IOBase of a client class
Error

Line: 88 Column: 15

              # Method descriptions and default implementations are inherited from the C
# version however.
class IOBase(_io._IOBase, metaclass=abc.ABCMeta):
    __doc__ = _io._IOBase.__doc__

class RawIOBase(_io._RawIOBase, IOBase):
    __doc__ = _io._RawIOBase.__doc__

class BufferedIOBase(_io._BufferedIOBase, IOBase):

            

Reported by Pylint.

Access to a protected member _RawIOBase of a client class
Error

Line: 90 Column: 17

              class IOBase(_io._IOBase, metaclass=abc.ABCMeta):
    __doc__ = _io._IOBase.__doc__

class RawIOBase(_io._RawIOBase, IOBase):
    __doc__ = _io._RawIOBase.__doc__

class BufferedIOBase(_io._BufferedIOBase, IOBase):
    __doc__ = _io._BufferedIOBase.__doc__


            

Reported by Pylint.

Lib/distutils/command/__init__.py
18 issues
Undefined variable name 'build' in __all__
Error

Line: 6 Column: 12

              Package containing implementation of all the standard Distutils
commands."""

__all__ = ['build',
           'build_py',
           'build_ext',
           'build_clib',
           'build_scripts',
           'clean',

            

Reported by Pylint.

Undefined variable name 'build_py' in __all__
Error

Line: 7 Column: 12

              commands."""

__all__ = ['build',
           'build_py',
           'build_ext',
           'build_clib',
           'build_scripts',
           'clean',
           'install',

            

Reported by Pylint.

Undefined variable name 'build_ext' in __all__
Error

Line: 8 Column: 12

              
__all__ = ['build',
           'build_py',
           'build_ext',
           'build_clib',
           'build_scripts',
           'clean',
           'install',
           'install_lib',

            

Reported by Pylint.

Undefined variable name 'build_clib' in __all__
Error

Line: 9 Column: 12

              __all__ = ['build',
           'build_py',
           'build_ext',
           'build_clib',
           'build_scripts',
           'clean',
           'install',
           'install_lib',
           'install_headers',

            

Reported by Pylint.

Undefined variable name 'build_scripts' in __all__
Error

Line: 10 Column: 12

                         'build_py',
           'build_ext',
           'build_clib',
           'build_scripts',
           'clean',
           'install',
           'install_lib',
           'install_headers',
           'install_scripts',

            

Reported by Pylint.

Undefined variable name 'clean' in __all__
Error

Line: 11 Column: 12

                         'build_ext',
           'build_clib',
           'build_scripts',
           'clean',
           'install',
           'install_lib',
           'install_headers',
           'install_scripts',
           'install_data',

            

Reported by Pylint.

Undefined variable name 'install' in __all__
Error

Line: 12 Column: 12

                         'build_clib',
           'build_scripts',
           'clean',
           'install',
           'install_lib',
           'install_headers',
           'install_scripts',
           'install_data',
           'sdist',

            

Reported by Pylint.

Undefined variable name 'install_lib' in __all__
Error

Line: 13 Column: 12

                         'build_scripts',
           'clean',
           'install',
           'install_lib',
           'install_headers',
           'install_scripts',
           'install_data',
           'sdist',
           'register',

            

Reported by Pylint.

Undefined variable name 'install_headers' in __all__
Error

Line: 14 Column: 12

                         'clean',
           'install',
           'install_lib',
           'install_headers',
           'install_scripts',
           'install_data',
           'sdist',
           'register',
           'bdist',

            

Reported by Pylint.

Undefined variable name 'install_scripts' in __all__
Error

Line: 15 Column: 12

                         'install',
           'install_lib',
           'install_headers',
           'install_scripts',
           'install_data',
           'sdist',
           'register',
           'bdist',
           'bdist_dumb',

            

Reported by Pylint.

Lib/idlelib/idle_test/test_tree.py
18 issues
Method should have "self" as first argument
Error

Line: 37 Column: 13

                  def test_wheel_event(self):
        # Fake widget class containing `yview` only.
        class _Widget:
            def __init__(widget, *expected):
                widget.expected = expected
            def yview(widget, *args):
                self.assertTupleEqual(widget.expected, args)
        # Fake event class
        class _Event:

            

Reported by Pylint.

Method should have "self" as first argument
Error

Line: 39 Column: 13

                      class _Widget:
            def __init__(widget, *expected):
                widget.expected = expected
            def yview(widget, *args):
                self.assertTupleEqual(widget.expected, args)
        # Fake event class
        class _Event:
            pass
        #        (type, delta, num, amount)

            

Reported by Pylint.

Attribute 'type' defined outside __init__
Error

Line: 52 Column: 13

              
        event = _Event()
        for ty, delta, num, amount in tests:
            event.type = ty
            event.delta = delta
            event.num = num
            res = tree.wheel_event(event, _Widget(SCROLL, amount, "units"))
            self.assertEqual(res, "break")


            

Reported by Pylint.

Attribute 'delta' defined outside __init__
Error

Line: 53 Column: 13

                      event = _Event()
        for ty, delta, num, amount in tests:
            event.type = ty
            event.delta = delta
            event.num = num
            res = tree.wheel_event(event, _Widget(SCROLL, amount, "units"))
            self.assertEqual(res, "break")



            

Reported by Pylint.

Attribute 'num' defined outside __init__
Error

Line: 54 Column: 13

                      for ty, delta, num, amount in tests:
            event.type = ty
            event.delta = delta
            event.num = num
            res = tree.wheel_event(event, _Widget(SCROLL, amount, "units"))
            self.assertEqual(res, "break")


if __name__ == '__main__':

            

Reported by Pylint.

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

Line: 4 Column: 1

              "Test tree. coverage 56%."

from idlelib import tree
import unittest
from test.support import requires
requires('gui')
from tkinter import Tk, EventType, SCROLL



            

Reported by Pylint.

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

Line: 5 Column: 1

              
from idlelib import tree
import unittest
from test.support import requires
requires('gui')
from tkinter import Tk, EventType, SCROLL


class TreeTest(unittest.TestCase):

            

Reported by Pylint.

Import "from tkinter import Tk, EventType, SCROLL" should be placed at the top of the module
Error

Line: 7 Column: 1

              import unittest
from test.support import requires
requires('gui')
from tkinter import Tk, EventType, SCROLL


class TreeTest(unittest.TestCase):

    @classmethod

            

Reported by Pylint.

standard import "from tkinter import Tk, EventType, SCROLL" should be placed before "from idlelib import tree"
Error

Line: 7 Column: 1

              import unittest
from test.support import requires
requires('gui')
from tkinter import Tk, EventType, SCROLL


class TreeTest(unittest.TestCase):

    @classmethod

            

Reported by Pylint.

Missing class docstring
Error

Line: 10 Column: 1

              from tkinter import Tk, EventType, SCROLL


class TreeTest(unittest.TestCase):

    @classmethod
    def setUpClass(cls):
        cls.root = Tk()
        cls.root.withdraw()

            

Reported by Pylint.