Skip to content

Commit 6c6fab1

Browse files
projectgusdpgeorge
authored andcommitted
all: Enable ruff F841 'Local variable is assigned to but never used'.
Most of these look like they were used for print debugging and then kept in when the print statements were removed or commented. Some look like missing or incomplete functionality, these have been marked with comments where possible. Signed-off-by: Angus Gratton <[email protected]>
1 parent cb281a4 commit 6c6fab1

File tree

10 files changed

+18
-34
lines changed

10 files changed

+18
-34
lines changed

Diff for: micropython/bluetooth/aioble/examples/l2cap_file_client.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ async def size(self, path):
8585
async def download(self, path, dest):
8686
size = await self.size(path)
8787

88-
send_seq = await self._command(_COMMAND_SEND, path.encode())
88+
await self._command(_COMMAND_SEND, path.encode())
8989

9090
with open(dest, "wb") as f: # noqa: ASYNC101
9191
total = 0
@@ -97,7 +97,7 @@ async def download(self, path, dest):
9797
total += n
9898

9999
async def list(self, path):
100-
send_seq = await self._command(_COMMAND_LIST, path.encode())
100+
await self._command(_COMMAND_LIST, path.encode())
101101
results = bytearray()
102102
buf = bytearray(self._channel.our_mtu)
103103
mv = memoryview(buf)

Diff for: micropython/bluetooth/aioble/examples/l2cap_file_server.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -132,23 +132,20 @@ async def control_task(connection):
132132
file = msg[2:].decode()
133133

134134
if command == _COMMAND_SEND:
135-
op_seq = seq
136135
send_file = file
137136
l2cap_event.set()
138137
elif command == _COMMAND_RECV:
139-
op_seq = seq
140138
recv_file = file
141139
l2cap_event.set()
142140
elif command == _COMMAND_LIST:
143-
op_seq = seq
144141
list_path = file
145142
l2cap_event.set()
146143
elif command == _COMMAND_SIZE:
147144
try:
148145
stat = os.stat(file)
149146
size = stat[6]
150147
status = 0
151-
except OSError as e:
148+
except OSError:
152149
size = 0
153150
status = _STATUS_NOT_FOUND
154151
control_characteristic.notify(

Diff for: micropython/bluetooth/aioble/multitests/ble_descriptor.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ async def instance0_task():
3232
char1_desc1.write("char1_desc1")
3333
char1_desc2 = aioble.Descriptor(char1, CHAR1_DESC2_UUID, read=True, write=True)
3434
char1_desc2.write("char1_desc2")
35-
char2 = aioble.Characteristic(
36-
service, CHAR2_UUID, read=True, write=True, notify=True, indicate=True
37-
)
35+
aioble.Characteristic(service, CHAR2_UUID, read=True, write=True, notify=True, indicate=True)
3836
char3 = aioble.Characteristic(
3937
service, CHAR3_UUID, read=True, write=True, notify=True, indicate=True
4038
)

Diff for: micropython/espflash/espflash.py

-1
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,6 @@ def flash_write_file(self, path, blksize=0x1000):
258258
print(f"Flash write size: {size} total_blocks: {total_blocks} block size: {blksize}")
259259
with open(path, "rb") as f:
260260
seq = 0
261-
subseq = 0
262261
for i in range(total_blocks):
263262
buf = f.read(blksize)
264263
# Update digest

Diff for: micropython/ucontextlib/tests.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def test_context_manager(self):
2424
def test_context_manager_on_error(self):
2525
exc = Exception()
2626
try:
27-
with self._manager(123) as x:
27+
with self._manager(123):
2828
raise exc
2929
except Exception as e:
3030
self.assertEqual(exc, e)

Diff for: micropython/udnspkt/udnspkt.py

+9-17
Original file line numberDiff line numberDiff line change
@@ -43,36 +43,28 @@ def parse_resp(buf, is_ipv6):
4343
if is_ipv6:
4444
typ = 28 # AAAA
4545

46-
id = buf.readbin(">H")
46+
buf.readbin(">H") # id
4747
flags = buf.readbin(">H")
4848
assert flags & 0x8000
49-
qcnt = buf.readbin(">H")
49+
buf.readbin(">H") # qcnt
5050
acnt = buf.readbin(">H")
51-
nscnt = buf.readbin(">H")
52-
addcnt = buf.readbin(">H")
53-
# print(qcnt, acnt, nscnt, addcnt)
51+
buf.readbin(">H") # nscnt
52+
buf.readbin(">H") # addcnt
5453

5554
skip_fqdn(buf)
56-
v = buf.readbin(">H")
57-
# print(v)
58-
v = buf.readbin(">H")
59-
# print(v)
55+
buf.readbin(">H")
56+
buf.readbin(">H")
6057

6158
for i in range(acnt):
6259
# print("Resp #%d" % i)
6360
# v = read_fqdn(buf)
6461
# print(v)
6562
skip_fqdn(buf)
66-
t = buf.readbin(">H")
67-
# print("Type", t)
68-
v = buf.readbin(">H")
69-
# print("Class", v)
70-
v = buf.readbin(">I")
71-
# print("TTL", v)
63+
t = buf.readbin(">H") # Type
64+
buf.readbin(">H") # Class
65+
buf.readbin(">I") # TTL
7266
rlen = buf.readbin(">H")
73-
# print("rlen", rlen)
7467
rval = buf.read(rlen)
75-
# print(rval)
7668

7769
if t == typ:
7870
return rval

Diff for: micropython/urllib.urequest/urllib/urequest.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ def urlopen(url, data=None, method="GET"):
4848
if data:
4949
s.write(data)
5050

51-
l = s.readline()
52-
l = l.split(None, 2)
51+
l = s.readline() # Status-Line
52+
# l = l.split(None, 2)
5353
# print(l)
54-
status = int(l[1])
54+
# status = int(l[1]) # FIXME: Status-Code element is not currently checked
5555
while True:
5656
l = s.readline()
5757
if not l or l == b"\r\n":

Diff for: pyproject.toml

-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ ignore = [
6363
"F405",
6464
"E501",
6565
"F541",
66-
"F841",
6766
"ISC001",
6867
"ISC003", # micropython does not support implicit concatenation of f-strings
6968
"PIE810", # micropython does not support passing tuples to .startswith or .endswith

Diff for: python-ecosys/aiohttp/aiohttp/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ async def __aexit__(self, *args):
104104

105105
async def _request(self, method, url, data=None, json=None, ssl=None, params=None, headers={}):
106106
redir_cnt = 0
107-
redir_url = None
108107
while redir_cnt < 2:
109108
reader = await self.request_raw(method, url, data, json, ssl, params, headers)
110109
_headers = []

Diff for: python-ecosys/cbor2/cbor2/_decoder.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def decode_simple_value(decoder):
159159

160160

161161
def decode_float16(decoder):
162-
payload = decoder.read(2)
162+
decoder.read(2)
163163
raise NotImplementedError # no float16 unpack function
164164

165165

0 commit comments

Comments
 (0)