From 487a13d895948feee8646788bd1d6e9cc31db753 Mon Sep 17 00:00:00 2001 From: Felipe Martins Diel Date: Thu, 17 Sep 2020 03:19:24 -0300 Subject: [PATCH] Improve annotations --- broadlink/__init__.py | 8 ++++---- broadlink/climate.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/broadlink/__init__.py b/broadlink/__init__.py index c3798dc..8b0eca9 100644 --- a/broadlink/__init__.py +++ b/broadlink/__init__.py @@ -3,7 +3,7 @@ import socket import time from datetime import datetime -from typing import List, Union, Tuple +from typing import Dict, List, Union, Tuple, Type from .alarm import S1C from .cover import dooya @@ -17,7 +17,7 @@ from .switch import bg1, mp1, sp1, sp2 from .helpers import calculate_crc16, get_local_ip -def get_devices() -> dict: +def get_devices() -> Dict[int, Tuple[Type[device], str, str]]: """Return all supported devices.""" return { 0x0000: (sp1, "SP1", "Broadlink"), @@ -90,7 +90,7 @@ def gendevice( mac: Union[bytes, str], name: str = None, is_locked: bool = None, -): +) -> device: """Generate a device.""" try: dev_class, model, manufacturer = get_devices()[dev_type] @@ -114,7 +114,7 @@ def discover( local_ip_address: str = None, discover_ip_address: str = '255.255.255.255', discover_ip_port: int = 80, -) -> list: +) -> List[device]: """Discover devices connected to the local network.""" local_ip_address = local_ip_address or get_local_ip() address = local_ip_address.split('.') diff --git a/broadlink/climate.py b/broadlink/climate.py index 427063f..353ad59 100644 --- a/broadlink/climate.py +++ b/broadlink/climate.py @@ -19,7 +19,7 @@ class hysen(device): # New behaviour: raises a ValueError if the device response indicates an error or CRC check fails # The function prepends length (2 bytes) and appends CRC - def send_request(self, input_payload: bytes) -> bytes: + def send_request(self, input_payload: bytearray) -> bytes: """Send a request to the device.""" crc = calculate_crc16(bytes(input_payload))