Skip to content

Commit f6c051e

Browse files
author
Jason Symons
committed
Run through pre-commit hooks
1 parent 3d2d3ed commit f6c051e

File tree

3 files changed

+48
-8
lines changed

3 files changed

+48
-8
lines changed

adafruit_espatcontrol/adafruit_espatcontrol.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,11 @@
3434

3535
import gc
3636
import time
37-
from digitalio import Direction
37+
from digitalio import Direction, DigitalInOut
3838

3939
try:
4040
import busio
4141
from typing import Optional, Dict, Union, List
42-
from digitalio import DigitalInOut
4342
except ImportError:
4443
pass
4544

@@ -175,7 +174,15 @@ def cipmux(self) -> int:
175174
return int(reply[8:])
176175
raise RuntimeError("Bad response to CIPMUX?")
177176

178-
def socket_connect(self, conntype: str, remote: str, remote_port: int, *, keepalive: int = 10, retries: int = 1) -> bool:
177+
def socket_connect(
178+
self,
179+
conntype: str,
180+
remote: str,
181+
remote_port: int,
182+
*,
183+
keepalive: int = 10,
184+
retries: int = 1
185+
) -> bool:
179186
"""Open a socket. conntype can be TYPE_TCP, TYPE_UDP, or TYPE_SSL. Remote
180187
can be an IP address or DNS (we'll do the lookup for you. Remote port
181188
is integer port on other side. We can't set the local port"""
@@ -314,7 +321,9 @@ def socket_disconnect(self) -> None:
314321

315322
# *************************** SNTP SETUP ****************************
316323

317-
def sntp_config(self, enable: bool, timezone: Optional[int] = None, server: Optional[str] = None) -> None:
324+
def sntp_config(
325+
self, enable: bool, timezone: Optional[int] = None, server: Optional[str] = None
326+
) -> None:
318327
"""Configure the built in ESP SNTP client with a UTC-offset number (timezone)
319328
and server as IP or hostname."""
320329
cmd = "AT+CIPSNTPCFG="
@@ -463,7 +472,9 @@ def join_AP(self, ssid: str, password: str) -> None: # pylint: disable=invalid-
463472
raise RuntimeError("Didn't get IP address")
464473
return
465474

466-
def scan_APs(self, retries: int = 3) -> Union[List[List[bytes]], None]: # pylint: disable=invalid-name
475+
def scan_APs( # pylint: disable=invalid-name
476+
self, retries: int = 3
477+
) -> Union[List[List[bytes]], None]:
467478
"""Ask the module to scan for access points and return a list of lists
468479
with name, RSSI, MAC addresses, etc"""
469480
for _ in range(retries):

adafruit_espatcontrol/adafruit_espatcontrol_socket.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,14 @@ def set_interface(iface: ESP_ATcontrol) -> None:
2424
AF_INET = const(2)
2525

2626
# pylint: disable=too-many-arguments, unused-argument
27-
def getaddrinfo(host: str, port: int, family: int = 0, socktype: int = 0, proto:int = 0, flags:int = 0) -> List[Tuple[int, int, int, str, Tuple[str, int]]]:
27+
def getaddrinfo(
28+
host: str,
29+
port: int,
30+
family: int = 0,
31+
socktype: int = 0,
32+
proto: int = 0,
33+
flags: int = 0,
34+
) -> List[Tuple[int, int, int, str, Tuple[str, int]]]:
2835
"""Given a hostname and a port name, return a 'socket.getaddrinfo'
2936
compatible list of tuples. Honestly, we ignore anything but host & port"""
3037
if not isinstance(port, int):
@@ -41,7 +48,13 @@ class socket:
4148
"""A simplified implementation of the Python 'socket' class, for connecting
4249
through an interface to a remote device"""
4350

44-
def __init__(self, family: int = AF_INET, type: int = SOCK_STREAM, proto: int = 0, fileno: Optional[int] = None) -> None:
51+
def __init__(
52+
self,
53+
family: int = AF_INET,
54+
type: int = SOCK_STREAM,
55+
proto: int = 0,
56+
fileno: Optional[int] = None,
57+
) -> None:
4558
if family != AF_INET:
4659
raise RuntimeError("Only AF_INET family supported")
4760
if type != SOCK_STREAM:

adafruit_espatcontrol/adafruit_espatcontrol_wifimanager.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,34 @@
2121
from typing import Dict, Protocol, Any, Optional, Union, Tuple
2222

2323
class Pixel(Protocol):
24+
"""
25+
A class for providing type hints for parameters
26+
requiring a pixel device (NeoPixel/DotStar)
27+
"""
28+
2429
def fill(self, value: Union[int, Tuple[int, int, int]]) -> Any:
30+
"""
31+
Duck types out the fill method for pixel devices
32+
"""
2533
...
2634

35+
2736
except ImportError:
2837
pass
2938

39+
3040
class ESPAT_WiFiManager:
3141
"""
3242
A class to help manage the Wifi connection
3343
"""
3444

35-
def __init__(self, esp: ESP_ATcontrol, secrets: Dict[str, Union[str, int]], status_pixel: Optional[Pixel] = None, attempts: int = 2):
45+
def __init__(
46+
self,
47+
esp: ESP_ATcontrol,
48+
secrets: Dict[str, Union[str, int]],
49+
status_pixel: Optional[Pixel] = None,
50+
attempts: int = 2,
51+
):
3652
"""
3753
:param ESP_SPIcontrol esp: The ESP object we are using
3854
:param dict secrets: The WiFi and Adafruit IO secrets dict (See examples)

0 commit comments

Comments
 (0)