Skip to content

Commit 24b1e01

Browse files
authored
Update Ruff to 0.1.8, avoid linter/formatter conflicts (home-assistant#106080)
* 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
1 parent f5f9b89 commit 24b1e01

File tree

91 files changed

+188
-173
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+188
-173
lines changed

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/astral-sh/ruff-pre-commit
3-
rev: v0.1.6
3+
rev: v0.1.8
44
hooks:
55
- id: ruff
66
args:

homeassistant/components/androidtv/media_player.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def adb_decorator(
160160
"""
161161

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

homeassistant/components/braviatv/coordinator.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343

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

homeassistant/components/calendar/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ def _api_event_dict_factory(obj: Iterable[tuple[str, Any]]) -> dict[str, Any]:
429429

430430

431431
def _list_events_dict_factory(
432-
obj: Iterable[tuple[str, Any]]
432+
obj: Iterable[tuple[str, Any]],
433433
) -> dict[str, JsonValueType]:
434434
"""Convert CalendarEvent dataclass items to dictionary of attributes."""
435435
return {
@@ -818,7 +818,7 @@ async def handle_calendar_event_update(
818818

819819

820820
def _validate_timespan(
821-
values: dict[str, Any]
821+
values: dict[str, Any],
822822
) -> tuple[datetime.datetime | datetime.date, datetime.datetime | datetime.date]:
823823
"""Parse a create event service call and convert the args ofr a create event entity call.
824824

homeassistant/components/cloud/http_api.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,9 @@ async def async_setup(hass: HomeAssistant) -> None:
116116

117117

118118
def _handle_cloud_errors(
119-
handler: Callable[Concatenate[_HassViewT, web.Request, _P], Awaitable[web.Response]]
119+
handler: Callable[
120+
Concatenate[_HassViewT, web.Request, _P], Awaitable[web.Response]
121+
],
120122
) -> Callable[
121123
Concatenate[_HassViewT, web.Request, _P], Coroutine[Any, Any, web.Response]
122124
]:

homeassistant/components/decora/light.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def _name_validator(config):
6060

6161

6262
def retry(
63-
method: Callable[Concatenate[_DecoraLightT, _P], _R]
63+
method: Callable[Concatenate[_DecoraLightT, _P], _R],
6464
) -> Callable[Concatenate[_DecoraLightT, _P], _R | None]:
6565
"""Retry bluetooth commands."""
6666

homeassistant/components/device_automation/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ def async_validate_entity_schema(
358358

359359

360360
def handle_device_errors(
361-
func: Callable[[HomeAssistant, ActiveConnection, dict[str, Any]], Awaitable[None]]
361+
func: Callable[[HomeAssistant, ActiveConnection, dict[str, Any]], Awaitable[None]],
362362
) -> Callable[
363363
[HomeAssistant, ActiveConnection, dict[str, Any]], Coroutine[Any, Any, None]
364364
]:

homeassistant/components/dhcp/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ def _handle_dhcp_packet(packet: Packet) -> None:
489489

490490

491491
def _dhcp_options_as_dict(
492-
dhcp_options: Iterable[tuple[str, int | bytes | None]]
492+
dhcp_options: Iterable[tuple[str, int | bytes | None]],
493493
) -> dict[str, str | int | bytes | None]:
494494
"""Extract data from packet options as a dict."""
495495
return {option[0]: option[1] for option in dhcp_options if len(option) >= 2}

homeassistant/components/dlna_dmr/media_player.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555

5656

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

homeassistant/components/dlna_dms/dms.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ class ActionError(DlnaDmsDeviceError):
124124

125125

126126
def catch_request_errors(
127-
func: Callable[[_DlnaDmsDeviceMethod, str], Coroutine[Any, Any, _R]]
127+
func: Callable[[_DlnaDmsDeviceMethod, str], Coroutine[Any, Any, _R]],
128128
) -> Callable[[_DlnaDmsDeviceMethod, str], Coroutine[Any, Any, _R]]:
129129
"""Catch UpnpError errors."""
130130

homeassistant/components/duotecno/entity.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ async def _on_update(self) -> None:
4747

4848

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

homeassistant/components/dynalite/convert_config.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def convert_template(config: dict[str, Any]) -> dict[str, Any]:
138138

139139

140140
def convert_config(
141-
config: dict[str, Any] | MappingProxyType[str, Any]
141+
config: dict[str, Any] | MappingProxyType[str, Any],
142142
) -> dict[str, Any]:
143143
"""Convert a config dict by replacing component consts with library consts."""
144144
my_map = {

homeassistant/components/esphome/entity.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def async_list_entities(infos: list[EntityInfo]) -> None:
9292

9393

9494
def esphome_state_property(
95-
func: Callable[[_EntityT], _R]
95+
func: Callable[[_EntityT], _R],
9696
) -> Callable[[_EntityT], _R | None]:
9797
"""Wrap a state property of an esphome entity.
9898

homeassistant/components/evil_genius_labs/util.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414

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

homeassistant/components/google_generative_ai_conversation/config_flow.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ async def async_step_init(
129129

130130

131131
def google_generative_ai_config_option_schema(
132-
options: MappingProxyType[str, Any]
132+
options: MappingProxyType[str, Any],
133133
) -> dict:
134134
"""Return a schema for Google Generative AI completion options."""
135135
if not options:

homeassistant/components/group/sensor.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def async_create_preview_sensor(
154154

155155

156156
def calc_min(
157-
sensor_values: list[tuple[str, float, State]]
157+
sensor_values: list[tuple[str, float, State]],
158158
) -> tuple[dict[str, str | None], float | None]:
159159
"""Calculate min value."""
160160
val: float | None = None
@@ -170,7 +170,7 @@ def calc_min(
170170

171171

172172
def calc_max(
173-
sensor_values: list[tuple[str, float, State]]
173+
sensor_values: list[tuple[str, float, State]],
174174
) -> tuple[dict[str, str | None], float | None]:
175175
"""Calculate max value."""
176176
val: float | None = None
@@ -186,7 +186,7 @@ def calc_max(
186186

187187

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

197197

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

207207

208208
def calc_last(
209-
sensor_values: list[tuple[str, float, State]]
209+
sensor_values: list[tuple[str, float, State]],
210210
) -> tuple[dict[str, str | None], float | None]:
211211
"""Calculate last value."""
212212
last_updated: datetime | None = None
@@ -223,7 +223,7 @@ def calc_last(
223223

224224

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

235235

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

246246

247247
def calc_product(
248-
sensor_values: list[tuple[str, float, State]]
248+
sensor_values: list[tuple[str, float, State]],
249249
) -> tuple[dict[str, str | None], float]:
250250
"""Calculate a product of values."""
251251
result = 1.0

homeassistant/components/guardian/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ async def async_init_coordinator(
171171

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

homeassistant/components/hassio/addon_manager.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def api_error(
4343
"""Handle HassioAPIError and raise a specific AddonError."""
4444

4545
def handle_hassio_api_error(
46-
func: _FuncType[_AddonManagerT, _P, _R]
46+
func: _FuncType[_AddonManagerT, _P, _R],
4747
) -> _ReturnFuncType[_AddonManagerT, _P, _R]:
4848
"""Handle a HassioAPIError."""
4949

homeassistant/components/hive/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ async def async_remove_config_entry_device(
131131

132132

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

homeassistant/components/homekit/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@
152152

153153

154154
def _has_all_unique_names_and_ports(
155-
bridges: list[dict[str, Any]]
155+
bridges: list[dict[str, Any]],
156156
) -> list[dict[str, Any]]:
157157
"""Validate that each homekit bridge configured has a unique name."""
158158
names = [bridge[CONF_NAME] for bridge in bridges]

homeassistant/components/homewizard/helpers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717

1818
def homewizard_exception_handler(
19-
func: Callable[Concatenate[_HomeWizardEntityT, _P], Coroutine[Any, Any, Any]]
19+
func: Callable[Concatenate[_HomeWizardEntityT, _P], Coroutine[Any, Any, Any]],
2020
) -> Callable[Concatenate[_HomeWizardEntityT, _P], Coroutine[Any, Any, None]]:
2121
"""Decorate HomeWizard Energy calls to handle HomeWizardEnergy exceptions.
2222

homeassistant/components/http/ban.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ async def ban_middleware(
8484

8585

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

homeassistant/components/http/decorators.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def require_admin(
4545
"""Home Assistant API decorator to require user to be an admin."""
4646

4747
def decorator_require_admin(
48-
func: _FuncType[_HomeAssistantViewT, _P]
48+
func: _FuncType[_HomeAssistantViewT, _P],
4949
) -> _FuncType[_HomeAssistantViewT, _P]:
5050
"""Wrap the provided with_admin function."""
5151

homeassistant/components/iaqualink/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
185185

186186

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

homeassistant/components/iqvia/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
5757
client.disable_request_retries()
5858

5959
async def async_get_data_from_api(
60-
api_coro: Callable[..., Coroutine[Any, Any, dict[str, Any]]]
60+
api_coro: Callable[..., Coroutine[Any, Any, dict[str, Any]]],
6161
) -> dict[str, Any]:
6262
"""Get data from a particular API coroutine."""
6363
try:

homeassistant/components/kodi/media_player.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ async def async_setup_entry(
231231

232232

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

homeassistant/components/lametric/helpers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020

2121
def lametric_exception_handler(
22-
func: Callable[Concatenate[_LaMetricEntityT, _P], Coroutine[Any, Any, Any]]
22+
func: Callable[Concatenate[_LaMetricEntityT, _P], Coroutine[Any, Any, Any]],
2323
) -> Callable[Concatenate[_LaMetricEntityT, _P], Coroutine[Any, Any, None]]:
2424
"""Decorate LaMetric calls to handle LaMetric exceptions.
2525

homeassistant/components/lutron_caseta/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ def _async_setup_keypads(
322322

323323
@callback
324324
def _async_build_trigger_schemas(
325-
keypad_button_names_to_leap: dict[int, dict[str, int]]
325+
keypad_button_names_to_leap: dict[int, dict[str, int]],
326326
) -> dict[int, vol.Schema]:
327327
"""Build device trigger schemas."""
328328

homeassistant/components/motioneye/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def get_motioneye_device_identifier(
111111

112112

113113
def split_motioneye_device_identifier(
114-
identifier: tuple[str, str]
114+
identifier: tuple[str, str],
115115
) -> tuple[str, str, int] | None:
116116
"""Get the identifiers for a motionEye device."""
117117
if len(identifier) != 2 or identifier[0] != DOMAIN or "_" not in identifier[1]:

homeassistant/components/mqtt/mixins.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1135,7 +1135,7 @@ def _cleanup_discovery_on_remove(self) -> None:
11351135

11361136

11371137
def device_info_from_specifications(
1138-
specifications: dict[str, Any] | None
1138+
specifications: dict[str, Any] | None,
11391139
) -> DeviceInfo | None:
11401140
"""Return a device description for device registry."""
11411141
if not specifications:

homeassistant/components/nina/coordinator.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ async def _async_update_data(self) -> dict[str, list[NinaWarningData]]:
6666

6767
@staticmethod
6868
def _remove_duplicate_warnings(
69-
warnings: dict[str, list[Any]]
69+
warnings: dict[str, list[Any]],
7070
) -> dict[str, list[Any]]:
7171
"""Remove warnings with the same title and expires timestamp in a region."""
7272
all_filtered_warnings: dict[str, list[Any]] = {}

homeassistant/components/openhome/media_player.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def catch_request_errors() -> (
7979
"""Catch asyncio.TimeoutError, aiohttp.ClientError, UpnpError errors."""
8080

8181
def call_wrapper(
82-
func: _FuncType[_OpenhomeDeviceT, _P, _R]
82+
func: _FuncType[_OpenhomeDeviceT, _P, _R],
8383
) -> _ReturnFuncType[_OpenhomeDeviceT, _P, _R]:
8484
"""Call wrapper for decorator."""
8585

homeassistant/components/otbr/util.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949

5050

5151
def _handle_otbr_error(
52-
func: Callable[Concatenate[OTBRData, _P], Coroutine[Any, Any, _R]]
52+
func: Callable[Concatenate[OTBRData, _P], Coroutine[Any, Any, _R]],
5353
) -> Callable[Concatenate[OTBRData, _P], Coroutine[Any, Any, _R]]:
5454
"""Handle OTBR errors."""
5555

homeassistant/components/overkiz/alarm_control_panel.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def _state_tsk_alarm_controller(select_state: Callable[[str], OverkizStateType])
9595

9696

9797
def _state_stateful_alarm_controller(
98-
select_state: Callable[[str], OverkizStateType]
98+
select_state: Callable[[str], OverkizStateType],
9999
) -> str:
100100
"""Return the state of the device."""
101101
if state := cast(str, select_state(OverkizState.CORE_ACTIVE_ZONES)):
@@ -118,7 +118,7 @@ def _state_stateful_alarm_controller(
118118

119119

120120
def _state_myfox_alarm_controller(
121-
select_state: Callable[[str], OverkizStateType]
121+
select_state: Callable[[str], OverkizStateType],
122122
) -> str:
123123
"""Return the state of the device."""
124124
if (
@@ -141,7 +141,7 @@ def _state_myfox_alarm_controller(
141141

142142

143143
def _state_alarm_panel_controller(
144-
select_state: Callable[[str], OverkizStateType]
144+
select_state: Callable[[str], OverkizStateType],
145145
) -> str:
146146
"""Return the state of the device."""
147147
return MAP_ARM_TYPE[

0 commit comments

Comments
 (0)