The following issues were found

Lib/urllib/request.py
446 issues
A FTP-related module is being imported. FTP is considered insecure. Use SSH/SFTP/SCP or some other encrypted protocol.
Security blacklist

Line: 1533
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_imports.html#b402-import-ftplib

              
class FTPHandler(BaseHandler):
    def ftp_open(self, req):
        import ftplib
        import mimetypes
        host = req.host
        if not host:
            raise URLError('ftp error: no host given')
        host, port = _splitport(host)

            

Reported by Bandit.

A FTP-related module is being imported. FTP is considered insecure. Use SSH/SFTP/SCP or some other encrypted protocol.
Security blacklist

Line: 2056
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_imports.html#b402-import-ftplib

                      passwd = unquote(passwd or '')
        host = socket.gethostbyname(host)
        if not port:
            import ftplib
            port = ftplib.FTP_PORT
        else:
            port = int(port)
        path, attrs = _splitattr(path)
        path = unquote(path)

            

Reported by Bandit.

A FTP-related module is being imported. FTP is considered insecure. Use SSH/SFTP/SCP or some other encrypted protocol.
Security blacklist

Line: 2378
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_imports.html#b402-import-ftplib

                  """Return the set of errors raised by the FTP class."""
    global _ftperrors
    if _ftperrors is None:
        import ftplib
        _ftperrors = ftplib.all_errors
    return _ftperrors

_noheaders = None
def noheaders():

            

Reported by Bandit.

A FTP-related module is being imported. FTP is considered insecure. Use SSH/SFTP/SCP or some other encrypted protocol.
Security blacklist

Line: 2413
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_imports.html#b402-import-ftplib

                          raise

    def init(self):
        import ftplib
        self.busy = 0
        self.ftp = ftplib.FTP()
        self.ftp.connect(self.host, self.port, self.timeout)
        self.ftp.login(self.user, self.passwd)
        _target = '/'.join(self.dirs)

            

Reported by Bandit.

FTP-related functions are being called. FTP is considered insecure. Use SSH/SFTP/SCP or some other encrypted protocol.
Security blacklist

Line: 2415
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b321-ftplib

                  def init(self):
        import ftplib
        self.busy = 0
        self.ftp = ftplib.FTP()
        self.ftp.connect(self.host, self.port, self.timeout)
        self.ftp.login(self.user, self.passwd)
        _target = '/'.join(self.dirs)
        self.ftp.cwd(_target)


            

Reported by Bandit.

A FTP-related module is being imported. FTP is considered insecure. Use SSH/SFTP/SCP or some other encrypted protocol.
Security blacklist

Line: 2422
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_imports.html#b402-import-ftplib

                      self.ftp.cwd(_target)

    def retrfile(self, file, type):
        import ftplib
        self.endtransfer()
        if type in ('d', 'D'): cmd = 'TYPE A'; isdir = 1
        else: cmd = 'TYPE ' + type; isdir = 0
        try:
            self.ftp.voidcmd(cmd)

            

Reported by Bandit.

Instance of 'AbstractBasicAuthHandler' has no 'auth_header' member
Error

Line: 1017 Column: 31

                      if pw is not None:
            raw = "%s:%s" % (user, pw)
            auth = "Basic " + base64.b64encode(raw.encode()).decode("ascii")
            if req.get_header(self.auth_header, None) == auth:
                return None
            req.add_unredirected_header(self.auth_header, auth)
            return self.parent.open(req, timeout=req.timeout)
        else:
            return None

            

Reported by Pylint.

Instance of 'AbstractBasicAuthHandler' has no 'auth_header' member
Error

Line: 1019 Column: 41

                          auth = "Basic " + base64.b64encode(raw.encode()).decode("ascii")
            if req.get_header(self.auth_header, None) == auth:
                return None
            req.add_unredirected_header(self.auth_header, auth)
            return self.parent.open(req, timeout=req.timeout)
        else:
            return None

    def http_request(self, req):

            

Reported by Pylint.

Instance of 'AbstractBasicAuthHandler' has no 'parent' member
Error

Line: 1020 Column: 20

                          if req.get_header(self.auth_header, None) == auth:
                return None
            req.add_unredirected_header(self.auth_header, auth)
            return self.parent.open(req, timeout=req.timeout)
        else:
            return None

    def http_request(self, req):
        if (not hasattr(self.passwd, 'is_authenticated') or

            

Reported by Pylint.

Instance of 'AbstractDigestAuthHandler' has no 'auth_header' member
Error

Line: 1129 Column: 32

                      auth = self.get_authorization(req, chal)
        if auth:
            auth_val = 'Digest %s' % auth
            if req.headers.get(self.auth_header, None) == auth_val:
                return None
            req.add_unredirected_header(self.auth_header, auth_val)
            resp = self.parent.open(req, timeout=req.timeout)
            return resp


            

Reported by Pylint.

Lib/unittest/test/test_loader.py
446 issues
Method has no argument
Error

Line: 1266 Column: 13

                  # touch a TestCase's attribute if it starts with the test method prefix.
    def test_getTestCaseNames__testNamePatterns__attribute_access_regression(self):
        class Trap:
            def __get__(*ignored):
                self.fail('Non-test attribute accessed')

        class MyTest(unittest.TestCase):
            def test_1(self): pass
            foobar = Trap()

            

Reported by Pylint.

XXX Currently, it succeeds anyway. This flexibility
Error

Line: 157 Column: 3

                  # What happens if loadTestsFromModule() is given something other
    # than a module?
    #
    # XXX Currently, it succeeds anyway. This flexibility
    # should either be documented or loadTestsFromModule() should
    # raise a TypeError
    #
    # XXX Certain people are using this behaviour. We'll add a test for it
    def test_loadTestsFromModule__not_a_module(self):

            

Reported by Pylint.

XXX Certain people are using this behaviour. We'll add a test for it
Error

Line: 161 Column: 3

                  # should either be documented or loadTestsFromModule() should
    # raise a TypeError
    #
    # XXX Certain people are using this behaviour. We'll add a test for it
    def test_loadTestsFromModule__not_a_module(self):
        class MyTestCase(unittest.TestCase):
            def test(self):
                pass


            

Reported by Pylint.

XXX Should probably raise a ValueError instead of an AttributeError
Error

Line: 478 Column: 3

                  # Does loadTestsFromName raise ValueError when passed an empty
    # name relative to a provided module?
    #
    # XXX Should probably raise a ValueError instead of an AttributeError
    def test_loadTestsFromName__relative_empty_name(self):
        loader = unittest.TestLoader()

        suite = loader.loadTestsFromName('', unittest)
        error, test = self.check_deferred_error(loader, suite)

            

Reported by Pylint.

XXX Should this raise AttributeError or ValueError?
Error

Line: 502 Column: 3

                  def test_loadTestsFromName__relative_malformed_name(self):
        loader = unittest.TestLoader()

        # XXX Should this raise AttributeError or ValueError?
        suite = loader.loadTestsFromName('abc () //', unittest)
        error, test = self.check_deferred_error(loader, suite)
        expected = "module 'unittest' has no attribute 'abc () //'"
        expected_regex = r"module 'unittest' has no attribute 'abc \(\) //'"
        self.assertIn(

            

Reported by Pylint.

XXX Accepts the not-a-module object, ignoring the object's type
Error

Line: 518 Column: 3

                  # Does loadTestsFromName raise TypeError when the `module` argument
    # isn't a module object?
    #
    # XXX Accepts the not-a-module object, ignoring the object's type
    # This should raise an exception or the method name should be changed
    #
    # XXX Some people are relying on this, so keep it for now
    def test_loadTestsFromName__relative_not_a_module(self):
        class MyTestCase(unittest.TestCase):

            

Reported by Pylint.

XXX Some people are relying on this, so keep it for now
Error

Line: 521 Column: 3

                  # XXX Accepts the not-a-module object, ignoring the object's type
    # This should raise an exception or the method name should be changed
    #
    # XXX Some people are relying on this, so keep it for now
    def test_loadTestsFromName__relative_not_a_module(self):
        class MyTestCase(unittest.TestCase):
            def test(self):
                pass


            

Reported by Pylint.

Unused variable 'suite'
Error

Line: 707 Column: 13

              
        loader = unittest.TestLoader()
        try:
            suite = loader.loadTestsFromName('return_wrong', m)
        except TypeError:
            pass
        else:
            self.fail("TestLoader.loadTestsFromName failed to raise TypeError")


            

Reported by Pylint.

XXX Should this raise a ValueError or just return an empty TestSuite?
Error

Line: 776 Column: 3

                  #
    # What happens if that sequence of names is empty?
    #
    # XXX Should this raise a ValueError or just return an empty TestSuite?
    def test_loadTestsFromNames__relative_empty_name_list(self):
        loader = unittest.TestLoader()

        suite = loader.loadTestsFromNames([], unittest)
        self.assertIsInstance(suite, loader.suiteClass)

            

Reported by Pylint.

XXX Should this raise ValueError or ImportError?
Error

Line: 809 Column: 3

                  def test_loadTestsFromNames__malformed_name(self):
        loader = unittest.TestLoader()

        # XXX Should this raise ValueError or ImportError?
        suite = loader.loadTestsFromNames(['abc () //'])
        error, test = self.check_deferred_error(loader, list(suite)[0])
        expected = "Failed to import test module: abc () //"
        expected_regex = r"Failed to import test module: abc \(\) //"
        self.assertIn(

            

Reported by Pylint.

Lib/test/test_asyncio/test_unix_events.py
437 issues
Method 'connection_made' has no 'assert_called_with' member
Error

Line: 685 Column: 9

                      tr = self.read_pipe_transport(waiter=waiter)
        self.loop.run_until_complete(waiter)

        self.protocol.connection_made.assert_called_with(tr)
        self.loop.assert_reader(5, tr._read_ready)
        self.assertIsNone(waiter.result())

    @mock.patch('os.read')
    def test__read_ready(self, m_read):

            

Reported by Pylint.

Instance of 'TestProtocol' has no 'data_received' member
Error

Line: 696 Column: 9

                      tr._read_ready()

        m_read.assert_called_with(5, tr.max_size)
        self.protocol.data_received.assert_called_with(b'data')

    @mock.patch('os.read')
    def test__read_ready_eof(self, m_read):
        tr = self.read_pipe_transport()
        m_read.return_value = b''

            

Reported by Pylint.

Instance of 'TestProtocol' has no 'eof_received' member
Error

Line: 707 Column: 9

                      m_read.assert_called_with(5, tr.max_size)
        self.assertFalse(self.loop.readers)
        test_utils.run_briefly(self.loop)
        self.protocol.eof_received.assert_called_with()
        self.protocol.connection_lost.assert_called_with(None)

    @mock.patch('os.read')
    def test__read_ready_blocked(self, m_read):
        tr = self.read_pipe_transport()

            

Reported by Pylint.

Method 'connection_lost' has no 'assert_called_with' member
Error

Line: 708 Column: 9

                      self.assertFalse(self.loop.readers)
        test_utils.run_briefly(self.loop)
        self.protocol.eof_received.assert_called_with()
        self.protocol.connection_lost.assert_called_with(None)

    @mock.patch('os.read')
    def test__read_ready_blocked(self, m_read):
        tr = self.read_pipe_transport()
        m_read.side_effect = BlockingIOError

            

Reported by Pylint.

Instance of 'TestProtocol' has no 'data_received' member
Error

Line: 718 Column: 26

              
        m_read.assert_called_with(5, tr.max_size)
        test_utils.run_briefly(self.loop)
        self.assertFalse(self.protocol.data_received.called)

    @mock.patch('asyncio.log.logger.error')
    @mock.patch('os.read')
    def test__read_ready_error(self, m_read, m_logexc):
        tr = self.read_pipe_transport()

            

Reported by Pylint.

Method 'connection_lost' has no 'assert_called_with' member
Error

Line: 775 Column: 9

                      self.assertTrue(tr.is_closing())
        self.assertFalse(self.loop.readers)
        test_utils.run_briefly(self.loop)
        self.protocol.connection_lost.assert_called_with(err)

    def test__call_connection_lost(self):
        tr = self.read_pipe_transport()
        self.assertIsNotNone(tr._protocol)
        self.assertIsNotNone(tr._loop)

            

Reported by Pylint.

Method 'connection_lost' has no 'assert_called_with' member
Error

Line: 784 Column: 9

              
        err = None
        tr._call_connection_lost(err)
        self.protocol.connection_lost.assert_called_with(err)
        self.pipe.close.assert_called_with()

        self.assertIsNone(tr._protocol)
        self.assertIsNone(tr._loop)


            

Reported by Pylint.

Method 'connection_lost' has no 'assert_called_with' member
Error

Line: 797 Column: 9

              
        err = OSError()
        tr._call_connection_lost(err)
        self.protocol.connection_lost.assert_called_with(err)
        self.pipe.close.assert_called_with()

        self.assertIsNone(tr._protocol)
        self.assertIsNone(tr._loop)


            

Reported by Pylint.

Instance of 'TestProtocol' has no 'connection_made' member
Error

Line: 862 Column: 9

                      tr = self.write_pipe_transport(waiter=waiter)
        self.loop.run_until_complete(waiter)

        self.protocol.connection_made.assert_called_with(tr)
        self.loop.assert_reader(5, tr._read_ready)
        self.assertEqual(None, waiter.result())

    def test_can_write_eof(self):
        tr = self.write_pipe_transport()

            

Reported by Pylint.

Instance of 'TestProtocol' has no 'connection_lost' member
Error

Line: 958 Column: 9

                      self.assertFalse(self.loop.writers)
        self.assertTrue(tr.is_closing())
        test_utils.run_briefly(self.loop)
        self.protocol.connection_lost.assert_called_with(None)

    @mock.patch('os.write')
    def test__write_ready(self, m_write):
        tr = self.write_pipe_transport()
        self.loop.add_writer(5, tr._write_ready)

            

Reported by Pylint.

Lib/unittest/test/test_case.py
437 issues
Undefined variable 'MyException'
Error

Line: 85 Column: 38

                  # thing.
    def test_init__no_test_name(self):
        class Test(unittest.TestCase):
            def runTest(self): raise MyException()
            def test(self): pass

        self.assertEqual(Test().id()[-13:], '.Test.runTest')

        # test that TestCase can be instantiated with no args

            

Reported by Pylint.

Undefined variable 'MyException'
Error

Line: 106 Column: 38

                  # method named methodName."
    def test_init__test_name__valid(self):
        class Test(unittest.TestCase):
            def runTest(self): raise MyException()
            def test(self): pass

        self.assertEqual(Test('test').id()[-10:], '.Test.test')

    # "class TestCase([methodName])"

            

Reported by Pylint.

Undefined variable 'MyException'
Error

Line: 117 Column: 38

                  # method named methodName."
    def test_init__test_name__invalid(self):
        class Test(unittest.TestCase):
            def runTest(self): raise MyException()
            def test(self): pass

        try:
            Test('testfoo')
        except ValueError:

            

Reported by Pylint.

No value for argument 'expected_exception' in method call
Error

Line: 1289 Column: 13

              
    def testAssertRaisesNoExceptionType(self):
        with self.assertRaises(TypeError):
            self.assertRaises()
        with self.assertRaises(TypeError):
            self.assertRaises(1)
        with self.assertRaises(TypeError):
            self.assertRaises(object)
        with self.assertRaises(TypeError):

            

Reported by Pylint.

No value for argument 'expected_exception' in method call
Error

Line: 1400 Column: 13

              
    def testAssertRaisesRegexNoExceptionType(self):
        with self.assertRaises(TypeError):
            self.assertRaisesRegex()
        with self.assertRaises(TypeError):
            self.assertRaisesRegex(ValueError)
        with self.assertRaises(TypeError):
            self.assertRaisesRegex(1, 'expect')
        with self.assertRaises(TypeError):

            

Reported by Pylint.

No value for argument 'expected_regex' in method call
Error

Line: 1400 Column: 13

              
    def testAssertRaisesRegexNoExceptionType(self):
        with self.assertRaises(TypeError):
            self.assertRaisesRegex()
        with self.assertRaises(TypeError):
            self.assertRaisesRegex(ValueError)
        with self.assertRaises(TypeError):
            self.assertRaisesRegex(1, 'expect')
        with self.assertRaises(TypeError):

            

Reported by Pylint.

No value for argument 'expected_regex' in method call
Error

Line: 1402 Column: 13

                      with self.assertRaises(TypeError):
            self.assertRaisesRegex()
        with self.assertRaises(TypeError):
            self.assertRaisesRegex(ValueError)
        with self.assertRaises(TypeError):
            self.assertRaisesRegex(1, 'expect')
        with self.assertRaises(TypeError):
            self.assertRaisesRegex(object, 'expect')
        with self.assertRaises(TypeError):

            

Reported by Pylint.

No value for argument 'expected_warning' in method call
Error

Line: 1491 Column: 13

              
    def testAssertWarnsNoExceptionType(self):
        with self.assertRaises(TypeError):
            self.assertWarns()
        with self.assertRaises(TypeError):
            self.assertWarns(1)
        with self.assertRaises(TypeError):
            self.assertWarns(object)
        with self.assertRaises(TypeError):

            

Reported by Pylint.

No value for argument 'expected_regex' in method call
Error

Line: 1582 Column: 13

              
    def testAssertWarnsRegexNoExceptionType(self):
        with self.assertRaises(TypeError):
            self.assertWarnsRegex()
        with self.assertRaises(TypeError):
            self.assertWarnsRegex(UserWarning)
        with self.assertRaises(TypeError):
            self.assertWarnsRegex(1, 'expect')
        with self.assertRaises(TypeError):

            

Reported by Pylint.

No value for argument 'expected_warning' in method call
Error

Line: 1582 Column: 13

              
    def testAssertWarnsRegexNoExceptionType(self):
        with self.assertRaises(TypeError):
            self.assertWarnsRegex()
        with self.assertRaises(TypeError):
            self.assertWarnsRegex(UserWarning)
        with self.assertRaises(TypeError):
            self.assertWarnsRegex(1, 'expect')
        with self.assertRaises(TypeError):

            

Reported by Pylint.

Lib/test/test_asyncio/test_proactor_events.py
435 issues
Instance of 'TestProtocol' has no 'data_received' member
Error

Line: 63 Column: 26

                      tr = self.socket_transport()
        tr._loop_reading()
        self.loop._proactor.recv_into.assert_called_with(self.sock, bytearray(self.buffer_size))
        self.assertFalse(self.protocol.data_received.called)
        self.assertFalse(self.protocol.eof_received.called)

    def test_loop_reading_data(self):
        buf = b'data'
        res = self.loop.create_future()

            

Reported by Pylint.

Instance of 'TestProtocol' has no 'eof_received' member
Error

Line: 64 Column: 26

                      tr._loop_reading()
        self.loop._proactor.recv_into.assert_called_with(self.sock, bytearray(self.buffer_size))
        self.assertFalse(self.protocol.data_received.called)
        self.assertFalse(self.protocol.eof_received.called)

    def test_loop_reading_data(self):
        buf = b'data'
        res = self.loop.create_future()
        res.set_result(len(buf))

            

Reported by Pylint.

Instance of 'TestProtocol' has no 'data_received' member
Error

Line: 78 Column: 9

                      called_buf = bytearray(self.buffer_size)
        called_buf[:len(buf)] = buf
        self.loop._proactor.recv_into.assert_called_with(self.sock, called_buf)
        self.protocol.data_received.assert_called_with(bytearray(buf))

    def test_loop_reading_no_data(self):
        res = self.loop.create_future()
        res.set_result(0)


            

Reported by Pylint.

Instance of 'TestProtocol' has no 'eof_received' member
Error

Line: 91 Column: 25

                      tr._read_fut = res
        tr._loop_reading(res)
        self.assertFalse(self.loop._proactor.recv_into.called)
        self.assertTrue(self.protocol.eof_received.called)
        self.assertTrue(tr.close.called)

    def test_loop_reading_aborted(self):
        err = self.loop._proactor.recv_into.side_effect = ConnectionAbortedError()


            

Reported by Pylint.

Method 'connection_lost' has no 'assert_called_with' member
Error

Line: 209 Column: 9

                      tr._loop_writing(fut)
        self.assertIsNone(tr._write_fut)
        test_utils.run_briefly(self.loop)
        self.protocol.connection_lost.assert_called_with(None)

    def test_abort(self):
        tr = self.socket_transport()
        tr._force_close = mock.Mock()
        tr.abort()

            

Reported by Pylint.

Method 'connection_lost' has no 'assert_called_with' member
Error

Line: 221 Column: 9

                      tr = self.socket_transport()
        tr.close()
        test_utils.run_briefly(self.loop)
        self.protocol.connection_lost.assert_called_with(None)
        self.assertTrue(tr.is_closing())
        self.assertEqual(tr._conn_lost, 1)

        self.protocol.connection_lost.reset_mock()
        tr.close()

            

Reported by Pylint.

Method 'connection_lost' has no 'reset_mock' member
Error

Line: 225 Column: 9

                      self.assertTrue(tr.is_closing())
        self.assertEqual(tr._conn_lost, 1)

        self.protocol.connection_lost.reset_mock()
        tr.close()
        test_utils.run_briefly(self.loop)
        self.assertFalse(self.protocol.connection_lost.called)

    def test_close_write_fut(self):

            

Reported by Pylint.

Method 'connection_lost' has no 'called' member
Error

Line: 228 Column: 26

                      self.protocol.connection_lost.reset_mock()
        tr.close()
        test_utils.run_briefly(self.loop)
        self.assertFalse(self.protocol.connection_lost.called)

    def test_close_write_fut(self):
        tr = self.socket_transport()
        tr._write_fut = mock.Mock()
        tr.close()

            

Reported by Pylint.

Method 'connection_lost' has no 'called' member
Error

Line: 235 Column: 26

                      tr._write_fut = mock.Mock()
        tr.close()
        test_utils.run_briefly(self.loop)
        self.assertFalse(self.protocol.connection_lost.called)

    def test_close_buffer(self):
        tr = self.socket_transport()
        tr._buffer = [b'data']
        tr.close()

            

Reported by Pylint.

Method 'connection_lost' has no 'called' member
Error

Line: 242 Column: 26

                      tr._buffer = [b'data']
        tr.close()
        test_utils.run_briefly(self.loop)
        self.assertFalse(self.protocol.connection_lost.called)

    @mock.patch('asyncio.base_events.logger')
    def test_fatal_error(self, m_logging):
        tr = self.socket_transport()
        tr._force_close = mock.Mock()

            

Reported by Pylint.

Lib/test/test_asyncio/test_events.py
434 issues
Generator 'generator' has no 'address' member
Error

Line: 521 Column: 51

                  def test_create_connection(self):
        with test_utils.run_test_server() as httpd:
            conn_fut = self.loop.create_connection(
                lambda: MyProto(loop=self.loop), *httpd.address)
            self._basetest_create_connection(conn_fut)

    @socket_helper.skip_unless_bind_unix_socket
    def test_create_unix_connection(self):
        # Issue #20682: On Mac OS X Tiger, getsockname() returns a

            

Reported by Pylint.

Generator 'generator' has no 'address' member
Error

Line: 532 Column: 50

              
        with test_utils.run_test_unix_server() as httpd:
            conn_fut = self.loop.create_unix_connection(
                lambda: MyProto(loop=self.loop), httpd.address)
            self._basetest_create_connection(conn_fut, check_sockname)

    def check_ssl_extra_info(self, client, check_sockname=True,
                             peername=None, peercert={}):
        if check_sockname:

            

Reported by Pylint.

Generator 'generator' has no 'address' member
Error

Line: 622 Column: 18

                          create_connection = functools.partial(
                self.loop.create_connection,
                lambda: MyProto(loop=self.loop),
                *httpd.address)
            self._test_create_ssl_connection(httpd, create_connection,
                                             peername=httpd.address)

    @socket_helper.skip_unless_bind_unix_socket
    @unittest.skipIf(ssl is None, 'No ssl module')

            

Reported by Pylint.

Generator 'generator' has no 'address' member
Error

Line: 624 Column: 55

                              lambda: MyProto(loop=self.loop),
                *httpd.address)
            self._test_create_ssl_connection(httpd, create_connection,
                                             peername=httpd.address)

    @socket_helper.skip_unless_bind_unix_socket
    @unittest.skipIf(ssl is None, 'No ssl module')
    def test_create_ssl_unix_connection(self):
        # Issue #20682: On Mac OS X Tiger, getsockname() returns a

            

Reported by Pylint.

Generator 'generator' has no 'address' member
Error

Line: 636 Column: 50

                      with test_utils.run_test_unix_server(use_ssl=True) as httpd:
            create_connection = functools.partial(
                self.loop.create_unix_connection,
                lambda: MyProto(loop=self.loop), httpd.address,
                server_hostname='127.0.0.1')

            self._test_create_ssl_connection(httpd, create_connection,
                                             check_sockname,
                                             peername=httpd.address)

            

Reported by Pylint.

Generator 'generator' has no 'address' member
Error

Line: 641 Column: 55

              
            self._test_create_ssl_connection(httpd, create_connection,
                                             check_sockname,
                                             peername=httpd.address)

    def test_create_connection_local_addr(self):
        with test_utils.run_test_server() as httpd:
            port = socket_helper.find_unused_port()
            f = self.loop.create_connection(

            

Reported by Pylint.

Generator 'generator' has no 'address' member
Error

Line: 648 Column: 18

                          port = socket_helper.find_unused_port()
            f = self.loop.create_connection(
                lambda: MyProto(loop=self.loop),
                *httpd.address, local_addr=(httpd.address[0], port))
            tr, pr = self.loop.run_until_complete(f)
            expected = pr.transport.get_extra_info('sockname')[1]
            self.assertEqual(port, expected)
            tr.close()


            

Reported by Pylint.

Generator 'generator' has no 'address' member
Error

Line: 648 Column: 45

                          port = socket_helper.find_unused_port()
            f = self.loop.create_connection(
                lambda: MyProto(loop=self.loop),
                *httpd.address, local_addr=(httpd.address[0], port))
            tr, pr = self.loop.run_until_complete(f)
            expected = pr.transport.get_extra_info('sockname')[1]
            self.assertEqual(port, expected)
            tr.close()


            

Reported by Pylint.

Generator 'generator' has no 'address' member
Error

Line: 658 Column: 44

                      with test_utils.run_test_server() as httpd:
            f = self.loop.create_connection(
                lambda: MyProto(loop=self.loop),
                *httpd.address, local_addr=httpd.address)
            with self.assertRaises(OSError) as cm:
                self.loop.run_until_complete(f)
            self.assertEqual(cm.exception.errno, errno.EADDRINUSE)
            self.assertIn(str(httpd.address), cm.exception.strerror)


            

Reported by Pylint.

Generator 'generator' has no 'address' member
Error

Line: 658 Column: 18

                      with test_utils.run_test_server() as httpd:
            f = self.loop.create_connection(
                lambda: MyProto(loop=self.loop),
                *httpd.address, local_addr=httpd.address)
            with self.assertRaises(OSError) as cm:
                self.loop.run_until_complete(f)
            self.assertEqual(cm.exception.errno, errno.EADDRINUSE)
            self.assertIn(str(httpd.address), cm.exception.strerror)


            

Reported by Pylint.

Lib/test/test_sax.py
432 issues
Instance of 'XmlgenTest' has no 'ioclass' member
Error

Line: 437 Column: 18

              
class XmlgenTest:
    def test_xmlgen_basic(self):
        result = self.ioclass()
        gen = XMLGenerator(result)
        gen.startDocument()
        gen.startElement("doc", {})
        gen.endElement("doc")
        gen.endDocument()

            

Reported by Pylint.

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

Line: 444 Column: 9

                      gen.endElement("doc")
        gen.endDocument()

        self.assertEqual(result.getvalue(), self.xml("<doc></doc>"))

    def test_xmlgen_basic_empty(self):
        result = self.ioclass()
        gen = XMLGenerator(result, short_empty_elements=True)
        gen.startDocument()

            

Reported by Pylint.

Instance of 'XmlgenTest' has no 'xml' member
Error

Line: 444 Column: 45

                      gen.endElement("doc")
        gen.endDocument()

        self.assertEqual(result.getvalue(), self.xml("<doc></doc>"))

    def test_xmlgen_basic_empty(self):
        result = self.ioclass()
        gen = XMLGenerator(result, short_empty_elements=True)
        gen.startDocument()

            

Reported by Pylint.

Instance of 'XmlgenTest' has no 'ioclass' member
Error

Line: 447 Column: 18

                      self.assertEqual(result.getvalue(), self.xml("<doc></doc>"))

    def test_xmlgen_basic_empty(self):
        result = self.ioclass()
        gen = XMLGenerator(result, short_empty_elements=True)
        gen.startDocument()
        gen.startElement("doc", {})
        gen.endElement("doc")
        gen.endDocument()

            

Reported by Pylint.

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

Line: 454 Column: 9

                      gen.endElement("doc")
        gen.endDocument()

        self.assertEqual(result.getvalue(), self.xml("<doc/>"))

    def test_xmlgen_content(self):
        result = self.ioclass()
        gen = XMLGenerator(result)


            

Reported by Pylint.

Instance of 'XmlgenTest' has no 'xml' member
Error

Line: 454 Column: 45

                      gen.endElement("doc")
        gen.endDocument()

        self.assertEqual(result.getvalue(), self.xml("<doc/>"))

    def test_xmlgen_content(self):
        result = self.ioclass()
        gen = XMLGenerator(result)


            

Reported by Pylint.

Instance of 'XmlgenTest' has no 'ioclass' member
Error

Line: 457 Column: 18

                      self.assertEqual(result.getvalue(), self.xml("<doc/>"))

    def test_xmlgen_content(self):
        result = self.ioclass()
        gen = XMLGenerator(result)

        gen.startDocument()
        gen.startElement("doc", {})
        gen.characters("huhei")

            

Reported by Pylint.

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

Line: 466 Column: 9

                      gen.endElement("doc")
        gen.endDocument()

        self.assertEqual(result.getvalue(), self.xml("<doc>huhei</doc>"))

    def test_xmlgen_content_empty(self):
        result = self.ioclass()
        gen = XMLGenerator(result, short_empty_elements=True)


            

Reported by Pylint.

Instance of 'XmlgenTest' has no 'xml' member
Error

Line: 466 Column: 45

                      gen.endElement("doc")
        gen.endDocument()

        self.assertEqual(result.getvalue(), self.xml("<doc>huhei</doc>"))

    def test_xmlgen_content_empty(self):
        result = self.ioclass()
        gen = XMLGenerator(result, short_empty_elements=True)


            

Reported by Pylint.

Instance of 'XmlgenTest' has no 'ioclass' member
Error

Line: 469 Column: 18

                      self.assertEqual(result.getvalue(), self.xml("<doc>huhei</doc>"))

    def test_xmlgen_content_empty(self):
        result = self.ioclass()
        gen = XMLGenerator(result, short_empty_elements=True)

        gen.startDocument()
        gen.startElement("doc", {})
        gen.characters("huhei")

            

Reported by Pylint.

Lib/test/test_argparse.py
424 issues
Super of 'MEPBase' has no 'get_parser' member
Error

Line: 2979 Column: 18

              class MEPBase(object):

    def get_parser(self, required=None):
        parent = super(MEPBase, self).get_parser(required=required)
        parser = ErrorRaisingArgumentParser(
            prog=parent.prog, add_help=False, parents=[parent])
        return parser



            

Reported by Pylint.

Method should have "self" as first argument
Error

Line: 4440 Column: 5

              
class TestHelpMetavarTypeFormatter(HelpTestCase):

    def custom_type(string):
        return string

    parser_signature = Sig(prog='PROG', description='description',
                           formatter_class=argparse.MetavarTypeHelpFormatter)
    argument_signatures = [Sig('a', type=int),

            

Reported by Pylint.

Unused variable 'root'
Error

Line: 41 Column: 13

              
    def tearDown(self):
        os.chdir(self.old_dir)
        for root, dirs, files in os.walk(self.temp_dir, topdown=False):
            for name in files:
                os.chmod(os.path.join(self.temp_dir, name), stat.S_IWRITE)
        shutil.rmtree(self.temp_dir, True)

    def create_readonly_file(self, filename):

            

Reported by Pylint.

Unused variable 'dirs'
Error

Line: 41 Column: 19

              
    def tearDown(self):
        os.chdir(self.old_dir)
        for root, dirs, files in os.walk(self.temp_dir, topdown=False):
            for name in files:
                os.chmod(os.path.join(self.temp_dir, name), stat.S_IWRITE)
        shutil.rmtree(self.temp_dir, True)

    def create_readonly_file(self, filename):

            

Reported by Pylint.

Redefining built-in 'exit'
Error

Line: 123 Column: 9

                      return stderr_to_parser_error(parse_args, *args, **kwargs)

    def exit(self, *args, **kwargs):
        exit = super(ErrorRaisingArgumentParser, self).exit
        return stderr_to_parser_error(exit, *args, **kwargs)

    def error(self, *args, **kwargs):
        error = super(ErrorRaisingArgumentParser, self).error
        return stderr_to_parser_error(error, *args, **kwargs)

            

Reported by Pylint.

Redefining name 'bases' from outer scope (line 244)
Error

Line: 147 Column: 29

                      remaining unparsed arguments
    """

    def __init__(cls, name, bases, bodydict):
        if name == 'ParserTestCase':
            return

        # default parser signature is empty
        if not hasattr(cls, 'parser_signature'):

            

Reported by Pylint.

Unused argument 'bodydict'
Error

Line: 147 Column: 36

                      remaining unparsed arguments
    """

    def __init__(cls, name, bases, bodydict):
        if name == 'ParserTestCase':
            return

        # default parser signature is empty
        if not hasattr(cls, 'parser_signature'):

            

Reported by Pylint.

__init__ method from base class 'type' is not called
Error

Line: 147 Column: 5

                      remaining unparsed arguments
    """

    def __init__(cls, name, bases, bodydict):
        if name == 'ParserTestCase':
            return

        # default parser signature is empty
        if not hasattr(cls, 'parser_signature'):

            

Reported by Pylint.

Unused argument 'bases'
Error

Line: 147 Column: 29

                      remaining unparsed arguments
    """

    def __init__(cls, name, bases, bodydict):
        if name == 'ParserTestCase':
            return

        # default parser signature is empty
        if not hasattr(cls, 'parser_signature'):

            

Reported by Pylint.

Redefining built-in 'type'
Error

Line: 1548 Column: 9

              class TestFileTypeRepr(TestCase):

    def test_r(self):
        type = argparse.FileType('r')
        self.assertEqual("FileType('r')", repr(type))

    def test_wb_1(self):
        type = argparse.FileType('wb', 1)
        self.assertEqual("FileType('wb', 1)", repr(type))

            

Reported by Pylint.

Lib/socket.py
420 issues
Undefined variable name 'SocketKind' in __all__
Error

Line: 66 Column: 51

              EWOULDBLOCK = getattr(errno, 'EWOULDBLOCK', 11)

__all__ = ["fromfd", "getfqdn", "create_connection", "create_server",
           "has_dualstack_ipv6", "AddressFamily", "SocketKind"]
__all__.extend(os._get_exports_list(_socket))

# Set up the socket.AF_* socket.SOCK_* constants as members of IntEnums for
# nicer string representations.
# Note that _socket only knows about the integer values. The public interface

            

Reported by Pylint.

Undefined variable name 'AddressFamily' in __all__
Error

Line: 66 Column: 34

              EWOULDBLOCK = getattr(errno, 'EWOULDBLOCK', 11)

__all__ = ["fromfd", "getfqdn", "create_connection", "create_server",
           "has_dualstack_ipv6", "AddressFamily", "SocketKind"]
__all__.extend(os._get_exports_list(_socket))

# Set up the socket.AF_* socket.SOCK_* constants as members of IntEnums for
# nicer string representations.
# Note that _socket only knows about the integer values. The public interface

            

Reported by Pylint.

class already defined line 52
Error

Line: 214 Column: 1

              class _GiveupOnSendfile(Exception): pass


class socket(_socket.socket):

    """A subclass of _socket.socket adding the makefile() method."""

    __slots__ = ["__weakref__", "_io_refs", "_closed"]


            

Reported by Pylint.

Undefined variable 'AddressFamily'
Error

Line: 518 Column: 51

                  def family(self):
        """Read-only access to the address family for this socket.
        """
        return _intenum_converter(super().family, AddressFamily)

    @property
    def type(self):
        """Read-only access to the socket type.
        """

            

Reported by Pylint.

Undefined variable 'SocketKind'
Error

Line: 524 Column: 49

                  def type(self):
        """Read-only access to the socket type.
        """
        return _intenum_converter(super().type, SocketKind)

    if os.name == 'nt':
        def get_inheritable(self):
            return os.get_handle_inheritable(self.fileno())
        def set_inheritable(self, inheritable):

            

Reported by Pylint.

Module 'os' has no 'get_handle_inheritable' member
Error

Line: 528 Column: 20

              
    if os.name == 'nt':
        def get_inheritable(self):
            return os.get_handle_inheritable(self.fileno())
        def set_inheritable(self, inheritable):
            os.set_handle_inheritable(self.fileno(), inheritable)
    else:
        def get_inheritable(self):
            return os.get_inheritable(self.fileno())

            

Reported by Pylint.

Module 'os' has no 'set_handle_inheritable' member
Error

Line: 530 Column: 13

                      def get_inheritable(self):
            return os.get_handle_inheritable(self.fileno())
        def set_inheritable(self, inheritable):
            os.set_handle_inheritable(self.fileno(), inheritable)
    else:
        def get_inheritable(self):
            return os.get_inheritable(self.fileno())
        def set_inheritable(self, inheritable):
            os.set_inheritable(self.fileno(), inheritable)

            

Reported by Pylint.

function already defined line 52
Error

Line: 594 Column: 5

              
if hasattr(_socket, "socketpair"):

    def socketpair(family=None, type=SOCK_STREAM, proto=0):
        """socketpair([family[, type[, proto]]]) -> (socket object, socket object)

        Create a pair of socket objects from the sockets returned by the platform
        socketpair() function.
        The arguments are the same as for socket() except the default family is

            

Reported by Pylint.

function already defined line 52
Error

Line: 615 Column: 5

              else:

    # Origin: https://gist.github.com/4325783, by Geert Jansen.  Public domain.
    def socketpair(family=AF_INET, type=SOCK_STREAM, proto=0):
        if family == AF_INET:
            host = _LOCALHOST
        elif family == AF_INET6:
            host = _LOCALHOST_V6
        else:

            

Reported by Pylint.

function already defined line 52
Error

Line: 937 Column: 1

                      raise


def getaddrinfo(host, port, family=0, type=0, proto=0, flags=0):
    """Resolve host and port into list of address info entries.

    Translate the host/port argument into a sequence of 5-tuples that contain
    all the necessary arguments for creating a socket connected to that service.
    host is a domain name, a string representation of an IPv4/v6 address or

            

Reported by Pylint.

Lib/test/test_ipaddress.py
418 issues
Instance of 'CommonTestMixin_v4' has no 'subTest' member
Error

Line: 112 Column: 18

                          "1.2.3.040",
        ]
        for address in addresses:
            with self.subTest(address=address):
                with self.assertAddressError(msg):
                    self.factory(address)

    def test_int(self):
        self.assertInstancesEqual(0, "0.0.0.0")

            

Reported by Pylint.

Instance of 'CommonTestMixin_v4' has no 'assertAddressError' member
Error

Line: 113 Column: 22

                      ]
        for address in addresses:
            with self.subTest(address=address):
                with self.assertAddressError(msg):
                    self.factory(address)

    def test_int(self):
        self.assertInstancesEqual(0, "0.0.0.0")
        self.assertInstancesEqual(3232235521, "192.168.0.1")

            

Reported by Pylint.

Instance of 'CommonTestMixin_v4' has no 'factory' member
Error

Line: 114 Column: 21

                      for address in addresses:
            with self.subTest(address=address):
                with self.assertAddressError(msg):
                    self.factory(address)

    def test_int(self):
        self.assertInstancesEqual(0, "0.0.0.0")
        self.assertInstancesEqual(3232235521, "192.168.0.1")


            

Reported by Pylint.

Instance of 'CommonTestMixin_v4' has no 'assertInstancesEqual' member
Error

Line: 117 Column: 9

                                  self.factory(address)

    def test_int(self):
        self.assertInstancesEqual(0, "0.0.0.0")
        self.assertInstancesEqual(3232235521, "192.168.0.1")

    def test_packed(self):
        self.assertInstancesEqual(bytes.fromhex("00000000"), "0.0.0.0")
        self.assertInstancesEqual(bytes.fromhex("c0a80001"), "192.168.0.1")

            

Reported by Pylint.

Instance of 'CommonTestMixin_v4' has no 'assertInstancesEqual' member
Error

Line: 118 Column: 9

              
    def test_int(self):
        self.assertInstancesEqual(0, "0.0.0.0")
        self.assertInstancesEqual(3232235521, "192.168.0.1")

    def test_packed(self):
        self.assertInstancesEqual(bytes.fromhex("00000000"), "0.0.0.0")
        self.assertInstancesEqual(bytes.fromhex("c0a80001"), "192.168.0.1")


            

Reported by Pylint.

Instance of 'CommonTestMixin_v4' has no 'assertInstancesEqual' member
Error

Line: 121 Column: 9

                      self.assertInstancesEqual(3232235521, "192.168.0.1")

    def test_packed(self):
        self.assertInstancesEqual(bytes.fromhex("00000000"), "0.0.0.0")
        self.assertInstancesEqual(bytes.fromhex("c0a80001"), "192.168.0.1")

    def test_negative_ints_rejected(self):
        msg = "-1 (< 0) is not permitted as an IPv4 address"
        with self.assertAddressError(re.escape(msg)):

            

Reported by Pylint.

Instance of 'CommonTestMixin_v4' has no 'assertInstancesEqual' member
Error

Line: 122 Column: 9

              
    def test_packed(self):
        self.assertInstancesEqual(bytes.fromhex("00000000"), "0.0.0.0")
        self.assertInstancesEqual(bytes.fromhex("c0a80001"), "192.168.0.1")

    def test_negative_ints_rejected(self):
        msg = "-1 (< 0) is not permitted as an IPv4 address"
        with self.assertAddressError(re.escape(msg)):
            self.factory(-1)

            

Reported by Pylint.

Instance of 'CommonTestMixin_v4' has no 'assertAddressError' member
Error

Line: 126 Column: 14

              
    def test_negative_ints_rejected(self):
        msg = "-1 (< 0) is not permitted as an IPv4 address"
        with self.assertAddressError(re.escape(msg)):
            self.factory(-1)

    def test_large_ints_rejected(self):
        msg = "%d (>= 2**32) is not permitted as an IPv4 address"
        with self.assertAddressError(re.escape(msg % 2**32)):

            

Reported by Pylint.

Instance of 'CommonTestMixin_v4' has no 'factory' member
Error

Line: 127 Column: 13

                  def test_negative_ints_rejected(self):
        msg = "-1 (< 0) is not permitted as an IPv4 address"
        with self.assertAddressError(re.escape(msg)):
            self.factory(-1)

    def test_large_ints_rejected(self):
        msg = "%d (>= 2**32) is not permitted as an IPv4 address"
        with self.assertAddressError(re.escape(msg % 2**32)):
            self.factory(2**32)

            

Reported by Pylint.

Instance of 'CommonTestMixin_v4' has no 'assertAddressError' member
Error

Line: 131 Column: 14

              
    def test_large_ints_rejected(self):
        msg = "%d (>= 2**32) is not permitted as an IPv4 address"
        with self.assertAddressError(re.escape(msg % 2**32)):
            self.factory(2**32)

    def test_bad_packed_length(self):
        def assertBadLength(length):
            addr = b'\0' * length

            

Reported by Pylint.