The following issues were found
Lib/asyncio/events.py
75 issues
Line: 21
Column: 1
import sys
import threading
from . import format_helpers
class Handle:
"""Object returned by callback registration methods."""
Reported by Pylint.
Line: 673
Column: 16
You must call set_event_loop() to make this the current event
loop.
"""
return self._loop_factory()
# Event loop policy. The policy itself is always global, even if the
# policy's rules say that there is an event loop per thread (or other
# notion of context). The default policy is installed by the first
Reported by Pylint.
Line: 732
Column: 13
global _event_loop_policy
with _lock:
if _event_loop_policy is None: # pragma: no branch
from . import DefaultEventLoopPolicy
_event_loop_policy = DefaultEventLoopPolicy()
def get_event_loop_policy():
"""Get the current event loop policy."""
Reported by Pylint.
Line: 51
Column: 25
if self._cancelled:
info.append('cancelled')
if self._callback is not None:
info.append(format_helpers._format_callback_source(
self._callback, self._args))
if self._source_traceback:
frame = self._source_traceback[-1]
info.append(f'created at {frame[0]}:{frame[1]}')
return info
Reported by Pylint.
Line: 83
Column: 16
self._context.run(self._callback, *self._args)
except (SystemExit, KeyboardInterrupt):
raise
except BaseException as exc:
cb = format_helpers._format_callback_source(
self._callback, self._args)
msg = f'Exception in callback {cb}'
context = {
'message': msg,
Reported by Pylint.
Line: 84
Column: 18
except (SystemExit, KeyboardInterrupt):
raise
except BaseException as exc:
cb = format_helpers._format_callback_source(
self._callback, self._args)
msg = f'Exception in callback {cb}'
context = {
'message': msg,
'exception': exc,
Reported by Pylint.
Line: 95
Column: 9
if self._source_traceback:
context['source_traceback'] = self._source_traceback
self._loop.call_exception_handler(context)
self = None # Needed to break cycles when an exception occurs.
class TimerHandle(Handle):
"""Object returned by timed callback registration methods."""
Reported by Pylint.
Line: 150
Column: 13
def cancel(self):
if not self._cancelled:
self._loop._timer_handle_cancelled(self)
super().cancel()
def when(self):
"""Return a scheduled callback time.
Reported by Pylint.
Line: 295
Column: 37
# Network I/O methods returning Futures.
async def getaddrinfo(self, host, port, *,
family=0, type=0, proto=0, flags=0):
raise NotImplementedError
async def getnameinfo(self, sockaddr, flags=0):
raise NotImplementedError
Reported by Pylint.
Line: 623
Column: 1
raise NotImplementedError
class BaseDefaultEventLoopPolicy(AbstractEventLoopPolicy):
"""Default policy implementation for accessing the event loop.
In this policy, each thread has its own event loop. However, we
only automatically create an event loop by default for the main
thread; other threads by default have no event loop.
Reported by Pylint.
Lib/test/test_dbm.py
75 issues
Line: 59
Column: 9
def keys_helper(self, f):
keys = sorted(k.decode("ascii") for k in f.keys())
dkeys = sorted(self._dict.keys())
self.assertEqual(keys, dkeys)
return keys
def test_error(self):
self.assertTrue(issubclass(self.module.error, OSError))
Reported by Pylint.
Line: 63
Column: 9
return keys
def test_error(self):
self.assertTrue(issubclass(self.module.error, OSError))
def test_anydbm_not_existing(self):
self.assertRaises(dbm.error, dbm.open, _fname)
def test_anydbm_creation(self):
Reported by Pylint.
Line: 63
Column: 36
return keys
def test_error(self):
self.assertTrue(issubclass(self.module.error, OSError))
def test_anydbm_not_existing(self):
self.assertRaises(dbm.error, dbm.open, _fname)
def test_anydbm_creation(self):
Reported by Pylint.
Line: 66
Column: 9
self.assertTrue(issubclass(self.module.error, OSError))
def test_anydbm_not_existing(self):
self.assertRaises(dbm.error, dbm.open, _fname)
def test_anydbm_creation(self):
f = dbm.open(_fname, 'c')
self.assertEqual(list(f.keys()), [])
for key in self._dict:
Reported by Pylint.
Line: 70
Column: 9
def test_anydbm_creation(self):
f = dbm.open(_fname, 'c')
self.assertEqual(list(f.keys()), [])
for key in self._dict:
f[key.encode("ascii")] = self._dict[key]
self.read_helper(f)
f.close()
Reported by Pylint.
Line: 80
Column: 13
# create an empty file
os_helper.create_empty_file(_fname)
with dbm.open(_fname, 'n') as f:
self.assertEqual(len(f), 0)
def test_anydbm_modification(self):
self.init_db()
f = dbm.open(_fname, 'c')
self._dict['g'] = f[b'g'] = b"indented"
Reported by Pylint.
Line: 88
Column: 9
self._dict['g'] = f[b'g'] = b"indented"
self.read_helper(f)
# setdefault() works as in the dict interface
self.assertEqual(f.setdefault(b'xxx', b'foo'), b'foo')
self.assertEqual(f[b'xxx'], b'foo')
f.close()
def test_anydbm_read(self):
self.init_db()
Reported by Pylint.
Line: 89
Column: 9
self.read_helper(f)
# setdefault() works as in the dict interface
self.assertEqual(f.setdefault(b'xxx', b'foo'), b'foo')
self.assertEqual(f[b'xxx'], b'foo')
f.close()
def test_anydbm_read(self):
self.init_db()
f = dbm.open(_fname, 'r')
Reported by Pylint.
Line: 97
Column: 9
f = dbm.open(_fname, 'r')
self.read_helper(f)
# get() works as in the dict interface
self.assertEqual(f.get(b'a'), self._dict['a'])
self.assertEqual(f.get(b'xxx', b'foo'), b'foo')
self.assertIsNone(f.get(b'xxx'))
with self.assertRaises(KeyError):
f[b'xxx']
f.close()
Reported by Pylint.
Line: 98
Column: 9
self.read_helper(f)
# get() works as in the dict interface
self.assertEqual(f.get(b'a'), self._dict['a'])
self.assertEqual(f.get(b'xxx', b'foo'), b'foo')
self.assertIsNone(f.get(b'xxx'))
with self.assertRaises(KeyError):
f[b'xxx']
f.close()
Reported by Pylint.
Lib/test/test_univnewlines.py
74 issues
Line: 48
Column: 16
WRITEMODE = 'wb'
def setUp(self):
data = self.DATA
if "b" in self.WRITEMODE:
data = data.encode("ascii")
with self.open(os_helper.TESTFN, self.WRITEMODE) as fp:
fp.write(data)
Reported by Pylint.
Line: 51
Column: 14
data = self.DATA
if "b" in self.WRITEMODE:
data = data.encode("ascii")
with self.open(os_helper.TESTFN, self.WRITEMODE) as fp:
fp.write(data)
def tearDown(self):
try:
os.unlink(os_helper.TESTFN)
Reported by Pylint.
Line: 61
Column: 14
pass
def test_read(self):
with self.open(os_helper.TESTFN, self.READMODE) as fp:
data = fp.read()
self.assertEqual(data, DATA_LF)
self.assertEqual(repr(fp.newlines), repr(self.NEWLINE))
def test_readlines(self):
Reported by Pylint.
Line: 63
Column: 9
def test_read(self):
with self.open(os_helper.TESTFN, self.READMODE) as fp:
data = fp.read()
self.assertEqual(data, DATA_LF)
self.assertEqual(repr(fp.newlines), repr(self.NEWLINE))
def test_readlines(self):
with self.open(os_helper.TESTFN, self.READMODE) as fp:
data = fp.readlines()
Reported by Pylint.
Line: 64
Column: 50
with self.open(os_helper.TESTFN, self.READMODE) as fp:
data = fp.read()
self.assertEqual(data, DATA_LF)
self.assertEqual(repr(fp.newlines), repr(self.NEWLINE))
def test_readlines(self):
with self.open(os_helper.TESTFN, self.READMODE) as fp:
data = fp.readlines()
self.assertEqual(data, DATA_SPLIT)
Reported by Pylint.
Line: 64
Column: 9
with self.open(os_helper.TESTFN, self.READMODE) as fp:
data = fp.read()
self.assertEqual(data, DATA_LF)
self.assertEqual(repr(fp.newlines), repr(self.NEWLINE))
def test_readlines(self):
with self.open(os_helper.TESTFN, self.READMODE) as fp:
data = fp.readlines()
self.assertEqual(data, DATA_SPLIT)
Reported by Pylint.
Line: 67
Column: 14
self.assertEqual(repr(fp.newlines), repr(self.NEWLINE))
def test_readlines(self):
with self.open(os_helper.TESTFN, self.READMODE) as fp:
data = fp.readlines()
self.assertEqual(data, DATA_SPLIT)
self.assertEqual(repr(fp.newlines), repr(self.NEWLINE))
def test_readline(self):
Reported by Pylint.
Line: 69
Column: 9
def test_readlines(self):
with self.open(os_helper.TESTFN, self.READMODE) as fp:
data = fp.readlines()
self.assertEqual(data, DATA_SPLIT)
self.assertEqual(repr(fp.newlines), repr(self.NEWLINE))
def test_readline(self):
with self.open(os_helper.TESTFN, self.READMODE) as fp:
data = []
Reported by Pylint.
Line: 70
Column: 50
with self.open(os_helper.TESTFN, self.READMODE) as fp:
data = fp.readlines()
self.assertEqual(data, DATA_SPLIT)
self.assertEqual(repr(fp.newlines), repr(self.NEWLINE))
def test_readline(self):
with self.open(os_helper.TESTFN, self.READMODE) as fp:
data = []
d = fp.readline()
Reported by Pylint.
Line: 70
Column: 9
with self.open(os_helper.TESTFN, self.READMODE) as fp:
data = fp.readlines()
self.assertEqual(data, DATA_SPLIT)
self.assertEqual(repr(fp.newlines), repr(self.NEWLINE))
def test_readline(self):
with self.open(os_helper.TESTFN, self.READMODE) as fp:
data = []
d = fp.readline()
Reported by Pylint.
Lib/tkinter/dnd.py
74 issues
Line: 128
Column: 13
return
root = event.widget._root()
try:
root.__dnd
return # Don't start recursive dnd
except AttributeError:
root.__dnd = self
self.root = root
self.source = source
Reported by Pylint.
Line: 128
Column: 13
return
root = event.widget._root()
try:
root.__dnd
return # Don't start recursive dnd
except AttributeError:
root.__dnd = self
self.root = root
self.source = source
Reported by Pylint.
Line: 131
Column: 13
root.__dnd
return # Don't start recursive dnd
except AttributeError:
root.__dnd = self
self.root = root
self.source = source
self.target = None
self.initial_button = button = event.num
self.initial_widget = widget = event.widget
Reported by Pylint.
Line: 224
Column: 9
return
label = tkinter.Label(canvas, text=self.name,
borderwidth=2, relief="raised")
id = canvas.create_window(x, y, window=label, anchor="nw")
self.canvas = canvas
self.label = label
self.id = id
label.bind("<ButtonPress>", self.press)
Reported by Pylint.
Line: 234
Column: 9
canvas = self.canvas
if canvas is None:
return
id = self.id
label = self.label
self.canvas = self.label = self.id = None
canvas.delete(id)
label.destroy()
Reported by Pylint.
Line: 243
Column: 13
def press(self, event):
if dnd_start(self, event):
# where the pointer is relative to the label widget:
self.x_off = event.x
self.y_off = event.y
# where the widget is relative to the canvas:
self.x_orig, self.y_orig = self.canvas.coords(self.id)
def move(self, event):
Reported by Pylint.
Line: 244
Column: 13
if dnd_start(self, event):
# where the pointer is relative to the label widget:
self.x_off = event.x
self.y_off = event.y
# where the widget is relative to the canvas:
self.x_orig, self.y_orig = self.canvas.coords(self.id)
def move(self, event):
x, y = self.where(self.canvas, event)
Reported by Pylint.
Line: 246
Column: 26
self.x_off = event.x
self.y_off = event.y
# where the widget is relative to the canvas:
self.x_orig, self.y_orig = self.canvas.coords(self.id)
def move(self, event):
x, y = self.where(self.canvas, event)
self.canvas.coords(self.id, x, y)
Reported by Pylint.
Line: 246
Column: 13
self.x_off = event.x
self.y_off = event.y
# where the widget is relative to the canvas:
self.x_orig, self.y_orig = self.canvas.coords(self.id)
def move(self, event):
x, y = self.where(self.canvas, event)
self.canvas.coords(self.id, x, y)
Reported by Pylint.
Line: 277
Column: 34
self.canvas.pack(fill="both", expand=1)
self.canvas.dnd_accept = self.dnd_accept
def dnd_accept(self, source, event):
return self
def dnd_enter(self, source, event):
self.canvas.focus_set() # Show highlight border
x, y = source.where(self.canvas, event)
Reported by Pylint.
Lib/test/test_importlib/test_threaded_import.py
74 issues
Line: 143
Column: 9
print("OK.")
def test_parallel_module_init(self):
self.check_parallel_module_init()
def test_parallel_meta_path(self):
finder = Finder()
sys.meta_path.insert(0, finder)
try:
Reported by Pylint.
Line: 149
Column: 13
finder = Finder()
sys.meta_path.insert(0, finder)
try:
self.check_parallel_module_init()
self.assertGreater(finder.numcalls, 0)
self.assertEqual(finder.x, finder.numcalls)
finally:
sys.meta_path.remove(finder)
Reported by Pylint.
Line: 171
Column: 24
try:
# Flush the cache a first time
flushing_finder.find_spec('')
numtests = self.check_parallel_module_init()
self.assertGreater(finder.numcalls, 0)
self.assertEqual(finder.x, finder.numcalls)
finally:
sys.meta_path.remove(flushing_finder)
sys.path_hooks.remove(path_hook)
Reported by Pylint.
Line: 213
Column: 13
importlib.invalidate_caches()
results = []
def import_ab():
import A
results.append(getattr(A, 'x', None))
def import_ba():
import B
results.append(getattr(B, 'x', None))
t1 = threading.Thread(target=import_ab)
Reported by Pylint.
Line: 216
Column: 13
import A
results.append(getattr(A, 'x', None))
def import_ba():
import B
results.append(getattr(B, 'x', None))
t1 = threading.Thread(target=import_ab)
t2 = threading.Thread(target=import_ba)
t1.start()
t2.start()
Reported by Pylint.
Line: 27
Column: 13
# We don't use modulefinder but still import it in order to stress
# importing of different modules from several threads.
if len(done_tasks) % 2:
import modulefinder
import random
else:
import random
import modulefinder
# This will fail if random is not completely initialized
Reported by Pylint.
Line: 33
Column: 9
import random
import modulefinder
# This will fail if random is not completely initialized
x = random.randrange(1, 3)
except Exception as e:
errors.append(e.with_traceback(None))
finally:
done_tasks.append(threading.get_ident())
finished = len(done_tasks) == N
Reported by Pylint.
Line: 34
Column: 12
import modulefinder
# This will fail if random is not completely initialized
x = random.randrange(1, 3)
except Exception as e:
errors.append(e.with_traceback(None))
finally:
done_tasks.append(threading.get_ident())
finished = len(done_tasks) == N
if finished:
Reported by Pylint.
Line: 77
Column: 42
self.x = 0
self.lock = threading.Lock()
def find_spec(self, name, path=None, target=None):
# Simulate some thread-unsafe behaviour. If calls to find_spec()
# are properly serialized, `x` will end up the same as `numcalls`.
# Otherwise not.
assert imp.lock_held()
with self.lock:
Reported by Pylint.
Line: 77
Column: 31
self.x = 0
self.lock = threading.Lock()
def find_spec(self, name, path=None, target=None):
# Simulate some thread-unsafe behaviour. If calls to find_spec()
# are properly serialized, `x` will end up the same as `numcalls`.
# Otherwise not.
assert imp.lock_held()
with self.lock:
Reported by Pylint.
Lib/xml/dom/pulldom.py
74 issues
Line: 33
Column: 5
self._current_context = self._ns_contexts[-1]
self.pending_events = []
def pop(self):
result = self.elementStack[-1]
del self.elementStack[-1]
return result
def setDocumentLocator(self, locator):
Reported by Pylint.
Line: 256
Column: 5
del parents[-1]
event = self.getEvent()
def getEvent(self):
# use IncrementalParser interface, so we get the desired
# pull effect
if not self.pulldom.firstEvent[1]:
self.pulldom.lastEvent = self.pulldom.firstEvent
while not self.pulldom.firstEvent[1]:
Reported by Pylint.
Line: 267
Column: 14
self.parser.close()
return None
self.parser.feed(buf)
rc = self.pulldom.firstEvent[1][0]
self.pulldom.firstEvent[1] = self.pulldom.firstEvent[1][1]
return rc
def _slurp(self):
""" Fallback replacement for getEvent() using the
Reported by Pylint.
Line: 268
Column: 38
return None
self.parser.feed(buf)
rc = self.pulldom.firstEvent[1][0]
self.pulldom.firstEvent[1] = self.pulldom.firstEvent[1][1]
return rc
def _slurp(self):
""" Fallback replacement for getEvent() using the
standard SAX2 interface, which means we slurp the
Reported by Pylint.
Line: 285
Column: 14
""" Fallback replacement for getEvent() that emits
the events that _slurp() read previously.
"""
rc = self.pulldom.firstEvent[1][0]
self.pulldom.firstEvent[1] = self.pulldom.firstEvent[1][1]
return rc
def clear(self):
"""clear(): Explicitly release parsing objects"""
Reported by Pylint.
Line: 286
Column: 38
the events that _slurp() read previously.
"""
rc = self.pulldom.firstEvent[1][0]
self.pulldom.firstEvent[1] = self.pulldom.firstEvent[1][1]
return rc
def clear(self):
"""clear(): Explicitly release parsing objects"""
self.pulldom.clear()
Reported by Pylint.
Line: 17
Column: 5
_locator = None
document = None
def __init__(self, documentFactory=None):
from xml.dom import XML_NAMESPACE
self.documentFactory = documentFactory
self.firstEvent = [None, None]
self.lastEvent = self.firstEvent
self.elementStack = []
Reported by Pylint.
Line: 43
Column: 13
def startPrefixMapping(self, prefix, uri):
if not hasattr(self, '_xmlns_attrs'):
self._xmlns_attrs = []
self._xmlns_attrs.append((prefix or 'xmlns', uri))
self._ns_contexts.append(self._current_context.copy())
self._current_context[uri] = prefix or None
def endPrefixMapping(self, prefix):
Reported by Pylint.
Line: 51
Column: 5
def endPrefixMapping(self, prefix):
self._current_context = self._ns_contexts.pop()
def startElementNS(self, name, tagName , attrs):
# Retrieve xml namespace declaration attributes.
xmlns_uri = 'http://www.w3.org/2000/xmlns/'
xmlns_attrs = getattr(self, '_xmlns_attrs', None)
if xmlns_attrs is not None:
for aname, value in xmlns_attrs:
Reported by Pylint.
Line: 57
Column: 17
xmlns_attrs = getattr(self, '_xmlns_attrs', None)
if xmlns_attrs is not None:
for aname, value in xmlns_attrs:
attrs._attrs[(xmlns_uri, aname)] = value
self._xmlns_attrs = []
uri, localname = name
if uri:
# When using namespaces, the reader may or may not
# provide us with the original name. If not, create
Reported by Pylint.
Lib/test/_test_eintr.py
74 issues
Line: 467
Column: 18
@unittest.skipUnless(hasattr(select, 'kqueue'), 'need select.kqueue')
def test_kqueue(self):
kqueue = select.kqueue()
self.addCleanup(kqueue.close)
t0 = time.monotonic()
kqueue.control(None, 1, self.sleep_time)
dt = time.monotonic() - t0
Reported by Pylint.
Line: 478
Column: 18
@unittest.skipUnless(hasattr(select, 'devpoll'), 'need select.devpoll')
def test_devpoll(self):
poller = select.devpoll()
self.addCleanup(poller.close)
t0 = time.monotonic()
poller.poll(self.sleep_time * 1e3)
dt = time.monotonic() - t0
Reported by Pylint.
Line: 51
Column: 26
# sleep_time > signal_period
sleep_time = 0.2
def sighandler(self, signum, frame):
self.signals += 1
def setUp(self):
self.signals = 0
self.orig_handler = signal.signal(signal.SIGALRM, self.sighandler)
Reported by Pylint.
Line: 51
Column: 34
# sleep_time > signal_period
sleep_time = 0.2
def sighandler(self, signum, frame):
self.signals += 1
def setUp(self):
self.signals = 0
self.orig_handler = signal.signal(signal.SIGALRM, self.sighandler)
Reported by Pylint.
Line: 389
Column: 9
def check_sigwait(self, wait_func):
signum = signal.SIGUSR1
pid = os.getpid()
old_handler = signal.signal(signum, lambda *args: None)
self.addCleanup(signal.signal, signum, old_handler)
code = '\n'.join((
Reported by Pylint.
Line: 403
Column: 9
'os.kill(pid, signum)',
))
old_mask = signal.pthread_sigmask(signal.SIG_BLOCK, [signum])
self.addCleanup(signal.pthread_sigmask, signal.SIG_UNBLOCK, [signum])
t0 = time.monotonic()
proc = self.subprocess(code)
with kill_on_error(proc):
Reported by Pylint.
Line: 410
Column: 13
proc = self.subprocess(code)
with kill_on_error(proc):
wait_func(signum)
dt = time.monotonic() - t0
self.assertEqual(proc.wait(), 0)
@unittest.skipUnless(hasattr(signal, 'sigwaitinfo'),
'need signal.sigwaitinfo()')
Reported by Pylint.
Line: 19
Suggestion:
https://bandit.readthedocs.io/en/latest/blacklists/blacklist_imports.html#b404-import-subprocess
import select
import signal
import socket
import subprocess
import sys
import time
import unittest
from test import support
Reported by Bandit.
Line: 51
Column: 5
# sleep_time > signal_period
sleep_time = 0.2
def sighandler(self, signum, frame):
self.signals += 1
def setUp(self):
self.signals = 0
self.orig_handler = signal.signal(signal.SIGALRM, self.sighandler)
Reported by Pylint.
Line: 66
Column: 5
file=sys.__stderr__)
@staticmethod
def stop_alarm():
signal.setitimer(signal.ITIMER_REAL, 0, 0)
def tearDown(self):
self.stop_alarm()
signal.signal(signal.SIGALRM, self.orig_handler)
Reported by Pylint.
Lib/uuid.py
74 issues
Line: 137
Column: 18
uuid_generate_time_safe(3).
"""
__slots__ = ('int', 'is_safe', '__weakref__')
def __init__(self, hex=None, bytes=None, bytes_le=None, fields=None,
int=None, version=None,
*, is_safe=SafeUUID.unknown):
r"""Create a UUID from either a string of 32 hexadecimal digits,
Reported by Pylint.
Line: 227
Column: 12
def __getstate__(self):
d = {'int': self.int}
if self.is_safe != SafeUUID.unknown:
# is_safe is a SafeUUID instance. Return just its value, so that
# it can be un-pickled in older Python versions without SafeUUID.
d['is_safe'] = self.is_safe.value
return d
Reported by Pylint.
Line: 230
Column: 28
if self.is_safe != SafeUUID.unknown:
# is_safe is a SafeUUID instance. Return just its value, so that
# it can be un-pickled in older Python versions without SafeUUID.
d['is_safe'] = self.is_safe.value
return d
def __setstate__(self, state):
object.__setattr__(self, 'int', state['int'])
# is_safe was added in 3.7; it is also omitted when it is "unknown"
Reported by Pylint.
Line: 597
Column: 22
def _windll_getnode():
"""Get the hardware address on Windows using the _uuid extension module."""
if _UuidCreate:
uuid_bytes = _UuidCreate()
return UUID(bytes_le=uuid_bytes).node
def _random_getnode():
"""Get a random node ID."""
# RFC 4122, $4.1.6 says "For systems with no IEEE address, a randomly or
Reported by Pylint.
Line: 708
Column: 14
def uuid3(namespace, name):
"""Generate a UUID from the MD5 hash of a namespace UUID and a name."""
from hashlib import md5
digest = md5(
namespace.bytes + bytes(name, "utf-8"),
usedforsecurity=False
).digest()
return UUID(bytes=digest[:16], version=3)
Reported by Pylint.
Line: 139
Column: 34
__slots__ = ('int', 'is_safe', '__weakref__')
def __init__(self, hex=None, bytes=None, bytes_le=None, fields=None,
int=None, version=None,
*, is_safe=SafeUUID.unknown):
r"""Create a UUID from either a string of 32 hexadecimal digits,
a string of 16 bytes as the 'bytes' argument, a string of 16 bytes
in little-endian order as the 'bytes_le' argument, a tuple of six
Reported by Pylint.
Line: 139
Column: 24
__slots__ = ('int', 'is_safe', '__weakref__')
def __init__(self, hex=None, bytes=None, bytes_le=None, fields=None,
int=None, version=None,
*, is_safe=SafeUUID.unknown):
r"""Create a UUID from either a string of 32 hexadecimal digits,
a string of 16 bytes as the 'bytes' argument, a string of 16 bytes
in little-endian order as the 'bytes_le' argument, a tuple of six
Reported by Pylint.
Line: 140
Column: 24
__slots__ = ('int', 'is_safe', '__weakref__')
def __init__(self, hex=None, bytes=None, bytes_le=None, fields=None,
int=None, version=None,
*, is_safe=SafeUUID.unknown):
r"""Create a UUID from either a string of 32 hexadecimal digits,
a string of 16 bytes as the 'bytes' argument, a string of 16 bytes
in little-endian order as the 'bytes_le' argument, a tuple of six
integers (32-bit time_low, 16-bit time_mid, 16-bit time_hi_version,
Reported by Pylint.
Line: 281
Column: 9
raise TypeError('UUID objects are immutable')
def __str__(self):
hex = '%032x' % self.int
return '%s-%s-%s-%s-%s' % (
hex[:8], hex[8:12], hex[12:16], hex[16:20], hex[20:])
@property
def bytes(self):
Reported by Pylint.
Line: 291
Column: 9
@property
def bytes_le(self):
bytes = self.bytes
return (bytes[4-1::-1] + bytes[6-1:4-1:-1] + bytes[8-1:6-1:-1] +
bytes[8:])
@property
def fields(self):
Reported by Pylint.
Lib/test/test_email/test_policy.py
74 issues
Line: 88
Column: 13
def test_abc(self):
with self.assertRaises(TypeError) as cm:
email.policy.Policy()
msg = str(cm.exception)
abstract_methods = ('fold',
'fold_binary',
'header_fetch_parse',
'header_source_parse',
Reported by Pylint.
Line: 280
Column: 3
with self.assertRaises(email.errors.HeaderParseError):
policy.fold("Subject", subject)
# XXX: Need subclassing tests.
# For adding subclassed objects, make sure the usual rules apply (subclass
# wins), but that the order still works (right overrides left).
class TestException(Exception):
Reported by Pylint.
Line: 293
Column: 5
# The abstract methods are used by the parser but not by the wrapper
# functions that call it, so if the exception gets raised we know that the
# policy was actually propagated all the way to feedparser.
class MyPolicy(email.policy.Policy):
def badmethod(self, *args, **kw):
raise TestException("test")
fold = fold_binary = header_fetch_parser = badmethod
header_source_parse = header_store_parse = badmethod
Reported by Pylint.
Line: 336
Column: 9
# the rest of the propagation tests.
def _make_msg(self, source='Subject: test\n\n', policy=None):
self.policy = email.policy.default.clone() if policy is None else policy
return email.message_from_string(source, policy=self.policy)
def test_parser_propagates_policy_to_message(self):
msg = self._make_msg()
self.assertIs(msg.policy, self.policy)
Reported by Pylint.
Line: 1
Column: 1
import io
import types
import textwrap
import unittest
import email.errors
import email.policy
import email.parser
import email.generator
import email.message
Reported by Pylint.
Line: 12
Column: 1
import email.message
from email import headerregistry
def make_defaults(base_defaults, differences):
defaults = base_defaults.copy()
defaults.update(differences)
return defaults
class PolicyAPITests(unittest.TestCase):
Reported by Pylint.
Line: 17
Column: 1
defaults.update(differences)
return defaults
class PolicyAPITests(unittest.TestCase):
longMessage = True
# Base default values.
compat32_defaults = {
Reported by Pylint.
Line: 66
Column: 5
# later that proves this.
policies[new_policy]['header_factory'] = new_policy.header_factory
def test_defaults(self):
for policy, expected in self.policies.items():
for attr, value in expected.items():
with self.subTest(policy=policy, attr=attr):
self.assertEqual(getattr(policy, attr), value,
("change {} docs/docstrings if defaults have "
Reported by Pylint.
Line: 74
Column: 5
("change {} docs/docstrings if defaults have "
"changed").format(policy))
def test_all_attributes_covered(self):
for policy, expected in self.policies.items():
for attr in dir(policy):
with self.subTest(policy=policy, attr=attr):
if (attr.startswith('_') or
isinstance(getattr(email.policy.EmailPolicy, attr),
Reported by Pylint.
Line: 78
Column: 21
for policy, expected in self.policies.items():
for attr in dir(policy):
with self.subTest(policy=policy, attr=attr):
if (attr.startswith('_') or
isinstance(getattr(email.policy.EmailPolicy, attr),
types.FunctionType)):
continue
else:
self.assertIn(attr, expected,
Reported by Pylint.
Lib/_collections_abc.py
73 issues
Line: 12
Column: 21
from abc import ABCMeta, abstractmethod
import sys
GenericAlias = type(list[int])
EllipsisType = type(...)
def _f(): pass
FunctionType = type(_f)
del _f
Reported by Pylint.
Line: 172
Column: 16
@abstractmethod
def __aiter__(self):
return AsyncIterator()
@classmethod
def __subclasshook__(cls, C):
if cls is AsyncIterable:
return _check_methods(C, "__aiter__")
Reported by Pylint.
Line: 33
Column: 1
# speed up interpreter startup. Some of the types such as MutableMapping are
# required early but collections module imports a lot of other modules.
# See issue #19218
__name__ = "collections.abc"
# Private list of types that we want to register with the various ABCs
# so that they will pass tests like:
# it = iter(somebytearray)
# assert isinstance(it, Iterable)
Reported by Pylint.
Line: 405
Column: 1
__class_getitem__ = classmethod(GenericAlias)
class Collection(Sized, Iterable, Container):
__slots__ = ()
@classmethod
def __subclasshook__(cls, C):
Reported by Pylint.
Line: 405
Column: 1
__class_getitem__ = classmethod(GenericAlias)
class Collection(Sized, Iterable, Container):
__slots__ = ()
@classmethod
def __subclasshook__(cls, C):
Reported by Pylint.
Line: 405
Column: 1
__class_getitem__ = classmethod(GenericAlias)
class Collection(Sized, Iterable, Container):
__slots__ = ()
@classmethod
def __subclasshook__(cls, C):
Reported by Pylint.
Line: 570
Column: 1
### SETS ###
class Set(Collection):
"""A set is a finite, iterable container.
This class provides concrete generic implementations of all
methods except for __contains__, __iter__ and __len__.
Reported by Pylint.
Line: 570
Column: 1
### SETS ###
class Set(Collection):
"""A set is a finite, iterable container.
This class provides concrete generic implementations of all
methods except for __contains__, __iter__ and __len__.
Reported by Pylint.
Line: 570
Column: 1
### SETS ###
class Set(Collection):
"""A set is a finite, iterable container.
This class provides concrete generic implementations of all
methods except for __contains__, __iter__ and __len__.
Reported by Pylint.
Line: 1084
Column: 1
Sequence.register(memoryview)
class ByteString(Sequence):
"""This unifies bytes and bytearray.
XXX Should add all their methods.
"""
Reported by Pylint.