Skip to content

Commit

Permalink
Update Ruff to 0.1.8, avoid linter/formatter conflicts (#106080)
Browse files Browse the repository at this point in the history
* Disable Ruff rules that may conflict with the formatter

* Upgrade Ruff to 0.1.8

- https://github.com/astral-sh/ruff/releases/tag/v0.1.7
- https://github.com/astral-sh/ruff/releases/tag/v0.1.8

* Format with Ruff 0.1.8
  • Loading branch information
scop committed Dec 20, 2023
1 parent f5f9b89 commit 24b1e01
Show file tree
Hide file tree
Showing 91 changed files with 188 additions and 173 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.6
rev: v0.1.8
hooks:
- id: ruff
args:
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/androidtv/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def adb_decorator(
"""

def _adb_decorator(
func: _FuncType[_ADBDeviceT, _P, _R]
func: _FuncType[_ADBDeviceT, _P, _R],
) -> _ReturnFuncType[_ADBDeviceT, _P, _R]:
"""Wrap the provided ADB method and catch exceptions."""

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/braviatv/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@


def catch_braviatv_errors(
func: Callable[Concatenate[_BraviaTVCoordinatorT, _P], Awaitable[None]]
func: Callable[Concatenate[_BraviaTVCoordinatorT, _P], Awaitable[None]],
) -> Callable[Concatenate[_BraviaTVCoordinatorT, _P], Coroutine[Any, Any, None]]:
"""Catch Bravia errors."""

Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/calendar/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ def _api_event_dict_factory(obj: Iterable[tuple[str, Any]]) -> dict[str, Any]:


def _list_events_dict_factory(
obj: Iterable[tuple[str, Any]]
obj: Iterable[tuple[str, Any]],
) -> dict[str, JsonValueType]:
"""Convert CalendarEvent dataclass items to dictionary of attributes."""
return {
Expand Down Expand Up @@ -818,7 +818,7 @@ async def handle_calendar_event_update(


def _validate_timespan(
values: dict[str, Any]
values: dict[str, Any],
) -> tuple[datetime.datetime | datetime.date, datetime.datetime | datetime.date]:
"""Parse a create event service call and convert the args ofr a create event entity call.
Expand Down
4 changes: 3 additions & 1 deletion homeassistant/components/cloud/http_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ async def async_setup(hass: HomeAssistant) -> None:


def _handle_cloud_errors(
handler: Callable[Concatenate[_HassViewT, web.Request, _P], Awaitable[web.Response]]
handler: Callable[
Concatenate[_HassViewT, web.Request, _P], Awaitable[web.Response]
],
) -> Callable[
Concatenate[_HassViewT, web.Request, _P], Coroutine[Any, Any, web.Response]
]:
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/decora/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def _name_validator(config):


def retry(
method: Callable[Concatenate[_DecoraLightT, _P], _R]
method: Callable[Concatenate[_DecoraLightT, _P], _R],
) -> Callable[Concatenate[_DecoraLightT, _P], _R | None]:
"""Retry bluetooth commands."""

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/device_automation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ def async_validate_entity_schema(


def handle_device_errors(
func: Callable[[HomeAssistant, ActiveConnection, dict[str, Any]], Awaitable[None]]
func: Callable[[HomeAssistant, ActiveConnection, dict[str, Any]], Awaitable[None]],
) -> Callable[
[HomeAssistant, ActiveConnection, dict[str, Any]], Coroutine[Any, Any, None]
]:
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/dhcp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ def _handle_dhcp_packet(packet: Packet) -> None:


def _dhcp_options_as_dict(
dhcp_options: Iterable[tuple[str, int | bytes | None]]
dhcp_options: Iterable[tuple[str, int | bytes | None]],
) -> dict[str, str | int | bytes | None]:
"""Extract data from packet options as a dict."""
return {option[0]: option[1] for option in dhcp_options if len(option) >= 2}
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/dlna_dmr/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@


def catch_request_errors(
func: Callable[Concatenate[_DlnaDmrEntityT, _P], Awaitable[_R]]
func: Callable[Concatenate[_DlnaDmrEntityT, _P], Awaitable[_R]],
) -> Callable[Concatenate[_DlnaDmrEntityT, _P], Coroutine[Any, Any, _R | None]]:
"""Catch UpnpError errors."""

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/dlna_dms/dms.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class ActionError(DlnaDmsDeviceError):


def catch_request_errors(
func: Callable[[_DlnaDmsDeviceMethod, str], Coroutine[Any, Any, _R]]
func: Callable[[_DlnaDmsDeviceMethod, str], Coroutine[Any, Any, _R]],
) -> Callable[[_DlnaDmsDeviceMethod, str], Coroutine[Any, Any, _R]]:
"""Catch UpnpError errors."""

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/duotecno/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ async def _on_update(self) -> None:


def api_call(
func: Callable[Concatenate[_T, _P], Awaitable[None]]
func: Callable[Concatenate[_T, _P], Awaitable[None]],
) -> Callable[Concatenate[_T, _P], Coroutine[Any, Any, None]]:
"""Catch command exceptions."""

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/dynalite/convert_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def convert_template(config: dict[str, Any]) -> dict[str, Any]:


def convert_config(
config: dict[str, Any] | MappingProxyType[str, Any]
config: dict[str, Any] | MappingProxyType[str, Any],
) -> dict[str, Any]:
"""Convert a config dict by replacing component consts with library consts."""
my_map = {
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/esphome/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def async_list_entities(infos: list[EntityInfo]) -> None:


def esphome_state_property(
func: Callable[[_EntityT], _R]
func: Callable[[_EntityT], _R],
) -> Callable[[_EntityT], _R | None]:
"""Wrap a state property of an esphome entity.
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/evil_genius_labs/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@


def update_when_done(
func: Callable[Concatenate[_EvilGeniusEntityT, _P], Awaitable[_R]]
func: Callable[Concatenate[_EvilGeniusEntityT, _P], Awaitable[_R]],
) -> Callable[Concatenate[_EvilGeniusEntityT, _P], Coroutine[Any, Any, _R]]:
"""Decorate function to trigger update when function is done."""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ async def async_step_init(


def google_generative_ai_config_option_schema(
options: MappingProxyType[str, Any]
options: MappingProxyType[str, Any],
) -> dict:
"""Return a schema for Google Generative AI completion options."""
if not options:
Expand Down
16 changes: 8 additions & 8 deletions homeassistant/components/group/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def async_create_preview_sensor(


def calc_min(
sensor_values: list[tuple[str, float, State]]
sensor_values: list[tuple[str, float, State]],
) -> tuple[dict[str, str | None], float | None]:
"""Calculate min value."""
val: float | None = None
Expand All @@ -170,7 +170,7 @@ def calc_min(


def calc_max(
sensor_values: list[tuple[str, float, State]]
sensor_values: list[tuple[str, float, State]],
) -> tuple[dict[str, str | None], float | None]:
"""Calculate max value."""
val: float | None = None
Expand All @@ -186,7 +186,7 @@ def calc_max(


def calc_mean(
sensor_values: list[tuple[str, float, State]]
sensor_values: list[tuple[str, float, State]],
) -> tuple[dict[str, str | None], float | None]:
"""Calculate mean value."""
result = (sensor_value for _, sensor_value, _ in sensor_values)
Expand All @@ -196,7 +196,7 @@ def calc_mean(


def calc_median(
sensor_values: list[tuple[str, float, State]]
sensor_values: list[tuple[str, float, State]],
) -> tuple[dict[str, str | None], float | None]:
"""Calculate median value."""
result = (sensor_value for _, sensor_value, _ in sensor_values)
Expand All @@ -206,7 +206,7 @@ def calc_median(


def calc_last(
sensor_values: list[tuple[str, float, State]]
sensor_values: list[tuple[str, float, State]],
) -> tuple[dict[str, str | None], float | None]:
"""Calculate last value."""
last_updated: datetime | None = None
Expand All @@ -223,7 +223,7 @@ def calc_last(


def calc_range(
sensor_values: list[tuple[str, float, State]]
sensor_values: list[tuple[str, float, State]],
) -> tuple[dict[str, str | None], float]:
"""Calculate range value."""
max_result = max((sensor_value for _, sensor_value, _ in sensor_values))
Expand All @@ -234,7 +234,7 @@ def calc_range(


def calc_sum(
sensor_values: list[tuple[str, float, State]]
sensor_values: list[tuple[str, float, State]],
) -> tuple[dict[str, str | None], float]:
"""Calculate a sum of values."""
result = 0.0
Expand All @@ -245,7 +245,7 @@ def calc_sum(


def calc_product(
sensor_values: list[tuple[str, float, State]]
sensor_values: list[tuple[str, float, State]],
) -> tuple[dict[str, str | None], float]:
"""Calculate a product of values."""
result = 1.0
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/guardian/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ async def async_init_coordinator(

@callback
def call_with_data(
func: Callable[[ServiceCall, GuardianData], Coroutine[Any, Any, None]]
func: Callable[[ServiceCall, GuardianData], Coroutine[Any, Any, None]],
) -> Callable[[ServiceCall], Coroutine[Any, Any, None]]:
"""Hydrate a service call with the appropriate GuardianData object."""

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/hassio/addon_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def api_error(
"""Handle HassioAPIError and raise a specific AddonError."""

def handle_hassio_api_error(
func: _FuncType[_AddonManagerT, _P, _R]
func: _FuncType[_AddonManagerT, _P, _R],
) -> _ReturnFuncType[_AddonManagerT, _P, _R]:
"""Handle a HassioAPIError."""

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/hive/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ async def async_remove_config_entry_device(


def refresh_system(
func: Callable[Concatenate[_HiveEntityT, _P], Awaitable[Any]]
func: Callable[Concatenate[_HiveEntityT, _P], Awaitable[Any]],
) -> Callable[Concatenate[_HiveEntityT, _P], Coroutine[Any, Any, None]]:
"""Force update all entities after state change."""

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/homekit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@


def _has_all_unique_names_and_ports(
bridges: list[dict[str, Any]]
bridges: list[dict[str, Any]],
) -> list[dict[str, Any]]:
"""Validate that each homekit bridge configured has a unique name."""
names = [bridge[CONF_NAME] for bridge in bridges]
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/homewizard/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@


def homewizard_exception_handler(
func: Callable[Concatenate[_HomeWizardEntityT, _P], Coroutine[Any, Any, Any]]
func: Callable[Concatenate[_HomeWizardEntityT, _P], Coroutine[Any, Any, Any]],
) -> Callable[Concatenate[_HomeWizardEntityT, _P], Coroutine[Any, Any, None]]:
"""Decorate HomeWizard Energy calls to handle HomeWizardEnergy exceptions.
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/http/ban.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ async def ban_middleware(


def log_invalid_auth(
func: Callable[Concatenate[_HassViewT, Request, _P], Awaitable[Response]]
func: Callable[Concatenate[_HassViewT, Request, _P], Awaitable[Response]],
) -> Callable[Concatenate[_HassViewT, Request, _P], Coroutine[Any, Any, Response]]:
"""Decorate function to handle invalid auth or failed login attempts."""

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/http/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def require_admin(
"""Home Assistant API decorator to require user to be an admin."""

def decorator_require_admin(
func: _FuncType[_HomeAssistantViewT, _P]
func: _FuncType[_HomeAssistantViewT, _P],
) -> _FuncType[_HomeAssistantViewT, _P]:
"""Wrap the provided with_admin function."""

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/iaqualink/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:


def refresh_system(
func: Callable[Concatenate[_AqualinkEntityT, _P], Awaitable[Any]]
func: Callable[Concatenate[_AqualinkEntityT, _P], Awaitable[Any]],
) -> Callable[Concatenate[_AqualinkEntityT, _P], Coroutine[Any, Any, None]]:
"""Force update all entities after state change."""

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/iqvia/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
client.disable_request_retries()

async def async_get_data_from_api(
api_coro: Callable[..., Coroutine[Any, Any, dict[str, Any]]]
api_coro: Callable[..., Coroutine[Any, Any, dict[str, Any]]],
) -> dict[str, Any]:
"""Get data from a particular API coroutine."""
try:
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/kodi/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ async def async_setup_entry(


def cmd(
func: Callable[Concatenate[_KodiEntityT, _P], Awaitable[Any]]
func: Callable[Concatenate[_KodiEntityT, _P], Awaitable[Any]],
) -> Callable[Concatenate[_KodiEntityT, _P], Coroutine[Any, Any, None]]:
"""Catch command exceptions."""

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/lametric/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@


def lametric_exception_handler(
func: Callable[Concatenate[_LaMetricEntityT, _P], Coroutine[Any, Any, Any]]
func: Callable[Concatenate[_LaMetricEntityT, _P], Coroutine[Any, Any, Any]],
) -> Callable[Concatenate[_LaMetricEntityT, _P], Coroutine[Any, Any, None]]:
"""Decorate LaMetric calls to handle LaMetric exceptions.
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/lutron_caseta/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ def _async_setup_keypads(

@callback
def _async_build_trigger_schemas(
keypad_button_names_to_leap: dict[int, dict[str, int]]
keypad_button_names_to_leap: dict[int, dict[str, int]],
) -> dict[int, vol.Schema]:
"""Build device trigger schemas."""

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/motioneye/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def get_motioneye_device_identifier(


def split_motioneye_device_identifier(
identifier: tuple[str, str]
identifier: tuple[str, str],
) -> tuple[str, str, int] | None:
"""Get the identifiers for a motionEye device."""
if len(identifier) != 2 or identifier[0] != DOMAIN or "_" not in identifier[1]:
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/mqtt/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -1135,7 +1135,7 @@ def _cleanup_discovery_on_remove(self) -> None:


def device_info_from_specifications(
specifications: dict[str, Any] | None
specifications: dict[str, Any] | None,
) -> DeviceInfo | None:
"""Return a device description for device registry."""
if not specifications:
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/nina/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ async def _async_update_data(self) -> dict[str, list[NinaWarningData]]:

@staticmethod
def _remove_duplicate_warnings(
warnings: dict[str, list[Any]]
warnings: dict[str, list[Any]],
) -> dict[str, list[Any]]:
"""Remove warnings with the same title and expires timestamp in a region."""
all_filtered_warnings: dict[str, list[Any]] = {}
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/openhome/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def catch_request_errors() -> (
"""Catch asyncio.TimeoutError, aiohttp.ClientError, UpnpError errors."""

def call_wrapper(
func: _FuncType[_OpenhomeDeviceT, _P, _R]
func: _FuncType[_OpenhomeDeviceT, _P, _R],
) -> _ReturnFuncType[_OpenhomeDeviceT, _P, _R]:
"""Call wrapper for decorator."""

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/otbr/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@


def _handle_otbr_error(
func: Callable[Concatenate[OTBRData, _P], Coroutine[Any, Any, _R]]
func: Callable[Concatenate[OTBRData, _P], Coroutine[Any, Any, _R]],
) -> Callable[Concatenate[OTBRData, _P], Coroutine[Any, Any, _R]]:
"""Handle OTBR errors."""

Expand Down
6 changes: 3 additions & 3 deletions homeassistant/components/overkiz/alarm_control_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def _state_tsk_alarm_controller(select_state: Callable[[str], OverkizStateType])


def _state_stateful_alarm_controller(
select_state: Callable[[str], OverkizStateType]
select_state: Callable[[str], OverkizStateType],
) -> str:
"""Return the state of the device."""
if state := cast(str, select_state(OverkizState.CORE_ACTIVE_ZONES)):
Expand All @@ -118,7 +118,7 @@ def _state_stateful_alarm_controller(


def _state_myfox_alarm_controller(
select_state: Callable[[str], OverkizStateType]
select_state: Callable[[str], OverkizStateType],
) -> str:
"""Return the state of the device."""
if (
Expand All @@ -141,7 +141,7 @@ def _state_myfox_alarm_controller(


def _state_alarm_panel_controller(
select_state: Callable[[str], OverkizStateType]
select_state: Callable[[str], OverkizStateType],
) -> str:
"""Return the state of the device."""
return MAP_ARM_TYPE[
Expand Down

0 comments on commit 24b1e01

Please sign in to comment.