Skip to content

Commit

Permalink
chore(pre-commit.ci): pre-commit autoupdate (#409)
Browse files Browse the repository at this point in the history
* chore(pre-commit.ci): pre-commit autoupdate

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.8.0 → v0.8.3](astral-sh/ruff-pre-commit@v0.8.0...v0.8.3)
- [github.com/commitizen-tools/commitizen: v3.31.0 → v4.1.0](commitizen-tools/commitizen@v3.31.0...v4.1.0)
- [github.com/alessandrojcm/commitlint-pre-commit-hook: v9.18.0 → v9.20.0](alessandrojcm/commitlint-pre-commit-hook@v9.18.0...v9.20.0)

* chore(pre-commit.ci): auto fixes

* chore: allign

* chore: noqa

* chore: revert wrong change

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Simone Chemelli <[email protected]>
  • Loading branch information
pre-commit-ci[bot] and chemelli74 authored Dec 17, 2024
1 parent b0be2cb commit 902ed45
Show file tree
Hide file tree
Showing 15 changed files with 109 additions and 99 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ repos:
- id: check-yaml
- id: detect-private-key
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.0
rev: v0.8.3
hooks:
- id: ruff
args:
- --fix
- id: ruff-format
- repo: https://github.com/commitizen-tools/commitizen
rev: v3.31.0
rev: v4.1.0
hooks:
- id: commitizen
stages: [commit-msg]
- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
rev: v9.18.0
rev: v9.20.0
hooks:
- id: commitlint
stages: [commit-msg]
Expand Down
6 changes: 3 additions & 3 deletions custom_components/midea_ac_lan/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ async def update_listener(hass: HomeAssistant, config_entry: ConfigEntry) -> Non
hass.async_create_task(
hass.config_entries.async_forward_entry_setups(config_entry, ALL_PLATFORM),
)
device_id: int = cast(int, config_entry.data.get(CONF_DEVICE_ID))
device_id: int = cast("int", config_entry.data.get(CONF_DEVICE_ID))
customize = config_entry.options.get(CONF_CUSTOMIZE, "")
ip_address = config_entry.options.get(CONF_IP_ADDRESS, None)
refresh_interval = config_entry.options.get(CONF_REFRESH_INTERVAL, None)
Expand All @@ -88,7 +88,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: # noqa:
attributes = []
for device_entities in MIDEA_DEVICES.values():
for attribute_name, attribute in cast(
dict,
"dict",
device_entities["entities"],
).items():
if (
Expand All @@ -108,7 +108,7 @@ def service_set_attribute(service: Any) -> None: # noqa: ANN401
value = 102
item = None
if _dev := MIDEA_DEVICES.get(dev.device_type):
item = cast(dict, _dev["entities"]).get(attr)
item = cast("dict", _dev["entities"]).get(attr)
if (
item
and (item.get("type") in EXTRA_SWITCH)
Expand Down
6 changes: 3 additions & 3 deletions custom_components/midea_ac_lan/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ async def async_setup_entry(
extra_sensors = config_entry.options.get(CONF_SENSORS, [])
binary_sensors = []
for entity_key, config in cast(
dict,
"dict",
MIDEA_DEVICES[device.device_type]["entities"],
).items():
if config["type"] == Platform.BINARY_SENSOR and entity_key in extra_sensors:
Expand All @@ -42,9 +42,9 @@ class MideaBinarySensor(MideaEntity, BinarySensorEntity):
@property
def device_class(self) -> BinarySensorDeviceClass | None:
"""Return device class."""
return cast(BinarySensorDeviceClass, self._config.get("device_class"))
return cast("BinarySensorDeviceClass", self._config.get("device_class"))

@property
def is_on(self) -> bool:
"""Return true if sensor state is on."""
return cast(bool, self._device.get_attribute(self._entity_key))
return cast("bool", self._device.get_attribute(self._entity_key))
61 changes: 35 additions & 26 deletions custom_components/midea_ac_lan/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ async def async_setup_entry(
| MideaFBClimate
] = []
for entity_key, config in cast(
dict,
"dict",
MIDEA_DEVICES[device.device_type]["entities"],
).items():
if config["type"] == Platform.CLIMATE and (
Expand Down Expand Up @@ -142,19 +142,19 @@ def supported_features(self) -> ClimateEntityFeature:
def hvac_mode(self) -> HVACMode:
"""Midea Climate hvac mode."""
if self._device.get_attribute("power"):
mode = cast(int, self._device.get_attribute("mode"))
mode = cast("int", self._device.get_attribute("mode"))
return self.hvac_modes[mode]
return HVACMode.OFF

@property
def target_temperature(self) -> float:
"""Midea Climate target temperature."""
return cast(float, self._device.get_attribute("target_temperature"))
return cast("float", self._device.get_attribute("target_temperature"))

@property
def current_temperature(self) -> float | None:
"""Midea Climate current temperature."""
return cast(float | None, self._device.get_attribute("indoor_temperature"))
return cast("float | None", self._device.get_attribute("indoor_temperature"))

@property
def preset_mode(self) -> str:
Expand All @@ -176,7 +176,7 @@ def preset_mode(self) -> str:
@property
def extra_state_attributes(self) -> dict:
"""Midea Climate extra state attributes."""
return cast(dict, self._device.attributes)
return cast("dict", self._device.attributes)

def turn_on(self, **kwargs: Any) -> None: # noqa: ANN401, ARG002
"""Midea Climate turn on."""
Expand Down Expand Up @@ -290,7 +290,7 @@ def __init__(self, device: MideaACDevice, entity_key: str) -> None:
@property
def fan_mode(self) -> str:
"""Midea AC Climate fan mode."""
fan_speed = cast(int, self._device.get_attribute(ACAttributes.fan_speed))
fan_speed = cast("int", self._device.get_attribute(ACAttributes.fan_speed))
if fan_speed > FanSpeed.AUTO:
return str(FAN_AUTO)
if fan_speed > FanSpeed.FULL_SPEED:
Expand Down Expand Up @@ -321,12 +321,15 @@ def swing_mode(self) -> str:
@property
def current_humidity(self) -> float | None:
"""Midea Climate current humidity."""
return cast(float | None, self._device.get_attribute("indoor_humidity"))
return cast("float | None", self._device.get_attribute("indoor_humidity"))

@property
def outdoor_temperature(self) -> float:
"""Midea AC Climate outdoor temperature."""
return cast(float, self._device.get_attribute(ACAttributes.outdoor_temperature))
return cast(
"float",
self._device.get_attribute(ACAttributes.outdoor_temperature),
)

def set_fan_mode(self, fan_mode: str) -> None:
"""Midea AC Climate set fan mode."""
Expand Down Expand Up @@ -367,18 +370,18 @@ def __init__(self, device: MideaCCDevice, entity_key: str) -> None:
@property
def fan_modes(self) -> list[str] | None:
"""Midea CC Climate fan modes."""
return cast(list, self._device.fan_modes)
return cast("list", self._device.fan_modes)

@property
def fan_mode(self) -> str:
"""Midea CC Climate fan mode."""
return cast(str, self._device.get_attribute(CCAttributes.fan_speed))
return cast("str", self._device.get_attribute(CCAttributes.fan_speed))

@property
def target_temperature_step(self) -> float:
"""Midea CC Climate target temperature step."""
return cast(
float,
"float",
self._device.get_attribute(CCAttributes.temperature_precision),
)

Expand Down Expand Up @@ -429,27 +432,30 @@ def supported_features(self) -> ClimateEntityFeature:
@property
def min_temp(self) -> float:
"""Midea CF Climate min temperature."""
return cast(float, self._device.get_attribute(CFAttributes.min_temperature))
return cast("float", self._device.get_attribute(CFAttributes.min_temperature))

@property
def max_temp(self) -> float:
"""Midea CF Climate max temperature."""
return cast(float, self._device.get_attribute(CFAttributes.max_temperature))
return cast("float", self._device.get_attribute(CFAttributes.max_temperature))

@property
def target_temperature_low(self) -> float:
"""Midea CF Climate target temperature."""
return cast(float, self._device.get_attribute(CFAttributes.min_temperature))
return cast("float", self._device.get_attribute(CFAttributes.min_temperature))

@property
def target_temperature_high(self) -> float:
"""Midea CF Climate target temperature high."""
return cast(float, self._device.get_attribute(CFAttributes.max_temperature))
return cast("float", self._device.get_attribute(CFAttributes.max_temperature))

@property
def current_temperature(self) -> float:
"""Midea CF Climate current temperature."""
return cast(float, self._device.get_attribute(CFAttributes.current_temperature))
return cast(
"float",
self._device.get_attribute(CFAttributes.current_temperature),
)


class MideaC3Climate(MideaClimate):
Expand Down Expand Up @@ -487,7 +493,7 @@ def _temperature(self, minimum: bool) -> list[str]:
if minimum
else C3Attributes.temperature_max)
# fmt: on
return cast(list[str], self._device.get_attribute(value))
return cast("list[str]", self._device.get_attribute(value))

@property
def supported_features(self) -> ClimateEntityFeature:
Expand All @@ -501,7 +507,7 @@ def supported_features(self) -> ClimateEntityFeature:
def target_temperature_step(self) -> float:
"""Midea C3 Climate target temperature step."""
zone_temp_type = cast(
list[str],
"list[str]",
self._device.get_attribute(C3Attributes.zone_temp_type),
)
return float(
Expand All @@ -512,31 +518,31 @@ def target_temperature_step(self) -> float:
def min_temp(self) -> float:
"""Midea C3 Climate min temperature."""
return cast(
float,
"float",
self._temperature(True)[self._zone],
)

@property
def max_temp(self) -> float:
"""Midea C3 Climate max temperature."""
return cast(
float,
"float",
self._temperature(False)[self._zone],
)

@property
def target_temperature_low(self) -> float:
"""Midea C3 Climate target temperature low."""
return cast(
float,
"float",
self._temperature(True)[self._zone],
)

@property
def target_temperature_high(self) -> float:
"""Midea C3 Climate target temperature high."""
return cast(
float,
"float",
self._temperature(False)[self._zone],
)

Expand All @@ -560,11 +566,11 @@ def hvac_mode(self) -> HVACMode:
def target_temperature(self) -> float:
"""Midea C3 Climate target temperature."""
target_temperature = cast(
list[str],
"list[str]",
self._device.get_attribute(C3Attributes.target_temperature),
)
return cast(
float,
"float",
target_temperature[self._zone],
)

Expand Down Expand Up @@ -630,7 +636,7 @@ def supported_features(self) -> ClimateEntityFeature:
@property
def preset_mode(self) -> str:
"""Midea FB Climate preset mode."""
return cast(str, self._device.get_attribute(attr=FBAttributes.mode))
return cast("str", self._device.get_attribute(attr=FBAttributes.mode))

@property
def hvac_mode(self) -> HVACMode:
Expand All @@ -644,7 +650,10 @@ def hvac_mode(self) -> HVACMode:
@property
def current_temperature(self) -> float:
"""Midea FB Climate current temperature."""
return cast(float, self._device.get_attribute(FBAttributes.current_temperature))
return cast(
"float",
self._device.get_attribute(FBAttributes.current_temperature),
)

def set_temperature(self, **kwargs: Any) -> None: # noqa: ANN401
"""Midea FB Climate set temperature."""
Expand Down
4 changes: 2 additions & 2 deletions custom_components/midea_ac_lan/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -934,8 +934,8 @@ async def async_step_init(
sensors = {}
switches = {}
for attribute, attribute_config in cast(
dict,
MIDEA_DEVICES[cast(int, self._device_type)]["entities"],
"dict",
MIDEA_DEVICES[cast("int", self._device_type)]["entities"],
).items():
attribute_name = (
attribute if isinstance(attribute, str) else attribute.value
Expand Down
22 changes: 11 additions & 11 deletions custom_components/midea_ac_lan/fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ async def async_setup_entry(
MideaFAFan | MideaB6Fan | MideaACFreshAirFan | MideaCEFan | MideaX40Fan
] = []
for entity_key, config in cast(
dict,
"dict",
MIDEA_DEVICES[device.device_type]["entities"],
).items():
if config["type"] == Platform.FAN and (
Expand Down Expand Up @@ -83,22 +83,22 @@ def preset_modes(self) -> list[str] | None:
@property
def is_on(self) -> bool:
"""Midea Fan is on."""
return cast(bool, self._device.get_attribute("power"))
return cast("bool", self._device.get_attribute("power"))

@property
def oscillating(self) -> bool:
"""Midea Fan oscillating."""
return cast(bool, self._device.get_attribute("oscillate"))
return cast("bool", self._device.get_attribute("oscillate"))

@property
def preset_mode(self) -> str | None:
"""Midea Fan preset mode."""
return cast(str, self._device.get_attribute("mode"))
return cast("str", self._device.get_attribute("mode"))

@property
def fan_speed(self) -> int | None:
"""Midea Fan fan speed."""
return cast(int, self._device.get_attribute("fan_speed"))
return cast("int", self._device.get_attribute("fan_speed"))

def turn_off(self, **kwargs: Any) -> None: # noqa: ANN401, ARG002
"""Midea Fan turn off."""
Expand All @@ -117,7 +117,7 @@ def percentage(self) -> int | None:
"""Midea Fan percentage."""
if not self.fan_speed:
return None
return int(round(self.fan_speed * self.percentage_step))
return int(round(self.fan_speed * self.percentage_step)) # noqa: RUF046

def set_percentage(self, percentage: int) -> None:
"""Midea Fan set percentage."""
Expand Down Expand Up @@ -209,17 +209,17 @@ def __init__(self, device: MideaACDevice, entity_key: str) -> None:
@property
def preset_modes(self) -> list[str] | None:
"""Midea AC Fan preset modes."""
return cast(list, self._device.fresh_air_fan_speeds)
return cast("list", self._device.fresh_air_fan_speeds)

@property
def is_on(self) -> bool:
"""Midea AC Fan is on."""
return cast(bool, self._device.get_attribute(ACAttributes.fresh_air_power))
return cast("bool", self._device.get_attribute(ACAttributes.fresh_air_power))

@property
def fan_speed(self) -> int:
"""Midea AC Fan fan speed."""
return cast(int, self._device.get_attribute(ACAttributes.fresh_air_fan_speed))
return cast("int", self._device.get_attribute(ACAttributes.fresh_air_fan_speed))

def turn_on(
self,
Expand Down Expand Up @@ -249,7 +249,7 @@ def set_preset_mode(self, preset_mode: str) -> None:
@property
def preset_mode(self) -> str | None:
"""Midea AC Fan preset mode."""
return cast(str, self._device.get_attribute(attr=ACAttributes.fresh_air_mode))
return cast("str", self._device.get_attribute(attr=ACAttributes.fresh_air_mode))


class MideaCEFan(MideaFan):
Expand Down Expand Up @@ -299,7 +299,7 @@ def __init__(self, device: MideaX40Device, entity_key: str) -> None:
@property
def is_on(self) -> bool:
"""Midea X40 Fan is on."""
return cast(int, self._device.get_attribute(attr=X40Attributes.fan_speed)) > 0
return cast("int", self._device.get_attribute(attr=X40Attributes.fan_speed)) > 0

def turn_on(
self,
Expand Down
Loading

0 comments on commit 902ed45

Please sign in to comment.