Skip to content

Commit

Permalink
build: enable pre-commit (#39)
Browse files Browse the repository at this point in the history
* build: enable pre-commit

* chore: add missing dependency

* chore: fix typing

* chore: update env to python 3.12

* chore: move HA to dev requirements

* chore: fix typing

* chore: spaces
  • Loading branch information
chemelli74 authored May 30, 2024
1 parent 928f4e2 commit fd63a03
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 9 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ jobs:
# list of files that changed across commits
fetch-depth: 0

- uses: actions/setup-python@v3
with:
python-version: '3.12'

- name: Pre-commit
uses: pre-commit/action@v3.0.1

- name: Super-linter
uses: super-linter/super-linter@v6.4.1 # x-release-please-version
env:
Expand Down
5 changes: 4 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
exclude: "CHANGELOG.md|.copier-answers.yml"
default_stages: [commit]

default_language_version:
python: python3.12

ci:
autofix_commit_msg: "chore(pre-commit.ci): auto fixes"
autoupdate_commit_msg: "chore(pre-commit.ci): pre-commit autoupdate"
Expand Down Expand Up @@ -53,4 +56,4 @@ repos:
rev: v1.10.0
hooks:
- id: mypy
additional_dependencies: []
additional_dependencies: [homeassistant==2024.5.1]
6 changes: 3 additions & 3 deletions custom_components/midea_ac_lan/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def is_on(self) -> bool:
return self.hvac_mode != HVACMode.OFF

@property
def hvac_mode(self) -> str:
def hvac_mode(self) -> HVACMode:
if self._device.get_attribute("power"):
return self._modes[self._device.get_attribute("mode")]
else:
Expand Down Expand Up @@ -449,7 +449,7 @@ def turn_off(self):
self._device.set_attribute(attr=self._power_attr, value=False)

@property
def hvac_mode(self) -> str:
def hvac_mode(self) -> HVACMode:
if self._device.get_attribute(self._power_attr):
return self._modes[self._device.get_attribute(C3Attributes.mode)]
else:
Expand Down Expand Up @@ -533,7 +533,7 @@ def target_temperature_high(self):
return 35

@property
def hvac_mode(self) -> str:
def hvac_mode(self) -> HVACMode:
return (
HVACMode.HEAT
if self._device.get_attribute(attr=FBAttributes.power)
Expand Down
3 changes: 2 additions & 1 deletion custom_components/midea_ac_lan/config_flow.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
from typing import Any

import voluptuous as vol

Expand Down Expand Up @@ -75,7 +76,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
devices: dict = {}
found_device: dict = {}
supports: dict = {}
unsorted: dict[int, str] = {}
unsorted: dict[int, Any] = {}
account: dict = {}
cloud: MideaCloud | None = None
session = None
Expand Down
2 changes: 1 addition & 1 deletion custom_components/midea_ac_lan/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def supported_features(self) -> LightEntityFeature:
supported_features |= SUPPORT_EFFECT
if self._device.get_attribute(X13Attributes.rgb_color):
supported_features |= SUPPORT_COLOR
return supported_features
return LightEntityFeature(supported_features)

def turn_on(self, **kwargs: Any):
if not self.is_on:
Expand Down
2 changes: 1 addition & 1 deletion custom_components/midea_ac_lan/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ def unlock(self, **kwargs) -> None:
self._device.set_attribute(attr=self._entity_key, value=False)

def open(self, **kwargs) -> None:
self.async_unlock()
self.unlock()
4 changes: 3 additions & 1 deletion requirements.dev.txt
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
mypy==1.10.0
homeassistant==2024.5.1
mypy==1.10.0
pre-commit==3.7.1
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
homeassistant==2024.5.1
pycryptodome==3.20.0
midea-local==1.0.3
3 changes: 3 additions & 0 deletions scripts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ cd "$(dirname "$0")/.."
python3 -m pip install --requirement requirements.txt
python3 -m pip install --requirement requirements.dev.txt

# Install pre-commit hooks on commit
pre-commit install

# Create config dir if not present
if [[ ! -d "${PWD}/config" ]]; then
mkdir -p "${PWD}/config"
Expand Down

0 comments on commit fd63a03

Please sign in to comment.