Improve entity type hints [a] (#76986)

This commit is contained in:
epenet 2022-08-18 15:56:52 +02:00 committed by GitHub
parent 24f1287bf9
commit 65eb1584f7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
31 changed files with 152 additions and 124 deletions

View file

@ -3,6 +3,7 @@ from __future__ import annotations
from http import HTTPStatus
import logging
from typing import Any
import requests
import voluptuous as vol
@ -122,7 +123,7 @@ class ArestSwitchFunction(ArestSwitchBase):
except ValueError:
_LOGGER.error("Response invalid")
def turn_on(self, **kwargs):
def turn_on(self, **kwargs: Any) -> None:
"""Turn the device on."""
request = requests.get(
f"{self._resource}/{self._func}", timeout=10, params={"params": "1"}
@ -133,7 +134,7 @@ class ArestSwitchFunction(ArestSwitchBase):
else:
_LOGGER.error("Can't turn on function %s at %s", self._func, self._resource)
def turn_off(self, **kwargs):
def turn_off(self, **kwargs: Any) -> None:
"""Turn the device off."""
request = requests.get(
f"{self._resource}/{self._func}", timeout=10, params={"params": "0"}
@ -146,7 +147,7 @@ class ArestSwitchFunction(ArestSwitchBase):
"Can't turn off function %s at %s", self._func, self._resource
)
def update(self):
def update(self) -> None:
"""Get the latest data from aREST API and update the state."""
try:
request = requests.get(f"{self._resource}/{self._func}", timeout=10)
@ -171,7 +172,7 @@ class ArestSwitchPin(ArestSwitchBase):
_LOGGER.error("Can't set mode")
self._attr_available = False
def turn_on(self, **kwargs):
def turn_on(self, **kwargs: Any) -> None:
"""Turn the device on."""
turn_on_payload = int(not self.invert)
request = requests.get(
@ -182,7 +183,7 @@ class ArestSwitchPin(ArestSwitchBase):
else:
_LOGGER.error("Can't turn on pin %s at %s", self._pin, self._resource)
def turn_off(self, **kwargs):
def turn_off(self, **kwargs: Any) -> None:
"""Turn the device off."""
turn_off_payload = int(self.invert)
request = requests.get(
@ -193,7 +194,7 @@ class ArestSwitchPin(ArestSwitchBase):
else:
_LOGGER.error("Can't turn off pin %s at %s", self._pin, self._resource)
def update(self):
def update(self) -> None:
"""Get the latest data from aREST API and update the state."""
try:
request = requests.get(f"{self._resource}/digital/{self._pin}", timeout=10)