Skip to content

Commit 8f0c1db

Browse files
author
BiffoBear
committed
Removed TODO notes
1 parent 6f7672f commit 8f0c1db

File tree

4 files changed

+8
-20
lines changed

4 files changed

+8
-20
lines changed

adafruit_wiznet5k/adafruit_wiznet5k_dhcp.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ def send_dhcp_message(
254254
# pylint: disable=too-many-branches, too-many-statements
255255
def parse_dhcp_response(
256256
self,
257-
) -> Union[Tuple[int, bytes], Tuple[int, int]]: # TODO: ****
257+
) -> Union[Tuple[int, bytes], Tuple[int, int]]:
258258
"""Parse DHCP response from DHCP server.
259259
260260
:return Union[Tuple[int, bytes], Tuple[int, int]]: DHCP packet type.
@@ -272,13 +272,11 @@ def parse_dhcp_response(
272272
DHCP message OP is not expected BOOT Reply."
273273

274274
xid = _BUFF[4:8]
275-
# TODO: ValueError bytes & int
276275
if bytes(xid) < self._initial_xid:
277276
print("f")
278277
return 0, 0
279278

280279
self.local_ip = tuple(_BUFF[16:20])
281-
# TODO: Don't think this will ever be True
282280
if _BUFF[28:34] == 0:
283281
return 0, 0
284282

@@ -424,7 +422,6 @@ def _dhcp_state_machine(self) -> None:
424422
if msg_type == DHCP_OFFER:
425423
# Check if transaction ID matches, otherwise it may be an offer
426424
# for another device
427-
# TODO: xid is already an int
428425
if htonl(self._transaction_id) == int.from_bytes(xid, "big"):
429426
if self._debug:
430427
print(
@@ -449,7 +446,6 @@ def _dhcp_state_machine(self) -> None:
449446
msg_type, xid = self.parse_dhcp_response()
450447
# Check if transaction ID matches, otherwise it may be
451448
# for another device
452-
# TODO: xid is already an int
453449
if htonl(self._transaction_id) == int.from_bytes(xid, "big"):
454450
if msg_type == DHCP_ACK:
455451
if self._debug:

adafruit_wiznet5k/adafruit_wiznet5k_dns.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def __init__(
6666
self._sock.settimeout(1)
6767

6868
self._dns_server = dns_address
69-
self._host = 0 # TODO: make b"" to resolve a type error with .decode in _build_dns_ques...
69+
self._host = 0
7070
self._request_id = 0 # request identifier
7171
self._pkt_buf = bytearray()
7272

@@ -78,7 +78,6 @@ def gethostbyname(self, hostname: bytes) -> Union[int, bytes]:
7878
7979
:return Union[int, bytes] The IPv4 address if successful, -1 otherwise.
8080
"""
81-
# TODO: See if it will take a string.
8281
if self._dns_server is None:
8382
return INVALID_SERVER
8483
self._host = hostname
@@ -143,7 +142,7 @@ def _parse_dns_response(
143142
return -1
144143
# Validate flags
145144
flags = int.from_bytes(self._pkt_buf[2:4], "big")
146-
if not flags in (0x8180, 0x8580): # TODO: Should be `flags not in ...`
145+
if not flags in (0x8180, 0x8580):
147146
if self._debug:
148147
print("* DNS ERROR: Invalid flags, ", flags)
149148
return -1

adafruit_wiznet5k/adafruit_wiznet5k_ntp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def __init__(
3737
self,
3838
iface: adafruit_wiznet5k.WIZNET5K,
3939
ntp_address: str,
40-
utc: int, # TODO: Should be float. India is UTC + 7.5
40+
utc: int,
4141
debug: bool = False,
4242
) -> None:
4343
"""

adafruit_wiznet5k/adafruit_wiznet5k_socket.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,6 @@ def getaddrinfo(
9393
:param int proto: Unused in this implementation of socket.
9494
:param int flags: Unused in this implementation of socket.
9595
"""
96-
# TODO: Python socket accepts port as a string or int or None. How are str and None handled?
97-
# TODO: Python socket has arg type in place of socktype.
9896
if not isinstance(port, int):
9997
raise RuntimeError("Port must be an integer")
10098
if is_ipv4(host):
@@ -322,7 +320,6 @@ def accept(
322320
self._socknum = new_listen_socknum # pylint: disable=protected-access
323321
self.bind((None, self._listen_port))
324322
self.listen()
325-
# TODO: Weird logic below. Should be an if, not a while
326323
while self.status != wiznet5k.adafruit_wiznet5k.SNSR_SOCK_LISTEN:
327324
raise RuntimeError("Failed to open new listening socket")
328325
return client_sock, addr
@@ -340,7 +337,6 @@ def connect(
340337
:param Optional[int] conntype: Raises an exception if set to 3, unused otherwise, defaults
341338
to None.
342339
"""
343-
# TODO: conntype unused beyond raising an exception.
344340
assert (
345341
conntype != 0x03
346342
), "Error: SSL/TLS is not currently supported by CircuitPython."
@@ -380,7 +376,7 @@ def sendto(self, data: bytearray, address: [Tuple[str, int]]) -> None:
380376
:param tuple address: Remote socket as a (host, port) tuple.
381377
"""
382378
self.connect(address)
383-
return self.send(data) # TODO: send only returns None, so can delete
379+
return self.send(data)
384380

385381
def recv(
386382
# pylint: disable=too-many-branches
@@ -431,17 +427,15 @@ def recv(
431427
elif self._sock_type == SOCK_DGRAM:
432428
recv = _the_interface.read_udp(self.socknum, min(to_read, avail))[1]
433429
to_read = len(recv) # only get this dgram
434-
recv = bytes(
435-
recv
436-
) # TODO: Maybe raise a specific exception before this line
430+
recv = bytes(recv)
437431
received.append(recv)
438432
to_read -= len(recv)
439433
gc.collect()
440434
if self._timeout > 0 and time.monotonic() - stamp > self._timeout:
441435
break
442436
self._buffer += b"".join(received)
443437

444-
ret = None # TODO: Unused definition
438+
ret = None
445439
if len(self._buffer) == bufsize:
446440
ret = self._buffer
447441
self._buffer = b""
@@ -463,9 +457,8 @@ def embed_recv(
463457
464458
:return bytes: All data available from the connection.
465459
"""
466-
# TODO: bufsize unused
467460
# print("Socket read", bufsize)
468-
ret = None # TODO: Useless definition
461+
ret = None
469462
avail = self.available()
470463
if avail:
471464
if self._sock_type == SOCK_STREAM:

0 commit comments

Comments
 (0)