Skip to content

Commit

Permalink
Merge pull request #162 from justmobilize/remove-socket-pool-contants
Browse files Browse the repository at this point in the history
Remove SocketPoolContants
  • Loading branch information
dhalbert authored May 21, 2024
2 parents 66ffd0b + ebf4677 commit fe0e02a
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions adafruit_wiznet5k/adafruit_wiznet5k_socketpool.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@
_global_socketpool = {}


class SocketPoolContants: # pylint: disable=too-few-public-methods
"""Helper class for the constants that are needed everywhere"""
class SocketPool:
"""WIZNET5K SocketPool library"""

# These must match circuitpython "socketpoool" values. However, we cannot
# These must match circuitpython "socketpool" values. However, we cannot
# depend on socketpool being importable, so hard-code them here.
SOCK_STREAM = 1
SOCK_DGRAM = 2
Expand All @@ -50,10 +50,6 @@ class SocketPoolContants: # pylint: disable=too-few-public-methods

AF_INET = const(3)


class SocketPool(SocketPoolContants):
"""WIZNET5K SocketPool library"""

def __new__(cls, iface: WIZNET5K):
# We want to make sure to return the same pool for the same interface
if iface not in _global_socketpool:
Expand Down Expand Up @@ -191,7 +187,7 @@ def getaddrinfo( # pylint: disable=redefined-builtin,too-many-arguments,unused-
raise ValueError("Port must be an integer")
if not self._is_ipv4_string(host):
host = self.gethostbyname(host)
return [(SocketPoolContants.AF_INET, type, proto, "", (host, port))]
return [(SocketPool.AF_INET, type, proto, "", (host, port))]

def gethostbyname(self, hostname: str) -> str:
"""
Expand All @@ -210,8 +206,8 @@ def gethostbyname(self, hostname: str) -> str:

def socket( # pylint: disable=redefined-builtin
self,
family: int = SocketPoolContants.AF_INET,
type: int = SocketPoolContants.SOCK_STREAM,
family: int = AF_INET,
type: int = SOCK_STREAM,
proto: int = 0,
fileno: Optional[int] = None,
):
Expand Down

0 comments on commit fe0e02a

Please sign in to comment.