Explorar el Código

Add more linting and update the version

Nik Rolls hace 5 años
padre
commit
ccbed735d1

+ 21 - 0
.github/workflows/linting.yml

@@ -0,0 +1,21 @@
+name: Linting
+
+on: [push, pull_request]
+
+jobs:
+  lint:
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v2
+
+      - name: Setup Python
+        uses: actions/setup-python@v1
+        with:
+          python-version: 3.7
+
+      - name: Install dependencies
+        run: pip install --pre -r requirements.txt
+      - name: isort
+        run: isort --recursive --diff
+      - name: Black
+        run: black --check .

+ 1 - 1
custom_components/goldair_climate/__init__.py

@@ -34,7 +34,7 @@ from .config_flow import ConfigFlowHandler
 
 _LOGGER = logging.getLogger(__name__)
 
-VERSION = "0.0.8"
+VERSION = "0.1.0"
 
 CONFIG_SCHEMA = vol.Schema(
     {DOMAIN: vol.All(cv.ensure_list, [vol.Schema(individual_config_schema())])},

+ 10 - 3
custom_components/goldair_climate/climate.py

@@ -2,8 +2,15 @@
 Setup for different kinds of Goldair climate devices
 """
 from . import DOMAIN
-from .const import (CONF_DEVICE_ID, CONF_TYPE, CONF_TYPE_DEHUMIDIFIER,
-                    CONF_TYPE_FAN, CONF_TYPE_HEATER, CONF_CLIMATE, CONF_TYPE_AUTO)
+from .const import (
+    CONF_DEVICE_ID,
+    CONF_TYPE,
+    CONF_TYPE_DEHUMIDIFIER,
+    CONF_TYPE_FAN,
+    CONF_TYPE_HEATER,
+    CONF_CLIMATE,
+    CONF_TYPE_AUTO,
+)
 from .dehumidifier.climate import GoldairDehumidifier
 from .fan.climate import GoldairFan
 from .heater.climate import GoldairHeater
@@ -12,7 +19,7 @@ from .heater.climate import GoldairHeater
 async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
     """Set up the Goldair climate device according to its type."""
     data = hass.data[DOMAIN][discovery_info[CONF_DEVICE_ID]]
-    device = data['device']
+    device = data["device"]
 
     if discovery_info[CONF_TYPE] == CONF_TYPE_AUTO:
         discovery_info[CONF_TYPE] = await device.async_inferred_type()

+ 36 - 7
custom_components/goldair_climate/configuration.py

@@ -1,9 +1,18 @@
 import voluptuous as vol
 from homeassistant.const import CONF_NAME, CONF_HOST
 
-from .const import (CONF_DEVICE_ID, CONF_LOCAL_KEY, CONF_TYPE, CONF_TYPE_HEATER,
-                    CONF_TYPE_DEHUMIDIFIER, CONF_TYPE_FAN, CONF_CLIMATE, CONF_DISPLAY_LIGHT, CONF_CHILD_LOCK,
-                    CONF_TYPE_AUTO)
+from .const import (
+    CONF_DEVICE_ID,
+    CONF_LOCAL_KEY,
+    CONF_TYPE,
+    CONF_TYPE_HEATER,
+    CONF_TYPE_DEHUMIDIFIER,
+    CONF_TYPE_FAN,
+    CONF_CLIMATE,
+    CONF_DISPLAY_LIGHT,
+    CONF_CHILD_LOCK,
+    CONF_TYPE_AUTO,
+)
 
 INDIVIDUAL_CONFIG_SCHEMA_TEMPLATE = [
     {"key": CONF_NAME, "type": str, "required": True, "option": False},
@@ -12,14 +21,34 @@ INDIVIDUAL_CONFIG_SCHEMA_TEMPLATE = [
     {"key": CONF_LOCAL_KEY, "type": str, "required": True, "option": True},
     {
         "key": CONF_TYPE,
-        "type": vol.In([CONF_TYPE_AUTO, CONF_TYPE_HEATER, CONF_TYPE_DEHUMIDIFIER, CONF_TYPE_FAN]),
+        "type": vol.In(
+            [CONF_TYPE_AUTO, CONF_TYPE_HEATER, CONF_TYPE_DEHUMIDIFIER, CONF_TYPE_FAN]
+        ),
         "required": False,
         "default": CONF_TYPE_AUTO,
         "option": True,
     },
-    {"key": CONF_CLIMATE, "type": bool, "required": False, "default": True, "option": True},
-    {"key": CONF_DISPLAY_LIGHT, "type": bool, "required": False, "default": False, "option": True},
-    {"key": CONF_CHILD_LOCK, "type": bool, "required": False, "default": False, "option": True},
+    {
+        "key": CONF_CLIMATE,
+        "type": bool,
+        "required": False,
+        "default": True,
+        "option": True,
+    },
+    {
+        "key": CONF_DISPLAY_LIGHT,
+        "type": bool,
+        "required": False,
+        "default": False,
+        "option": True,
+    },
+    {
+        "key": CONF_CHILD_LOCK,
+        "type": bool,
+        "required": False,
+        "default": False,
+        "option": True,
+    },
 ]
 
 

+ 10 - 3
custom_components/goldair_climate/light.py

@@ -2,8 +2,15 @@
 Setup for different kinds of Goldair climate devices
 """
 from . import DOMAIN
-from .const import (CONF_DEVICE_ID, CONF_TYPE, CONF_TYPE_DEHUMIDIFIER,
-                    CONF_TYPE_FAN, CONF_TYPE_HEATER, CONF_DISPLAY_LIGHT, CONF_TYPE_AUTO)
+from .const import (
+    CONF_DEVICE_ID,
+    CONF_TYPE,
+    CONF_TYPE_DEHUMIDIFIER,
+    CONF_TYPE_FAN,
+    CONF_TYPE_HEATER,
+    CONF_DISPLAY_LIGHT,
+    CONF_TYPE_AUTO,
+)
 from .dehumidifier.light import GoldairDehumidifierLedDisplayLight
 from .fan.light import GoldairFanLedDisplayLight
 from .heater.light import GoldairHeaterLedDisplayLight
@@ -12,7 +19,7 @@ from .heater.light import GoldairHeaterLedDisplayLight
 async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
     """Set up the Goldair climate device according to its type."""
     data = hass.data[DOMAIN][discovery_info[CONF_DEVICE_ID]]
-    device = data['device']
+    device = data["device"]
 
     if discovery_info[CONF_TYPE] == CONF_TYPE_AUTO:
         discovery_info[CONF_TYPE] = await device.async_inferred_type()

+ 2 - 6
custom_components/goldair_climate/manifest.json

@@ -3,11 +3,7 @@
   "name": "Goldair WiFi climate devices",
   "documentation": "https://github.com/nikrolls/homeassistant-goldair-climate",
   "dependencies": [],
-  "codeowners": [
-    "@nikrolls"
-  ],
-  "requirements": [
-    "pytuya>=7.0.5"
-  ],
+  "codeowners": ["@nikrolls"],
+  "requirements": ["pytuya>=7.0.5"],
   "config_flow": true
 }

+ 2 - 0
requirements.txt

@@ -0,0 +1,2 @@
+black==19.*
+isort==4.*