Skip to content

Commit 0b8c348

Browse files
authored
Fix pyflakes warnings: variable is assigned to but never used (#142294)
Example of fixed warning: Lib/netrc.py:98:13: local variable 'toplevel' is assigned to but never used
1 parent c279e95 commit 0b8c348

32 files changed

+36
-47
lines changed

Lib/_py_warnings.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,6 @@ def warn_explicit(message, category, filename, lineno,
563563
else:
564564
text = message
565565
message = category(message)
566-
modules = None
567566
key = (text, category, lineno)
568567
with _wm._lock:
569568
if registry is None:

Lib/_threading_local.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def thread_deleted(_, idt=idt):
5757
# as soon as the OS-level thread ends instead.
5858
local = wrlocal()
5959
if local is not None:
60-
dct = local.dicts.pop(idt)
60+
local.dicts.pop(idt)
6161
wrlocal = ref(self, local_deleted)
6262
wrthread = ref(thread, thread_deleted)
6363
thread.__dict__[key] = wrlocal

Lib/asyncio/base_events.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -949,7 +949,7 @@ async def sock_sendfile(self, sock, file, offset=0, count=None,
949949
try:
950950
return await self._sock_sendfile_native(sock, file,
951951
offset, count)
952-
except exceptions.SendfileNotAvailableError as exc:
952+
except exceptions.SendfileNotAvailableError:
953953
if not fallback:
954954
raise
955955
return await self._sock_sendfile_fallback(sock, file,
@@ -1270,7 +1270,7 @@ async def sendfile(self, transport, file, offset=0, count=None,
12701270
try:
12711271
return await self._sendfile_native(transport, file,
12721272
offset, count)
1273-
except exceptions.SendfileNotAvailableError as exc:
1273+
except exceptions.SendfileNotAvailableError:
12741274
if not fallback:
12751275
raise
12761276

Lib/asyncio/proactor_events.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ async def sock_accept(self, sock):
733733
async def _sock_sendfile_native(self, sock, file, offset, count):
734734
try:
735735
fileno = file.fileno()
736-
except (AttributeError, io.UnsupportedOperation) as err:
736+
except (AttributeError, io.UnsupportedOperation):
737737
raise exceptions.SendfileNotAvailableError("not a regular file")
738738
try:
739739
fsize = os.fstat(fileno).st_size

Lib/asyncio/tools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ def _get_awaited_by_tasks(pid: int) -> list:
244244
e = e.__context__
245245
print(f"Error retrieving tasks: {e}")
246246
sys.exit(1)
247-
except PermissionError as e:
247+
except PermissionError:
248248
exit_with_permission_help_text()
249249

250250

Lib/asyncio/unix_events.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ async def _sock_sendfile_native(self, sock, file, offset, count):
359359
"os.sendfile() is not available")
360360
try:
361361
fileno = file.fileno()
362-
except (AttributeError, io.UnsupportedOperation) as err:
362+
except (AttributeError, io.UnsupportedOperation):
363363
raise exceptions.SendfileNotAvailableError("not a regular file")
364364
try:
365365
fsize = os.fstat(fileno).st_size

Lib/codeop.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ def _maybe_compile(compiler, source, filename, symbol, flags):
6666
try:
6767
compiler(source + "\n", filename, symbol, flags=flags)
6868
return None
69-
except _IncompleteInputError as e:
69+
except _IncompleteInputError:
7070
return None
71-
except SyntaxError as e:
71+
except SyntaxError:
7272
pass
7373
# fallthrough
7474

Lib/compileall.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ def compile_file(fullname, ddir=None, force=False, rx=None, quiet=0,
223223
cfile = importlib.util.cache_from_source(fullname)
224224
opt_cfiles[opt_level] = cfile
225225

226-
head, tail = name[:-3], name[-3:]
226+
tail = name[-3:]
227227
if tail == '.py':
228228
if not force:
229229
try:

Lib/concurrent/interpreters/_queues.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ def put(self, obj, block=True, timeout=None, *,
223223
while True:
224224
try:
225225
_queues.put(self._id, obj, unboundop)
226-
except QueueFull as exc:
226+
except QueueFull:
227227
if timeout is not None and time.time() >= end:
228228
raise # re-raise
229229
time.sleep(_delay)
@@ -258,7 +258,7 @@ def get(self, block=True, timeout=None, *,
258258
while True:
259259
try:
260260
obj, unboundop = _queues.get(self._id)
261-
except QueueEmpty as exc:
261+
except QueueEmpty:
262262
if timeout is not None and time.time() >= end:
263263
raise # re-raise
264264
time.sleep(_delay)
@@ -277,7 +277,7 @@ def get_nowait(self):
277277
"""
278278
try:
279279
obj, unboundop = _queues.get(self._id)
280-
except QueueEmpty as exc:
280+
except QueueEmpty:
281281
raise # re-raise
282282
if unboundop is not None:
283283
assert obj is None, repr(obj)

Lib/dis.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,6 @@ def print_instruction_line(self, instr, mark_as_current):
530530
fields.append(instr.opname.ljust(_OPNAME_WIDTH))
531531
# Column: Opcode argument
532532
if instr.arg is not None:
533-
arg = repr(instr.arg)
534533
# If opname is longer than _OPNAME_WIDTH, we allow it to overflow into
535534
# the space reserved for oparg. This results in fewer misaligned opargs
536535
# in the disassembly output.

0 commit comments

Comments
 (0)