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 <angus@redyak.com.au>
pull/856/head
Angus Gratton 2024-05-14 15:05:35 +10:00 zatwierdzone przez Damien George
rodzic cb281a4177
commit 6c6fab1db1
10 zmienionych plików z 18 dodań i 34 usunięć

Wyświetl plik

@ -85,7 +85,7 @@ class FileClient:
async def download(self, path, dest): async def download(self, path, dest):
size = await self.size(path) size = await self.size(path)
send_seq = await self._command(_COMMAND_SEND, path.encode()) await self._command(_COMMAND_SEND, path.encode())
with open(dest, "wb") as f: # noqa: ASYNC101 with open(dest, "wb") as f: # noqa: ASYNC101
total = 0 total = 0
@ -97,7 +97,7 @@ class FileClient:
total += n total += n
async def list(self, path): async def list(self, path):
send_seq = await self._command(_COMMAND_LIST, path.encode()) await self._command(_COMMAND_LIST, path.encode())
results = bytearray() results = bytearray()
buf = bytearray(self._channel.our_mtu) buf = bytearray(self._channel.our_mtu)
mv = memoryview(buf) mv = memoryview(buf)

Wyświetl plik

@ -132,15 +132,12 @@ async def control_task(connection):
file = msg[2:].decode() file = msg[2:].decode()
if command == _COMMAND_SEND: if command == _COMMAND_SEND:
op_seq = seq
send_file = file send_file = file
l2cap_event.set() l2cap_event.set()
elif command == _COMMAND_RECV: elif command == _COMMAND_RECV:
op_seq = seq
recv_file = file recv_file = file
l2cap_event.set() l2cap_event.set()
elif command == _COMMAND_LIST: elif command == _COMMAND_LIST:
op_seq = seq
list_path = file list_path = file
l2cap_event.set() l2cap_event.set()
elif command == _COMMAND_SIZE: elif command == _COMMAND_SIZE:
@ -148,7 +145,7 @@ async def control_task(connection):
stat = os.stat(file) stat = os.stat(file)
size = stat[6] size = stat[6]
status = 0 status = 0
except OSError as e: except OSError:
size = 0 size = 0
status = _STATUS_NOT_FOUND status = _STATUS_NOT_FOUND
control_characteristic.notify( control_characteristic.notify(

Wyświetl plik

@ -32,9 +32,7 @@ async def instance0_task():
char1_desc1.write("char1_desc1") char1_desc1.write("char1_desc1")
char1_desc2 = aioble.Descriptor(char1, CHAR1_DESC2_UUID, read=True, write=True) char1_desc2 = aioble.Descriptor(char1, CHAR1_DESC2_UUID, read=True, write=True)
char1_desc2.write("char1_desc2") char1_desc2.write("char1_desc2")
char2 = aioble.Characteristic( aioble.Characteristic(service, CHAR2_UUID, read=True, write=True, notify=True, indicate=True)
service, CHAR2_UUID, read=True, write=True, notify=True, indicate=True
)
char3 = aioble.Characteristic( char3 = aioble.Characteristic(
service, CHAR3_UUID, read=True, write=True, notify=True, indicate=True service, CHAR3_UUID, read=True, write=True, notify=True, indicate=True
) )

Wyświetl plik

@ -258,7 +258,6 @@ class ESPFlash:
print(f"Flash write size: {size} total_blocks: {total_blocks} block size: {blksize}") print(f"Flash write size: {size} total_blocks: {total_blocks} block size: {blksize}")
with open(path, "rb") as f: with open(path, "rb") as f:
seq = 0 seq = 0
subseq = 0
for i in range(total_blocks): for i in range(total_blocks):
buf = f.read(blksize) buf = f.read(blksize)
# Update digest # Update digest

Wyświetl plik

@ -24,7 +24,7 @@ class ContextManagerTestCase(unittest.TestCase):
def test_context_manager_on_error(self): def test_context_manager_on_error(self):
exc = Exception() exc = Exception()
try: try:
with self._manager(123) as x: with self._manager(123):
raise exc raise exc
except Exception as e: except Exception as e:
self.assertEqual(exc, e) self.assertEqual(exc, e)

Wyświetl plik

@ -43,36 +43,28 @@ def parse_resp(buf, is_ipv6):
if is_ipv6: if is_ipv6:
typ = 28 # AAAA typ = 28 # AAAA
id = buf.readbin(">H") buf.readbin(">H") # id
flags = buf.readbin(">H") flags = buf.readbin(">H")
assert flags & 0x8000 assert flags & 0x8000
qcnt = buf.readbin(">H") buf.readbin(">H") # qcnt
acnt = buf.readbin(">H") acnt = buf.readbin(">H")
nscnt = buf.readbin(">H") buf.readbin(">H") # nscnt
addcnt = buf.readbin(">H") buf.readbin(">H") # addcnt
# print(qcnt, acnt, nscnt, addcnt)
skip_fqdn(buf) skip_fqdn(buf)
v = buf.readbin(">H") buf.readbin(">H")
# print(v) buf.readbin(">H")
v = buf.readbin(">H")
# print(v)
for i in range(acnt): for i in range(acnt):
# print("Resp #%d" % i) # print("Resp #%d" % i)
# v = read_fqdn(buf) # v = read_fqdn(buf)
# print(v) # print(v)
skip_fqdn(buf) skip_fqdn(buf)
t = buf.readbin(">H") t = buf.readbin(">H") # Type
# print("Type", t) buf.readbin(">H") # Class
v = buf.readbin(">H") buf.readbin(">I") # TTL
# print("Class", v)
v = buf.readbin(">I")
# print("TTL", v)
rlen = buf.readbin(">H") rlen = buf.readbin(">H")
# print("rlen", rlen)
rval = buf.read(rlen) rval = buf.read(rlen)
# print(rval)
if t == typ: if t == typ:
return rval return rval

Wyświetl plik

@ -48,10 +48,10 @@ def urlopen(url, data=None, method="GET"):
if data: if data:
s.write(data) s.write(data)
l = s.readline() l = s.readline() # Status-Line
l = l.split(None, 2) # l = l.split(None, 2)
# print(l) # print(l)
status = int(l[1]) # status = int(l[1]) # FIXME: Status-Code element is not currently checked
while True: while True:
l = s.readline() l = s.readline()
if not l or l == b"\r\n": if not l or l == b"\r\n":

Wyświetl plik

@ -63,7 +63,6 @@ ignore = [
"F405", "F405",
"E501", "E501",
"F541", "F541",
"F841",
"ISC001", "ISC001",
"ISC003", # micropython does not support implicit concatenation of f-strings "ISC003", # micropython does not support implicit concatenation of f-strings
"PIE810", # micropython does not support passing tuples to .startswith or .endswith "PIE810", # micropython does not support passing tuples to .startswith or .endswith

Wyświetl plik

@ -104,7 +104,6 @@ class ClientSession:
async def _request(self, method, url, data=None, json=None, ssl=None, params=None, headers={}): async def _request(self, method, url, data=None, json=None, ssl=None, params=None, headers={}):
redir_cnt = 0 redir_cnt = 0
redir_url = None
while redir_cnt < 2: while redir_cnt < 2:
reader = await self.request_raw(method, url, data, json, ssl, params, headers) reader = await self.request_raw(method, url, data, json, ssl, params, headers)
_headers = [] _headers = []

Wyświetl plik

@ -159,7 +159,7 @@ def decode_simple_value(decoder):
def decode_float16(decoder): def decode_float16(decoder):
payload = decoder.read(2) decoder.read(2)
raise NotImplementedError # no float16 unpack function raise NotImplementedError # no float16 unpack function