Skip to content

Use Protocol type annotation #18

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 2 commits into from
Aug 22, 2022
Merged
Show file tree
Hide file tree
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
13 changes: 4 additions & 9 deletions adafruit_lifx.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,9 @@
LIFX_URL = "https://api.lifx.com/v1/lights/"

try:
from typing import Union, Dict, Any
from adafruit_esp32spi.adafruit_esp32spi_wifimanager import ESPSPI_WiFiManager
from adafruit_espatcontrol.adafruit_espatcontrol_wifimanager import (
ESPAT_WiFiManager,
)
from adafruit_requests import Session, Response

WifiManagerType = Union[ESPSPI_WiFiManager, ESPAT_WiFiManager, Session]
from typing import Dict, Any
from circuitpython_typing.http import HTTPProtocol
from adafruit_requests import Response
except ImportError:
pass

Expand All @@ -55,7 +50,7 @@ class LIFX:
:param str lifx_token: LIFX API token (https://api.developer.lifx.com/docs/authentication)
"""

def __init__(self, wifi_manager: WifiManagerType, lifx_token: str) -> None:
def __init__(self, wifi_manager: HTTPProtocol, lifx_token: str) -> None:
wifi_type = str(type(wifi_manager))
allowed_wifi_types = ("ESPSPI_WiFiManager", "ESPAT_WiFiManager", "Session")
if any(x in wifi_type for x in allowed_wifi_types):
Expand Down
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@
# SPDX-License-Identifier: Unlicense

Adafruit-Blinka
adafruit-circuitpython-typing~=1.8
adafruit-circuitpython-requests
adafruit-circuitpython-esp32spi
adafruit-circuitpython-esp-atcontrol