The following issues were found
Lib/test/list_tests.py
283 issues
Line: 17
Column: 26
def test_init(self):
# Iterable arg is optional
self.assertEqual(self.type2test([]), self.type2test())
# Init clears previous values
a = self.type2test([1, 2, 3])
a.__init__()
self.assertEqual(a, self.type2test([]))
Reported by Pylint.
Line: 17
Column: 46
def test_init(self):
# Iterable arg is optional
self.assertEqual(self.type2test([]), self.type2test())
# Init clears previous values
a = self.type2test([1, 2, 3])
a.__init__()
self.assertEqual(a, self.type2test([]))
Reported by Pylint.
Line: 20
Column: 13
self.assertEqual(self.type2test([]), self.type2test())
# Init clears previous values
a = self.type2test([1, 2, 3])
a.__init__()
self.assertEqual(a, self.type2test([]))
# Init overwrites previous values
a = self.type2test([1, 2, 3])
Reported by Pylint.
Line: 22
Column: 29
# Init clears previous values
a = self.type2test([1, 2, 3])
a.__init__()
self.assertEqual(a, self.type2test([]))
# Init overwrites previous values
a = self.type2test([1, 2, 3])
a.__init__([4, 5, 6])
self.assertEqual(a, self.type2test([4, 5, 6]))
Reported by Pylint.
Line: 25
Column: 13
self.assertEqual(a, self.type2test([]))
# Init overwrites previous values
a = self.type2test([1, 2, 3])
a.__init__([4, 5, 6])
self.assertEqual(a, self.type2test([4, 5, 6]))
# Mutables always return a new object
b = self.type2test(a)
Reported by Pylint.
Line: 27
Column: 29
# Init overwrites previous values
a = self.type2test([1, 2, 3])
a.__init__([4, 5, 6])
self.assertEqual(a, self.type2test([4, 5, 6]))
# Mutables always return a new object
b = self.type2test(a)
self.assertNotEqual(id(a), id(b))
self.assertEqual(a, b)
Reported by Pylint.
Line: 30
Column: 13
self.assertEqual(a, self.type2test([4, 5, 6]))
# Mutables always return a new object
b = self.type2test(a)
self.assertNotEqual(id(a), id(b))
self.assertEqual(a, b)
def test_getitem_error(self):
a = []
Reported by Pylint.
Line: 38
Column: 13
a = []
msg = "list indices must be integers or slices"
with self.assertRaisesRegex(TypeError, msg):
a['a']
def test_setitem_error(self):
a = []
msg = "list indices must be integers or slices"
with self.assertRaisesRegex(TypeError, msg):
Reported by Pylint.
Line: 44
Column: 13
a = []
msg = "list indices must be integers or slices"
with self.assertRaisesRegex(TypeError, msg):
a['a'] = "python"
def test_repr(self):
l0 = []
l2 = [0, 1, 2]
a0 = self.type2test(l0)
Reported by Pylint.
Line: 49
Column: 14
def test_repr(self):
l0 = []
l2 = [0, 1, 2]
a0 = self.type2test(l0)
a2 = self.type2test(l2)
self.assertEqual(str(a0), str(l0))
self.assertEqual(repr(a0), repr(l0))
self.assertEqual(repr(a2), repr(l2))
Reported by Pylint.
Lib/ssl.py
280 issues
Line: 153
Column: 48
lambda name: name.startswith('CERT_'),
source=_ssl)
PROTOCOL_SSLv23 = _SSLMethod.PROTOCOL_SSLv23 = _SSLMethod.PROTOCOL_TLS
_PROTOCOL_NAMES = {value: name for name, value in _SSLMethod.__members__.items()}
_SSLv2_IF_EXISTS = getattr(_SSLMethod, 'PROTOCOL_SSLv2', None)
Reported by Pylint.
Line: 153
Column: 19
lambda name: name.startswith('CERT_'),
source=_ssl)
PROTOCOL_SSLv23 = _SSLMethod.PROTOCOL_SSLv23 = _SSLMethod.PROTOCOL_TLS
_PROTOCOL_NAMES = {value: name for name, value in _SSLMethod.__members__.items()}
_SSLv2_IF_EXISTS = getattr(_SSLMethod, 'PROTOCOL_SSLv2', None)
Reported by Pylint.
Line: 154
Column: 51
source=_ssl)
PROTOCOL_SSLv23 = _SSLMethod.PROTOCOL_SSLv23 = _SSLMethod.PROTOCOL_TLS
_PROTOCOL_NAMES = {value: name for name, value in _SSLMethod.__members__.items()}
_SSLv2_IF_EXISTS = getattr(_SSLMethod, 'PROTOCOL_SSLv2', None)
@_simple_enum(_IntEnum)
Reported by Pylint.
Line: 156
Column: 28
PROTOCOL_SSLv23 = _SSLMethod.PROTOCOL_SSLv23 = _SSLMethod.PROTOCOL_TLS
_PROTOCOL_NAMES = {value: name for name, value in _SSLMethod.__members__.items()}
_SSLv2_IF_EXISTS = getattr(_SSLMethod, 'PROTOCOL_SSLv2', None)
@_simple_enum(_IntEnum)
class TLSVersion:
MINIMUM_SUPPORTED = _ssl.PROTO_MINIMUM_SUPPORTED
Reported by Pylint.
Line: 258
Column: 5
if sys.platform == "win32":
from _ssl import enum_certificates, enum_crls
from socket import socket, SOCK_STREAM, create_connection
from socket import SOL_SOCKET, SO_TYPE, _GLOBAL_DEFAULT_TIMEOUT
import socket as _socket
import base64 # for DER-to-PEM translation
Reported by Pylint.
Line: 258
Column: 5
if sys.platform == "win32":
from _ssl import enum_certificates, enum_crls
from socket import socket, SOCK_STREAM, create_connection
from socket import SOL_SOCKET, SO_TYPE, _GLOBAL_DEFAULT_TIMEOUT
import socket as _socket
import base64 # for DER-to-PEM translation
Reported by Pylint.
Line: 607
Column: 34
@minimum_version.setter
def minimum_version(self, value):
if value == TLSVersion.SSLv3:
self.options &= ~Options.OP_NO_SSLv3
super(SSLContext, SSLContext).minimum_version.__set__(self, value)
@property
def maximum_version(self):
return TLSVersion(super().maximum_version)
Reported by Pylint.
Line: 608
Column: 13
def minimum_version(self, value):
if value == TLSVersion.SSLv3:
self.options &= ~Options.OP_NO_SSLv3
super(SSLContext, SSLContext).minimum_version.__set__(self, value)
@property
def maximum_version(self):
return TLSVersion(super().maximum_version)
Reported by Pylint.
Line: 616
Column: 13
@maximum_version.setter
def maximum_version(self, value):
super(SSLContext, SSLContext).maximum_version.__set__(self, value)
@property
def options(self):
return Options(super().options)
Reported by Pylint.
Line: 620
Column: 16
@property
def options(self):
return Options(super().options)
@options.setter
def options(self, value):
super(SSLContext, SSLContext).options.__set__(self, value)
Reported by Pylint.
Lib/tkinter/test/test_tkinter/test_widgets.py
280 issues
Line: 26
Column: 18
_conv_pad_pixels = noconv
def test_configure_class(self):
widget = self.create()
self.assertEqual(widget['class'],
widget.__class__.__name__.title())
self.checkInvalidParam(widget, 'class', 'Foo',
errmsg="can't modify -class option after widget is created")
widget2 = self.create(class_='Foo')
Reported by Pylint.
Line: 27
Column: 9
def test_configure_class(self):
widget = self.create()
self.assertEqual(widget['class'],
widget.__class__.__name__.title())
self.checkInvalidParam(widget, 'class', 'Foo',
errmsg="can't modify -class option after widget is created")
widget2 = self.create(class_='Foo')
self.assertEqual(widget2['class'], 'Foo')
Reported by Pylint.
Line: 31
Column: 19
widget.__class__.__name__.title())
self.checkInvalidParam(widget, 'class', 'Foo',
errmsg="can't modify -class option after widget is created")
widget2 = self.create(class_='Foo')
self.assertEqual(widget2['class'], 'Foo')
def test_configure_colormap(self):
widget = self.create()
self.assertEqual(widget['colormap'], '')
Reported by Pylint.
Line: 32
Column: 9
self.checkInvalidParam(widget, 'class', 'Foo',
errmsg="can't modify -class option after widget is created")
widget2 = self.create(class_='Foo')
self.assertEqual(widget2['class'], 'Foo')
def test_configure_colormap(self):
widget = self.create()
self.assertEqual(widget['colormap'], '')
self.checkInvalidParam(widget, 'colormap', 'new',
Reported by Pylint.
Line: 35
Column: 18
self.assertEqual(widget2['class'], 'Foo')
def test_configure_colormap(self):
widget = self.create()
self.assertEqual(widget['colormap'], '')
self.checkInvalidParam(widget, 'colormap', 'new',
errmsg="can't modify -colormap option after widget is created")
widget2 = self.create(colormap='new')
self.assertEqual(widget2['colormap'], 'new')
Reported by Pylint.
Line: 36
Column: 9
def test_configure_colormap(self):
widget = self.create()
self.assertEqual(widget['colormap'], '')
self.checkInvalidParam(widget, 'colormap', 'new',
errmsg="can't modify -colormap option after widget is created")
widget2 = self.create(colormap='new')
self.assertEqual(widget2['colormap'], 'new')
Reported by Pylint.
Line: 39
Column: 19
self.assertEqual(widget['colormap'], '')
self.checkInvalidParam(widget, 'colormap', 'new',
errmsg="can't modify -colormap option after widget is created")
widget2 = self.create(colormap='new')
self.assertEqual(widget2['colormap'], 'new')
def test_configure_container(self):
widget = self.create()
self.assertEqual(widget['container'], 0 if self.wantobjects else '0')
Reported by Pylint.
Line: 40
Column: 9
self.checkInvalidParam(widget, 'colormap', 'new',
errmsg="can't modify -colormap option after widget is created")
widget2 = self.create(colormap='new')
self.assertEqual(widget2['colormap'], 'new')
def test_configure_container(self):
widget = self.create()
self.assertEqual(widget['container'], 0 if self.wantobjects else '0')
self.checkInvalidParam(widget, 'container', 1,
Reported by Pylint.
Line: 43
Column: 18
self.assertEqual(widget2['colormap'], 'new')
def test_configure_container(self):
widget = self.create()
self.assertEqual(widget['container'], 0 if self.wantobjects else '0')
self.checkInvalidParam(widget, 'container', 1,
errmsg="can't modify -container option after widget is created")
widget2 = self.create(container=True)
self.assertEqual(widget2['container'], 1 if self.wantobjects else '1')
Reported by Pylint.
Line: 44
Column: 9
def test_configure_container(self):
widget = self.create()
self.assertEqual(widget['container'], 0 if self.wantobjects else '0')
self.checkInvalidParam(widget, 'container', 1,
errmsg="can't modify -container option after widget is created")
widget2 = self.create(container=True)
self.assertEqual(widget2['container'], 1 if self.wantobjects else '1')
Reported by Pylint.
Lib/test/test_positional_only_arg.py
280 issues
Line: 81
Column: 9
f(1, b=2)
self.assertEqual(f(1, c=2), 13)
def f(a=1, b=10, /, c=100):
return a + b + c
self.assertEqual(f(1, 2, 3), 6)
self.assertEqual(f(1, 2, c=3), 6)
with self.assertRaisesRegex(TypeError, r"f\(\) got some positional-only arguments passed as keyword arguments: 'b'"):
Reported by Pylint.
Line: 107
Column: 9
self.assertEqual(3, f.__code__.co_posonlyargcount)
self.assertEqual((1,), f.__defaults__)
def f(a, b, c=1, /, d=2, e=3, *, f, g=4):
pass
self.assertEqual(5, f.__code__.co_argcount) # 3 posonly + 2 "standard args"
self.assertEqual(3, f.__code__.co_posonlyargcount)
self.assertEqual((1, 2, 3), f.__defaults__)
Reported by Pylint.
Line: 127
Column: 9
with self.assertRaisesRegex(TypeError, expected):
f(a=1)
def f(a, /, b):
pass
expected = r"f\(\) got some positional-only arguments passed as keyword arguments: 'a'"
with self.assertRaisesRegex(TypeError, expected):
f(a=1, b=2)
Reported by Pylint.
Line: 133
Column: 9
with self.assertRaisesRegex(TypeError, expected):
f(a=1, b=2)
def f(a, b, /):
pass
expected = r"f\(\) got some positional-only arguments passed as keyword arguments: 'a, b'"
with self.assertRaisesRegex(TypeError, expected):
f(a=1, b=2)
Reported by Pylint.
Line: 143
Column: 13
def f(a, b, /, c):
pass
with self.assertRaisesRegex(TypeError, r"f\(\) missing 1 required positional argument: 'c'"):
f(1, 2)
with self.assertRaisesRegex(TypeError, r"f\(\) missing 2 required positional arguments: 'b' and 'c'"):
f(1)
with self.assertRaisesRegex(TypeError, r"f\(\) missing 3 required positional arguments: 'a', 'b', and 'c'"):
f()
with self.assertRaisesRegex(TypeError, r"f\(\) takes 3 positional arguments but 4 were given"):
Reported by Pylint.
Line: 145
Column: 13
with self.assertRaisesRegex(TypeError, r"f\(\) missing 1 required positional argument: 'c'"):
f(1, 2)
with self.assertRaisesRegex(TypeError, r"f\(\) missing 2 required positional arguments: 'b' and 'c'"):
f(1)
with self.assertRaisesRegex(TypeError, r"f\(\) missing 3 required positional arguments: 'a', 'b', and 'c'"):
f()
with self.assertRaisesRegex(TypeError, r"f\(\) takes 3 positional arguments but 4 were given"):
f(1, 2, 3, 4)
Reported by Pylint.
Line: 145
Column: 13
with self.assertRaisesRegex(TypeError, r"f\(\) missing 1 required positional argument: 'c'"):
f(1, 2)
with self.assertRaisesRegex(TypeError, r"f\(\) missing 2 required positional arguments: 'b' and 'c'"):
f(1)
with self.assertRaisesRegex(TypeError, r"f\(\) missing 3 required positional arguments: 'a', 'b', and 'c'"):
f()
with self.assertRaisesRegex(TypeError, r"f\(\) takes 3 positional arguments but 4 were given"):
f(1, 2, 3, 4)
Reported by Pylint.
Line: 147
Column: 13
with self.assertRaisesRegex(TypeError, r"f\(\) missing 2 required positional arguments: 'b' and 'c'"):
f(1)
with self.assertRaisesRegex(TypeError, r"f\(\) missing 3 required positional arguments: 'a', 'b', and 'c'"):
f()
with self.assertRaisesRegex(TypeError, r"f\(\) takes 3 positional arguments but 4 were given"):
f(1, 2, 3, 4)
def test_positional_only_and_optional_arg_invalid_calls(self):
def f(a, b, /, c=3):
Reported by Pylint.
Line: 147
Column: 13
with self.assertRaisesRegex(TypeError, r"f\(\) missing 2 required positional arguments: 'b' and 'c'"):
f(1)
with self.assertRaisesRegex(TypeError, r"f\(\) missing 3 required positional arguments: 'a', 'b', and 'c'"):
f()
with self.assertRaisesRegex(TypeError, r"f\(\) takes 3 positional arguments but 4 were given"):
f(1, 2, 3, 4)
def test_positional_only_and_optional_arg_invalid_calls(self):
def f(a, b, /, c=3):
Reported by Pylint.
Line: 147
Column: 13
with self.assertRaisesRegex(TypeError, r"f\(\) missing 2 required positional arguments: 'b' and 'c'"):
f(1)
with self.assertRaisesRegex(TypeError, r"f\(\) missing 3 required positional arguments: 'a', 'b', and 'c'"):
f()
with self.assertRaisesRegex(TypeError, r"f\(\) takes 3 positional arguments but 4 were given"):
f(1, 2, 3, 4)
def test_positional_only_and_optional_arg_invalid_calls(self):
def f(a, b, /, c=3):
Reported by Pylint.
Lib/test/test_smtplib.py
277 issues
Line: 78
Column: 9
def testQuoteData(self):
teststr = "abc\n.jkl\rfoo\r\n..blue"
expected = "abc\r\n..jkl\r\nfoo\r\n...blue"
self.assertEqual(expected, smtplib.quotedata(teststr))
def testBasic1(self):
mock_socket.reply_with(b"220 Hola mundo")
# connects
client = self.client(HOST, self.port)
Reported by Pylint.
Line: 83
Column: 18
def testBasic1(self):
mock_socket.reply_with(b"220 Hola mundo")
# connects
client = self.client(HOST, self.port)
client.close()
def testSourceAddress(self):
mock_socket.reply_with(b"220 Hola mundo")
# connects
Reported by Pylint.
Line: 89
Column: 18
def testSourceAddress(self):
mock_socket.reply_with(b"220 Hola mundo")
# connects
client = self.client(HOST, self.port,
source_address=('127.0.0.1',19876))
self.assertEqual(client.source_address, ('127.0.0.1', 19876))
client.close()
def testBasic2(self):
Reported by Pylint.
Line: 91
Column: 9
# connects
client = self.client(HOST, self.port,
source_address=('127.0.0.1',19876))
self.assertEqual(client.source_address, ('127.0.0.1', 19876))
client.close()
def testBasic2(self):
mock_socket.reply_with(b"220 Hola mundo")
# connects, include port in host name
Reported by Pylint.
Line: 97
Column: 18
def testBasic2(self):
mock_socket.reply_with(b"220 Hola mundo")
# connects, include port in host name
client = self.client("%s:%s" % (HOST, self.port))
client.close()
def testLocalHostName(self):
mock_socket.reply_with(b"220 Hola mundo")
# check that supplied local_hostname is used
Reported by Pylint.
Line: 103
Column: 18
def testLocalHostName(self):
mock_socket.reply_with(b"220 Hola mundo")
# check that supplied local_hostname is used
client = self.client(HOST, self.port, local_hostname="testhost")
self.assertEqual(client.local_hostname, "testhost")
client.close()
def testTimeoutDefault(self):
mock_socket.reply_with(b"220 Hola mundo")
Reported by Pylint.
Line: 104
Column: 9
mock_socket.reply_with(b"220 Hola mundo")
# check that supplied local_hostname is used
client = self.client(HOST, self.port, local_hostname="testhost")
self.assertEqual(client.local_hostname, "testhost")
client.close()
def testTimeoutDefault(self):
mock_socket.reply_with(b"220 Hola mundo")
self.assertIsNone(mock_socket.getdefaulttimeout())
Reported by Pylint.
Line: 109
Column: 9
def testTimeoutDefault(self):
mock_socket.reply_with(b"220 Hola mundo")
self.assertIsNone(mock_socket.getdefaulttimeout())
mock_socket.setdefaulttimeout(30)
self.assertEqual(mock_socket.getdefaulttimeout(), 30)
try:
client = self.client(HOST, self.port)
finally:
Reported by Pylint.
Line: 111
Column: 9
mock_socket.reply_with(b"220 Hola mundo")
self.assertIsNone(mock_socket.getdefaulttimeout())
mock_socket.setdefaulttimeout(30)
self.assertEqual(mock_socket.getdefaulttimeout(), 30)
try:
client = self.client(HOST, self.port)
finally:
mock_socket.setdefaulttimeout(None)
self.assertEqual(client.sock.gettimeout(), 30)
Reported by Pylint.
Line: 113
Column: 22
mock_socket.setdefaulttimeout(30)
self.assertEqual(mock_socket.getdefaulttimeout(), 30)
try:
client = self.client(HOST, self.port)
finally:
mock_socket.setdefaulttimeout(None)
self.assertEqual(client.sock.gettimeout(), 30)
client.close()
Reported by Pylint.
Lib/test/test_bz2.py
275 issues
Line: 30
Column: 5
has_cmdline_bunzip2 = None
def ext_decompress(data):
global has_cmdline_bunzip2
if has_cmdline_bunzip2 is None:
has_cmdline_bunzip2 = bool(shutil.which('bunzip2'))
if has_cmdline_bunzip2:
return subprocess.check_output(['bunzip2'], input=data)
else:
Reported by Pylint.
Line: 160
Column: 17
with BZ2File(self.filename) as bz2f:
text = b''
while True:
str = bz2f.read(10)
if not str:
break
text += str
self.assertEqual(text, self.TEXT)
Reported by Pylint.
Line: 171
Column: 17
with BZ2File(self.filename) as bz2f:
text = b''
while True:
str = bz2f.read(10)
if not str:
break
text += str
self.assertEqual(text, self.TEXT * 5)
Reported by Pylint.
Line: 258
Column: 17
with BZ2File(self.filename, "w") as bz2f:
n = 0
while True:
str = self.TEXT[n*10:(n+1)*10]
if not str:
break
bz2f.write(str)
n += 1
with open(self.filename, 'rb') as f:
Reported by Pylint.
Line: 459
Column: 13
def testOpenDel(self):
self.createTempFile()
for i in range(10000):
o = BZ2File(self.filename)
del o
def testOpenNonexistent(self):
self.assertRaises(OSError, BZ2File, "/non/existent")
Reported by Pylint.
Line: 493
Column: 17
self.fail("__enter__ on a closed file didn't raise an exception")
try:
with BZ2File(self.filename, "wb") as f:
1/0
except ZeroDivisionError:
pass
else:
self.fail("1/0 didn't raise an exception")
Reported by Pylint.
Line: 505
Column: 21
nthreads = 10
with BZ2File(self.filename, 'wb') as f:
def comp():
for i in range(5):
f.write(data)
threads = [threading.Thread(target=comp) for i in range(nthreads)]
with threading_helper.start_threads(threads):
pass
Reported by Pylint.
Line: 568
Column: 30
decomp = BZ2File(BytesIO(bomb))
self.assertEqual(decomp.read(1), b'\0')
max_decomp = 1 + DEFAULT_BUFFER_SIZE
self.assertLessEqual(decomp._buffer.raw.tell(), max_decomp,
"Excessive amount of data was decompressed")
# Tests for a BZ2File wrapping another file object:
Reported by Pylint.
Line: 652
Column: 13
n = 0
data = b''
while True:
str = self.TEXT[n*10:(n+1)*10]
if not str:
break
data += bz2c.compress(str)
n += 1
data += bz2c.flush()
Reported by Pylint.
Line: 699
Column: 13
text = b''
n = 0
while True:
str = self.DATA[n*10:(n+1)*10]
if not str:
break
text += bz2d.decompress(str)
n += 1
self.assertEqual(text, self.TEXT)
Reported by Pylint.
Lib/test/test_genericclass.py
274 issues
Line: 15
Column: 9
return (C,)
c = C()
self.assertEqual(tested, [])
class D(B, c): ...
self.assertEqual(tested[0], ((B, c),))
self.assertEqual(tested[1], {})
def test_mro_entry(self):
tested = []
Reported by Pylint.
Line: 29
Column: 9
return (self.__class__,)
c = C()
self.assertEqual(tested, [])
class D(A, c, B): ...
self.assertEqual(tested[-1], (A, c, B))
self.assertEqual(D.__bases__, (A, C, B))
self.assertEqual(D.__orig_bases__, (A, c, B))
self.assertEqual(D.__mro__, (D, A, C, B, object))
d = D()
Reported by Pylint.
Line: 35
Column: 9
self.assertEqual(D.__orig_bases__, (A, c, B))
self.assertEqual(D.__mro__, (D, A, C, B, object))
d = D()
class E(d): ...
self.assertEqual(tested[-1], (d,))
self.assertEqual(E.__bases__, (D,))
def test_mro_entry_none(self):
tested = []
Reported by Pylint.
Line: 49
Column: 9
return ()
c = C()
self.assertEqual(tested, [])
class D(A, c, B): ...
self.assertEqual(tested[-1], (A, c, B))
self.assertEqual(D.__bases__, (A, B))
self.assertEqual(D.__orig_bases__, (A, c, B))
self.assertEqual(D.__mro__, (D, A, B, object))
class E(c): ...
Reported by Pylint.
Line: 54
Column: 9
self.assertEqual(D.__bases__, (A, B))
self.assertEqual(D.__orig_bases__, (A, c, B))
self.assertEqual(D.__mro__, (D, A, B, object))
class E(c): ...
self.assertEqual(tested[-1], (c,))
self.assertEqual(E.__bases__, (object,))
self.assertEqual(E.__orig_bases__, (c,))
self.assertEqual(E.__mro__, (E, object))
Reported by Pylint.
Line: 69
Column: 9
return (dict,)
c = C()
self.assertEqual(tested, [])
class D(A, c): ...
self.assertEqual(tested[-1], (A, c))
self.assertEqual(D.__bases__, (A, dict))
self.assertEqual(D.__orig_bases__, (A, c))
self.assertEqual(D.__mro__, (D, A, dict, object))
Reported by Pylint.
Line: 83
Column: 9
return (C,)
c = C()
self.assertEqual(tested, [])
class D(c, dict): ...
self.assertEqual(tested[-1], (c, dict))
self.assertEqual(D.__bases__, (C, dict))
self.assertEqual(D.__orig_bases__, (c, dict))
self.assertEqual(D.__mro__, (D, C, dict, object))
Reported by Pylint.
Line: 95
Column: 13
return ()
c = C_too_many()
with self.assertRaises(TypeError):
class D(c): ...
class C_too_few:
def __mro_entries__(self):
return ()
d = C_too_few()
with self.assertRaises(TypeError):
Reported by Pylint.
Line: 101
Column: 13
return ()
d = C_too_few()
with self.assertRaises(TypeError):
class D(d): ...
def test_mro_entry_errors_2(self):
class C_not_callable:
__mro_entries__ = "Surprise!"
c = C_not_callable()
Reported by Pylint.
Line: 101
Column: 13
return ()
d = C_too_few()
with self.assertRaises(TypeError):
class D(d): ...
def test_mro_entry_errors_2(self):
class C_not_callable:
__mro_entries__ = "Surprise!"
c = C_not_callable()
Reported by Pylint.
Lib/sre_parse.py
270 issues
Line: 28
Column: 27
WHITESPACE = frozenset(" \t\n\r\v\f")
_REPEATCODES = frozenset({MIN_REPEAT, MAX_REPEAT})
_UNITCODES = frozenset({ANY, RANGE, IN, LITERAL, NOT_LITERAL, CATEGORY})
ESCAPES = {
r"\a": (LITERAL, ord("\a")),
r"\b": (LITERAL, ord("\b")),
Reported by Pylint.
Line: 28
Column: 39
WHITESPACE = frozenset(" \t\n\r\v\f")
_REPEATCODES = frozenset({MIN_REPEAT, MAX_REPEAT})
_UNITCODES = frozenset({ANY, RANGE, IN, LITERAL, NOT_LITERAL, CATEGORY})
ESCAPES = {
r"\a": (LITERAL, ord("\a")),
r"\b": (LITERAL, ord("\b")),
Reported by Pylint.
Line: 29
Column: 25
WHITESPACE = frozenset(" \t\n\r\v\f")
_REPEATCODES = frozenset({MIN_REPEAT, MAX_REPEAT})
_UNITCODES = frozenset({ANY, RANGE, IN, LITERAL, NOT_LITERAL, CATEGORY})
ESCAPES = {
r"\a": (LITERAL, ord("\a")),
r"\b": (LITERAL, ord("\b")),
r"\f": (LITERAL, ord("\f")),
Reported by Pylint.
Line: 29
Column: 30
WHITESPACE = frozenset(" \t\n\r\v\f")
_REPEATCODES = frozenset({MIN_REPEAT, MAX_REPEAT})
_UNITCODES = frozenset({ANY, RANGE, IN, LITERAL, NOT_LITERAL, CATEGORY})
ESCAPES = {
r"\a": (LITERAL, ord("\a")),
r"\b": (LITERAL, ord("\b")),
r"\f": (LITERAL, ord("\f")),
Reported by Pylint.
Line: 29
Column: 41
WHITESPACE = frozenset(" \t\n\r\v\f")
_REPEATCODES = frozenset({MIN_REPEAT, MAX_REPEAT})
_UNITCODES = frozenset({ANY, RANGE, IN, LITERAL, NOT_LITERAL, CATEGORY})
ESCAPES = {
r"\a": (LITERAL, ord("\a")),
r"\b": (LITERAL, ord("\b")),
r"\f": (LITERAL, ord("\f")),
Reported by Pylint.
Line: 29
Column: 63
WHITESPACE = frozenset(" \t\n\r\v\f")
_REPEATCODES = frozenset({MIN_REPEAT, MAX_REPEAT})
_UNITCODES = frozenset({ANY, RANGE, IN, LITERAL, NOT_LITERAL, CATEGORY})
ESCAPES = {
r"\a": (LITERAL, ord("\a")),
r"\b": (LITERAL, ord("\b")),
r"\f": (LITERAL, ord("\f")),
Reported by Pylint.
Line: 29
Column: 50
WHITESPACE = frozenset(" \t\n\r\v\f")
_REPEATCODES = frozenset({MIN_REPEAT, MAX_REPEAT})
_UNITCODES = frozenset({ANY, RANGE, IN, LITERAL, NOT_LITERAL, CATEGORY})
ESCAPES = {
r"\a": (LITERAL, ord("\a")),
r"\b": (LITERAL, ord("\b")),
r"\f": (LITERAL, ord("\f")),
Reported by Pylint.
Line: 29
Column: 37
WHITESPACE = frozenset(" \t\n\r\v\f")
_REPEATCODES = frozenset({MIN_REPEAT, MAX_REPEAT})
_UNITCODES = frozenset({ANY, RANGE, IN, LITERAL, NOT_LITERAL, CATEGORY})
ESCAPES = {
r"\a": (LITERAL, ord("\a")),
r"\b": (LITERAL, ord("\b")),
r"\f": (LITERAL, ord("\f")),
Reported by Pylint.
Line: 32
Column: 13
_UNITCODES = frozenset({ANY, RANGE, IN, LITERAL, NOT_LITERAL, CATEGORY})
ESCAPES = {
r"\a": (LITERAL, ord("\a")),
r"\b": (LITERAL, ord("\b")),
r"\f": (LITERAL, ord("\f")),
r"\n": (LITERAL, ord("\n")),
r"\r": (LITERAL, ord("\r")),
r"\t": (LITERAL, ord("\t")),
Reported by Pylint.
Line: 33
Column: 13
ESCAPES = {
r"\a": (LITERAL, ord("\a")),
r"\b": (LITERAL, ord("\b")),
r"\f": (LITERAL, ord("\f")),
r"\n": (LITERAL, ord("\n")),
r"\r": (LITERAL, ord("\r")),
r"\t": (LITERAL, ord("\t")),
r"\v": (LITERAL, ord("\v")),
Reported by Pylint.
Lib/test/test_tracemalloc.py
269 issues
Line: 76
Column: 12
return (snapshot, snapshot2)
def frame(filename, lineno):
return tracemalloc._Frame((filename, lineno))
def traceback(*frames):
return tracemalloc.Traceback(frames)
def traceback_lineno(filename, lineno):
Reported by Pylint.
Line: 91
Column: 25
class TestTraceback(unittest.TestCase):
def test_repr(self):
def get_repr(*args) -> str:
return repr(tracemalloc.Traceback(*args))
self.assertEqual(get_repr(()), "<Traceback ()>")
self.assertEqual(get_repr((), 0), "<Traceback () total_nframe=0>")
frames = (("f1", 1), ("f2", 2))
Reported by Pylint.
Line: 279
Column: 9
size1, peak1 = tracemalloc.get_traced_memory()
# reset_peak() resets peak to traced memory: peak2 < peak1
tracemalloc.reset_peak()
size2, peak2 = tracemalloc.get_traced_memory()
self.assertGreaterEqual(peak2, size2)
self.assertLess(peak2, peak1)
# check that peak continue to be updated if new memory is allocated:
Reported by Pylint.
Line: 307
Column: 28
snapshot = tracemalloc.take_snapshot()
# This can vary
self.assertGreater(snapshot.traces[1].traceback.total_nframe, 10)
# write on disk
snapshot.dump(os_helper.TESTFN)
self.addCleanup(os_helper.unlink, os_helper.TESTFN)
Reported by Pylint.
Line: 382
Column: 30
self.assertEqual(snapshot.traceback_limit, 5)
self.assertEqual(len(snapshot.traces), 1)
trace = snapshot.traces[0]
self.assertEqual(trace.size, 5)
self.assertEqual(trace.traceback.total_nframe, 10)
self.assertEqual(len(trace.traceback), 1)
self.assertEqual(trace.traceback[0].filename, 'a.py')
self.assertEqual(trace.traceback[0].lineno, 2)
Reported by Pylint.
Line: 383
Column: 30
self.assertEqual(len(snapshot.traces), 1)
trace = snapshot.traces[0]
self.assertEqual(trace.size, 5)
self.assertEqual(trace.traceback.total_nframe, 10)
self.assertEqual(len(trace.traceback), 1)
self.assertEqual(trace.traceback[0].filename, 'a.py')
self.assertEqual(trace.traceback[0].lineno, 2)
def test_filter_traces(self):
Reported by Pylint.
Line: 384
Column: 34
trace = snapshot.traces[0]
self.assertEqual(trace.size, 5)
self.assertEqual(trace.traceback.total_nframe, 10)
self.assertEqual(len(trace.traceback), 1)
self.assertEqual(trace.traceback[0].filename, 'a.py')
self.assertEqual(trace.traceback[0].lineno, 2)
def test_filter_traces(self):
snapshot, snapshot2 = create_snapshots()
Reported by Pylint.
Line: 385
Column: 30
self.assertEqual(trace.size, 5)
self.assertEqual(trace.traceback.total_nframe, 10)
self.assertEqual(len(trace.traceback), 1)
self.assertEqual(trace.traceback[0].filename, 'a.py')
self.assertEqual(trace.traceback[0].lineno, 2)
def test_filter_traces(self):
snapshot, snapshot2 = create_snapshots()
filter1 = tracemalloc.Filter(False, "b.py")
Reported by Pylint.
Line: 386
Column: 30
self.assertEqual(trace.traceback.total_nframe, 10)
self.assertEqual(len(trace.traceback), 1)
self.assertEqual(trace.traceback[0].filename, 'a.py')
self.assertEqual(trace.traceback[0].lineno, 2)
def test_filter_traces(self):
snapshot, snapshot2 = create_snapshots()
filter1 = tracemalloc.Filter(False, "b.py")
filter2 = tracemalloc.Filter(True, "a.py", 2)
Reported by Pylint.
Line: 610
Column: 21
snapshot, snapshot2 = create_snapshots()
trace = snapshot.traces[0]
self.assertEqual(str(trace), 'b.py:4: 10 B')
traceback = trace.traceback
self.assertEqual(str(traceback), 'b.py:4')
frame = traceback[0]
self.assertEqual(str(frame), 'b.py:4')
def test_statistic_format(self):
Reported by Pylint.
Lib/test/test_imaplib.py
269 issues
Line: 226
Column: 17
"""
self.close_request(request)
self.server_close()
raise
self.addCleanup(self._cleanup)
self.server = self.server_class((socket_helper.HOST, 0), imap_handler)
self.thread = threading.Thread(
name=self._testMethodName+'-server',
Reported by Pylint.
Line: 594
Column: 17
def handle_error(self, request, client_address):
self.close_request(request)
self.server_close()
raise
if verbose:
print("creating server")
server = MyServer(addr, hdlr)
self.assertEqual(server.server_address, server.socket.getsockname())
Reported by Pylint.
Line: 923
Column: 34
with self.reaped_server(SimpleIMAPHandler) as server:
with self.imap_class(*server.server_address) as imap:
imap.login('user', 'pass')
self.assertEqual(server.logged, 'user')
self.assertIsNone(server.logged)
@threading_helper.reap_threads
def test_with_statement_logout(self):
# what happens if already logout in the block?
Reported by Pylint.
Line: 924
Column: 31
with self.imap_class(*server.server_address) as imap:
imap.login('user', 'pass')
self.assertEqual(server.logged, 'user')
self.assertIsNone(server.logged)
@threading_helper.reap_threads
def test_with_statement_logout(self):
# what happens if already logout in the block?
with self.reaped_server(SimpleIMAPHandler) as server:
Reported by Pylint.
Line: 932
Column: 34
with self.reaped_server(SimpleIMAPHandler) as server:
with self.imap_class(*server.server_address) as imap:
imap.login('user', 'pass')
self.assertEqual(server.logged, 'user')
imap.logout()
self.assertIsNone(server.logged)
self.assertIsNone(server.logged)
@threading_helper.reap_threads
Reported by Pylint.
Line: 934
Column: 35
imap.login('user', 'pass')
self.assertEqual(server.logged, 'user')
imap.logout()
self.assertIsNone(server.logged)
self.assertIsNone(server.logged)
@threading_helper.reap_threads
@cpython_only
def test_dump_ur(self):
Reported by Pylint.
Line: 935
Column: 31
self.assertEqual(server.logged, 'user')
imap.logout()
self.assertIsNone(server.logged)
self.assertIsNone(server.logged)
@threading_helper.reap_threads
@cpython_only
def test_dump_ur(self):
# See: http://bugs.python.org/issue26543
Reported by Pylint.
Line: 180
Column: 35
else:
self._send_tagged(tag, 'BAD', cmd + ' unknown')
def cmd_CAPABILITY(self, tag, args):
caps = ('IMAP4rev1 ' + self.capabilities
if self.capabilities
else 'IMAP4rev1')
self._send_textline('* CAPABILITY ' + caps)
self._send_tagged(tag, 'OK', 'CAPABILITY completed')
Reported by Pylint.
Line: 187
Column: 31
self._send_textline('* CAPABILITY ' + caps)
self._send_tagged(tag, 'OK', 'CAPABILITY completed')
def cmd_LOGOUT(self, tag, args):
self.server.logged = None
self._send_textline('* BYE IMAP4ref1 Server logging out')
self._send_tagged(tag, 'OK', 'LOGOUT completed')
def cmd_LOGIN(self, tag, args):
Reported by Pylint.
Line: 196
Column: 31
self.server.logged = args[0]
self._send_tagged(tag, 'OK', 'LOGIN completed')
def cmd_SELECT(self, tag, args):
self.server.is_selected = True
self._send_line(b'* 2 EXISTS')
self._send_tagged(tag, 'OK', '[READ-WRITE] SELECT completed.')
def cmd_UNSELECT(self, tag, args):
Reported by Pylint.