diff --git a/custom_components/localtuya/__init__.py b/custom_components/localtuya/__init__.py index eae9853..d4549a1 100644 --- a/custom_components/localtuya/__init__.py +++ b/custom_components/localtuya/__init__.py @@ -1,4 +1,4 @@ -"""The LocalTuya integration. """ +"""The LocalTuya integration.""" import asyncio import logging import time diff --git a/custom_components/localtuya/cloud_api.py b/custom_components/localtuya/cloud_api.py index b55c46f..76687c2 100755 --- a/custom_components/localtuya/cloud_api.py +++ b/custom_components/localtuya/cloud_api.py @@ -10,6 +10,7 @@ import requests # Signature algorithm. def calc_sign(msg, key): + """Calculate signature for request.""" sign = ( hmac.new( msg=bytes(msg, "latin-1"), @@ -36,6 +37,7 @@ class TuyaCloudApi: self._device_list = {} def generate_payload(self, method, t, url, headers, body=None): + """Generate signed payload for requests.""" payload = self._client_id + self._access_token + t payload += method + "\n" diff --git a/custom_components/localtuya/common.py b/custom_components/localtuya/common.py index d3e691b..372b61e 100644 --- a/custom_components/localtuya/common.py +++ b/custom_components/localtuya/common.py @@ -218,6 +218,7 @@ class TuyaDevice(pytuya.TuyaListener, pytuya.ContextualLogger): self._connect_task = None async def update_local_key(self): + """Retrieve updated local_key from Cloud API and update the config_entry.""" dev_id = self._dev_config_entry[CONF_DEVICE_ID] await self._hass.data[DOMAIN][DATA_CLOUD].async_get_devices_list() cloud_devs = self._hass.data[DOMAIN][DATA_CLOUD]._device_list diff --git a/custom_components/localtuya/config_flow.py b/custom_components/localtuya/config_flow.py index 3de2284..605ea03 100644 --- a/custom_components/localtuya/config_flow.py +++ b/custom_components/localtuya/config_flow.py @@ -593,6 +593,7 @@ class LocalTuyaOptionsFlowHandler(config_entries.OptionsFlow): return self.async_show_form(step_id="pick_entity_type", data_schema=schema) def available_dps_strings(self): + """Return list of DPs use by the device's entities.""" available_dps = [] used_dps = [str(entity[CONF_ID]) for entity in self.entities] for dp_string in self.dps_strings: diff --git a/requirements_test.txt b/requirements_test.txt index ca811a0..d803b74 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -1,4 +1,4 @@ -black==21.4b0 +black==22.3.0 codespell==2.0.0 flake8==3.9.2 mypy==0.901 @@ -7,4 +7,3 @@ cryptography==3.3.2 pylint==2.8.2 pylint-strict-informational==0.1 homeassistant==2022.5.1 -tox==3.25.0 diff --git a/tox.ini b/tox.ini index 033e723..0a642b7 100644 --- a/tox.ini +++ b/tox.ini @@ -27,7 +27,7 @@ ignore_errors = True deps = {[testenv]deps} commands = - codespell -q 4 -L {[tox]cs_exclude_words} --skip="*.pyc,*.pyi,*~" custom_components + codespell -q 4 -L {[tox]cs_exclude_words} --skip="*.pyc,*.pyi,*~,*.json" custom_components flake8 custom_components black --fast --check . pydocstyle -v custom_components