Skip to content

Commit b632fdd

Browse files
author
BiffoBear
committed
Made changes to types requested in review. Additionally removed all 'Any' types for unused parameters. Replaced with types from CPython.
1 parent b2d5882 commit b632fdd

File tree

4 files changed

+19
-19
lines changed

4 files changed

+19
-19
lines changed

adafruit_wiznet5k/adafruit_wiznet5k.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ def remote_port(self, socket_num: int) -> Union[int, bytearray]:
418418
@property
419419
def ifconfig(
420420
self,
421-
) -> Tuple[bytearray, bytearray, bytearray, Tuple[int, int, int, int]]: # *1
421+
) -> Tuple[bytearray, bytearray, bytearray, Tuple[int, int, int, int]]:
422422
"""
423423
Network configuration information.
424424
@@ -1143,7 +1143,7 @@ def _write_socket(self, sock: int, address: int, data: int) -> None:
11431143
)
11441144
return None
11451145

1146-
def _read_socket(self, sock: int, address: int) -> Optional[bytearray]: # *1
1146+
def _read_socket(self, sock: int, address: int) -> Optional[bytearray]:
11471147
"""Read a W5k socket register."""
11481148
if self._chip_type == "w5500":
11491149
cntl_byte = (sock << 5) + 0x08

adafruit_wiznet5k/adafruit_wiznet5k_dhcp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def __init__(
9898
eth: WIZNET5K,
9999
mac_address: Sequence[Union[int, bytes]],
100100
hostname: Optional[str] = None,
101-
response_timeout: float = 30,
101+
response_timeout: float = 30.0,
102102
debug: bool = False,
103103
) -> None:
104104
"""

adafruit_wiznet5k/adafruit_wiznet5k_ntp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def __init__(
4646
"""
4747
:param adafruit_wiznet5k.WIZNET5K iface: Wiznet 5k object.
4848
:param str ntp_address: The hostname of the NTP server.
49-
:param int utc: Numbers of hours to offset time from UTC.
49+
:param float utc: Numbers of hours to offset time from UTC.
5050
:param bool debug: Enable debugging output, defaults to False.
5151
"""
5252
self._debug = debug

adafruit_wiznet5k/adafruit_wiznet5k_socket.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from __future__ import annotations
1616

1717
try:
18-
from typing import TYPE_CHECKING, Any, Optional, Tuple, List, Union
18+
from typing import TYPE_CHECKING, Optional, Tuple, List, Union
1919

2020
if TYPE_CHECKING:
2121
from adafruit_wiznet5k.adafruit_wiznet5k import WIZNET5K
@@ -149,17 +149,17 @@ def __init__(
149149
self,
150150
family: int = AF_INET,
151151
type: int = SOCK_STREAM,
152-
proto: Any = 0,
152+
proto: int = 0,
153153
fileno: Optional[int] = None,
154154
socknum: Optional[int] = None,
155155
) -> None:
156156
"""
157157
:param int family: Socket address (and protocol) family, defaults to AF_INET.
158158
:param int type: Socket type, use SOCK_STREAM for TCP and SOCK_DGRAM for UDP,
159159
defaults to SOCK_STREAM.
160-
:param Any proto: Unused, retained for compatibility.
161-
:param Optional[Any] fileno: Unused, retained for compatibility.
162-
:param Optional[Any] socknum: Unused, retained for compatibility.
160+
:param int proto: Unused, retained for compatibility.
161+
:param Optional[int] fileno: Unused, retained for compatibility.
162+
:param Optional[int] socknum: Unused, retained for compatibility.
163163
"""
164164
if family != AF_INET:
165165
raise RuntimeError("Only AF_INET family supported by W5K modules.")
@@ -277,11 +277,11 @@ def bind(self, address: Tuple[Optional[str], int]) -> None:
277277
)
278278
self._buffer = b""
279279

280-
def listen(self, backlog: Optional[Any] = None) -> None:
280+
def listen(self, backlog: Optional[int] = None) -> None:
281281
"""
282282
Listen on the port specified by bind.
283283
284-
:param Optional[Any] backlog: Included for compatibility but ignored.
284+
:param Optional[int] backlog: Included for compatibility but ignored.
285285
"""
286286
assert self._listen_port is not None, "Use bind to set the port before listen!"
287287
_the_interface.socket_listen(self.socknum, self._listen_port)
@@ -385,7 +385,7 @@ def recv(
385385
# pylint: disable=too-many-branches
386386
self,
387387
bufsize: int = 0,
388-
flags: Any = 0,
388+
flags: int = 0,
389389
) -> bytes:
390390
"""
391391
Read from the connected remote address.
@@ -451,7 +451,7 @@ def recv(
451451
return ret
452452

453453
def embed_recv(
454-
self, bufsize: int = 0, flags: Any = 0
454+
self, bufsize: int = 0, flags: int = 0
455455
) -> bytes: # pylint: disable=too-many-branches
456456
"""
457457
Read from the connected remote address.
@@ -478,13 +478,13 @@ def embed_recv(
478478
return ret
479479

480480
def recvfrom(
481-
self, bufsize: int = 0, flags: Any = 0
481+
self, bufsize: int = 0, flags: int = 0
482482
) -> Tuple[bytes, Tuple[str, int]]:
483483
"""
484484
Read some bytes from the connected remote address.
485485
486486
:param int bufsize: Maximum number of bytes to receive.
487-
:param Any flags: ignored, present for compatibility.
487+
:param int flags: ignored, present for compatibility.
488488
489489
:return Tuple[bytes, Tuple[str, int]]: a tuple (bytes, address)
490490
where address is a tuple (ip, port)
@@ -497,13 +497,13 @@ def recvfrom(
497497
),
498498
)
499499

500-
def recv_into(self, buf: bytearray, nbytes: int = 0, flags: Any = 0) -> int:
500+
def recv_into(self, buf: bytearray, nbytes: int = 0, flags: int = 0) -> int:
501501
"""
502502
Read from the connected remote address into the provided buffer.
503503
504504
:param bytearray buf: Data buffer
505505
:param nbytes: Maximum number of bytes to receive
506-
:param Any flags: ignored, present for compatibility.
506+
:param int flags: ignored, present for compatibility.
507507
508508
:return int: the number of bytes received
509509
"""
@@ -515,7 +515,7 @@ def recv_into(self, buf: bytearray, nbytes: int = 0, flags: Any = 0) -> int:
515515
return nbytes
516516

517517
def recvfrom_into(
518-
self, buf: bytearray, nbytes: int = 0, flags: Any = 0
518+
self, buf: bytearray, nbytes: int = 0, flags: int = 0
519519
) -> Tuple[int, Tuple[str, int]]:
520520
"""
521521
Read some bytes from the connected remote address into the provided buffer.
@@ -540,7 +540,7 @@ def readline(self) -> bytes:
540540
Read a line from the socket.
541541
542542
Attempt to return as many bytes as we can up to but not including a carriage return and
543-
linefeed charater pair.
543+
linefeed character pair.
544544
545545
:return bytes: The data read from the socket.
546546
"""

0 commit comments

Comments
 (0)