8000 Update pre-commit hooks by syssi · Pull Request #267 · syssi/xiaomi_fan · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Update pre-commit hooks #267

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
2 changes: 1 addition & 1 deletion .hound.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
python:
enabled: true
config_file: .flake8.ini
config_file: .flake8
18 changes: 13 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
repos:
- repo: https://github.com/ambv/black
rev: stable
hooks:
- id: black
language_version: python3
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.5
hooks:
- id: ruff
args:
- --fix
- id: ruff-format

- repo: https://github.com/pycqa/flake8
rev: 7.0.0
hooks:
- id: flake8
additional_dependencies: [flake8-docstrings, flake8-bugbear, flake8-builtins, flake8-print, flake8-pytest-style, flake8-return, flake8-simplify, flake8-annotations]
43 changes: 20 additions & 23 deletions custom_components/xiaomi_miio_fan/fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
For more details about this platform, please refer to the documentation
https://home-assistant.io/components/fan.xiaomi_miio/
"""

import asyncio
import logging
from enum import Enum
Expand All @@ -12,12 +13,7 @@

import homeassistant.helpers.config_validation as cv
import voluptuous as vol
from homeassistant.components.fan import (
PLATFORM_SCHEMA,
FanEntity,
FanEntityFeature,
)

from homeassistant.components.fan import PLATFORM_SCHEMA, FanEntity, FanEntityFeature
from homeassistant.const import (
ATTR_ENTITY_ID,
ATTR_MODE,
Expand All @@ -30,19 +26,9 @@
ordered_list_item_to_percentage,
percentage_to_ordered_list_item,
)
from miio import (
Device,
DeviceException,
Fan,
Fan1C,
FanLeshow,
FanMiot,
FanP5,
)
from miio import Device, DeviceException, Fan, Fan1C, FanLeshow, FanMiot, FanP5
from miio.fan_common import FanException
from miio.fan_common import (
LedBrightness as FanLedBrightness,
)
from miio.fan_common import LedBrightness as FanLedBrightness
from miio.fan_common import MoveDirection as FanMoveDirection
from miio.fan_common import OperationMode as FanOperationMode
from miio.integrations.fan.leshow.fan_leshow import (
Expand Down Expand Up @@ -429,6 +415,7 @@ def _filter_request_fields(req):
"""Return only the parts that belong to the request.."""
return {k: v for k, v in req.items() if k in ["did", "siid", "piid"]}


# pylint: disable=unused-argument
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the miio fan device from config."""
Expand Down Expand Up @@ -637,7 +624,9 @@ async def _try_command(self, mask_error, func, *args, **kwargs):
self._available = False
return False

async def async_turn_on(self, speed: str = None, mode: str = None, **kwargs) -> None:
async def async_turn_on(
self, speed: str = None, mode: str = None, **kwargs
) -> None:
"""Turn the device on."""
result = await self._try_command(
"Turning the miio device on failed.", self._device.on
Expand Down Expand Up @@ -725,6 +714,7 @@ def __init__(self, name, device, model, unique_id, retries, preset_modes_overrid
self._state_attrs.update(
{attribute: None for attribute in self._available_attributes}
)

@property
def supported_features(self) -> int:
"""Supported features."""
Expand Down Expand Up @@ -1101,7 +1091,11 @@ def __init__(self, name, device, model, unique_id, retries, preset_modes_overrid
@property
def supported_features(self) -> int:
"""Supported features."""
return FanEntityFeature.SET_SPEED | FanEntityFeature.PRESET_MODE | FanEntityFeature.OSCILLATE
return (
FanEntityFeature.SET_SPEED
| FanEntityFeature.PRESET_MODE
| FanEntityFeature.OSCILLATE
)

async def async_update(self):
"""Fetch state from the device."""
Expand Down Expand Up @@ -1239,7 +1233,11 @@ def __init__(self, name, device, model, unique_id, retries, preset_modes_overrid
@property
def supported_features(self) -> int:
"""Supported features."""
return FanEntityFeature.SET_SPEED | FanEntityFeature.PRESET_MODE | FanEntityFeature.OSCILLATE
return (
FanEntityFeature.SET_SPEED
| FanEntityFeature.PRESET_MODE
| FanEntityFeature.OSCILLATE
)

async def async_update(self):
"""Fetch state from the device."""
Expand Down Expand Up @@ -2336,8 +2334,7 @@ def get_properties_for_mapping(self, *, max_properties=15) -> list:
properties = [
{"did": k, **_filter_request_fields(v)}
for k, v in mapping.items()
if "aiid" not in v
and ("access" not in v or "read" in v["access"])
if "aiid" not in v and ("access" not in v or "read" in v["access"])
]

return self.get_properties(
Expand Down
Loading
0