Skip to content

Remove SocketPoolContants #205

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions adafruit_esp32spi/adafruit_esp32spi_socketpool.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
_global_socketpool = {}


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

SOCK_STREAM = const(0)
SOCK_DGRAM = const(1)
Expand All @@ -39,10 +39,6 @@ class SocketPoolContants: # pylint: disable=too-few-public-methods

MAX_PACKET = const(4000)


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

def __new__(cls, iface: ESP_SPIcontrol):
# We want to make sure to return the same pool for the same interface
if iface not in _global_socketpool:
Expand All @@ -60,12 +56,12 @@ def getaddrinfo( # pylint: disable=too-many-arguments,unused-argument
if not isinstance(port, int):
raise ValueError("Port must be an integer")
ipaddr = self._interface.get_host_by_name(host)
return [(SocketPoolContants.AF_INET, socktype, proto, "", (ipaddr, port))]
return [(SocketPool.AF_INET, socktype, proto, "", (ipaddr, port))]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be a qualified name now.

Suggested change
return [(SocketPool.AF_INET, socktype, proto, "", (ipaddr, port))]
return [(AF_INET, socktype, proto, "", (ipaddr, port))]

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dhalbert happy to add this and the pylint ignore, but thought this was cleaner (and it works):
image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I see, sorry. I was just testing by importing it into CPython, which did not complain. But it doesn't run.


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