Update Ruff to 0.1.8, avoid linter/formatter conflicts (#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
This commit is contained in:
Ville Skyttä 2023-12-21 00:55:09 +02:00 committed by GitHub
parent f5f9b89848
commit 24b1e01d71
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
91 changed files with 188 additions and 173 deletions

View File

@ -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:

View File

@ -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."""

View File

@ -42,7 +42,7 @@ SCAN_INTERVAL: Final = timedelta(seconds=10)
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."""

View File

@ -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 {
@ -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.

View File

@ -116,7 +116,9 @@ _P = ParamSpec("_P")
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]
]:

View File

@ -60,7 +60,7 @@ PLATFORM_SCHEMA = vol.Schema(
def retry(
method: Callable[Concatenate[_DecoraLightT, _P], _R]
method: Callable[Concatenate[_DecoraLightT, _P], _R],
) -> Callable[Concatenate[_DecoraLightT, _P], _R | None]:
"""Retry bluetooth commands."""

View File

@ -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]
]:

View File

@ -489,7 +489,7 @@ class DHCPWatcher(WatcherBase):
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}

View File

@ -55,7 +55,7 @@ _P = ParamSpec("_P")
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."""

View File

@ -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."""

View File

@ -47,7 +47,7 @@ _P = ParamSpec("_P")
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."""

View File

@ -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 = {

View File

@ -92,7 +92,7 @@ async def platform_async_setup_entry(
def esphome_state_property(
func: Callable[[_EntityT], _R]
func: Callable[[_EntityT], _R],
) -> Callable[[_EntityT], _R | None]:
"""Wrap a state property of an esphome entity.

View File

@ -13,7 +13,7 @@ _P = ParamSpec("_P")
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."""

View File

@ -129,7 +129,7 @@ class OptionsFlow(config_entries.OptionsFlow):
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:

View File

@ -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
@ -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
@ -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)
@ -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)
@ -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
@ -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))
@ -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
@ -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

View File

@ -171,7 +171,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
@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."""

View File

@ -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."""

View File

@ -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."""

View File

@ -152,7 +152,7 @@ _HOMEKIT_CONFIG_UPDATE_TIME = (
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]

View File

@ -16,7 +16,7 @@ _P = ParamSpec("_P")
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.

View File

@ -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."""

View File

@ -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."""

View File

@ -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."""

View File

@ -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:

View File

@ -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."""

View File

@ -19,7 +19,7 @@ _P = ParamSpec("_P")
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.

View File

@ -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."""

View File

@ -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]:

View File

@ -1135,7 +1135,7 @@ class MqttDiscoveryUpdate(Entity):
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:

View File

@ -66,7 +66,7 @@ class NINADataUpdateCoordinator(
@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]] = {}

View File

@ -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."""

View File

@ -49,7 +49,7 @@ INSECURE_PASSPHRASES = (
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."""

View File

@ -95,7 +95,7 @@ MAP_CORE_ACTIVE_ZONES: dict[str, str] = {
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)):
@ -118,7 +118,7 @@ MAP_MYFOX_STATUS_STATE: dict[str, str] = {
def _state_myfox_alarm_controller(
select_state: Callable[[str], OverkizStateType]
select_state: Callable[[str], OverkizStateType],
) -> str:
"""Return the state of the device."""
if (
@ -141,7 +141,7 @@ MAP_ARM_TYPE: dict[str, str] = {
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[

View File

@ -53,7 +53,7 @@ _LOGGER = logging.getLogger(__name__)
def needs_session(
func: Callable[Concatenate[_PlexMediaPlayerT, _P], _R]
func: Callable[Concatenate[_PlexMediaPlayerT, _P], _R],
) -> Callable[Concatenate[_PlexMediaPlayerT, _P], _R | None]:
"""Ensure session is available for certain attributes."""

View File

@ -14,7 +14,7 @@ _P = ParamSpec("_P")
def plugwise_command(
func: Callable[Concatenate[_PlugwiseEntityT, _P], Awaitable[_R]]
func: Callable[Concatenate[_PlugwiseEntityT, _P], Awaitable[_R]],
) -> Callable[Concatenate[_PlugwiseEntityT, _P], Coroutine[Any, Any, _R]]:
"""Decorate Plugwise calls that send commands/make changes to the device.

View File

@ -335,7 +335,7 @@ async def async_setup_entry( # noqa: C901
"""Hydrate a service call with the appropriate controller."""
def decorator(
func: Callable[[ServiceCall, Controller], Coroutine[Any, Any, None]]
func: Callable[[ServiceCall, Controller], Coroutine[Any, Any, None]],
) -> Callable[[ServiceCall], Coroutine[Any, Any, None]]:
"""Define the decorator."""

View File

@ -117,7 +117,7 @@ _P = ParamSpec("_P")
def raise_on_request_error(
func: Callable[Concatenate[_T, _P], Awaitable[None]]
func: Callable[Concatenate[_T, _P], Awaitable[None]],
) -> Callable[Concatenate[_T, _P], Coroutine[Any, Any, None]]:
"""Define a decorator to raise on a request error."""

View File

@ -782,7 +782,7 @@ def _statistic_by_id_from_metadata(
def _flatten_list_statistic_ids_metadata_result(
result: dict[str, dict[str, Any]]
result: dict[str, dict[str, Any]],
) -> list[dict]:
"""Return a flat dict of metadata."""
return [

View File

@ -658,7 +658,7 @@ def database_job_retry_wrapper(
"""
def decorator(
job: _WrappedFuncType[_RecorderT, _P]
job: _WrappedFuncType[_RecorderT, _P],
) -> _WrappedFuncType[_RecorderT, _P]:
@functools.wraps(job)
def wrapper(instance: _RecorderT, *args: _P.args, **kwargs: _P.kwargs) -> None:

View File

@ -26,7 +26,7 @@ _P = ParamSpec("_P")
def with_error_wrapping(
func: Callable[Concatenate[RenaultVehicleProxy, _P], Awaitable[_T]]
func: Callable[Concatenate[RenaultVehicleProxy, _P], Awaitable[_T]],
) -> Callable[Concatenate[RenaultVehicleProxy, _P], Coroutine[Any, Any, _T]]:
"""Catch Renault errors."""

View File

@ -147,7 +147,7 @@ def _create_rfx(config: Mapping[str, Any]) -> rfxtrxmod.Connect:
def _get_device_lookup(
devices: dict[str, dict[str, Any]]
devices: dict[str, dict[str, Any]],
) -> dict[DeviceTuple, dict[str, Any]]:
"""Get a lookup structure for devices."""
lookup = {}
@ -440,7 +440,7 @@ def get_device_id(
def get_device_tuple_from_identifiers(
identifiers: set[tuple[str, str]]
identifiers: set[tuple[str, str]],
) -> DeviceTuple | None:
"""Calculate the device tuple from a device entry."""
identifier = next((x for x in identifiers if x[0] == DOMAIN and len(x) == 4), None)

View File

@ -32,7 +32,7 @@ def roku_exception_handler(
"""Decorate Roku calls to handle Roku exceptions."""
def decorator(
func: _FuncType[_RokuEntityT, _P]
func: _FuncType[_RokuEntityT, _P],
) -> _ReturnFuncType[_RokuEntityT, _P]:
@wraps(func)
async def wrapper(

View File

@ -191,7 +191,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
@callback
def extract_api(
func: Callable[[ServiceCall, SabnzbdApiData], Coroutine[Any, Any, None]]
func: Callable[[ServiceCall, SabnzbdApiData], Coroutine[Any, Any, None]],
) -> Callable[[ServiceCall], Coroutine[Any, Any, None]]:
"""Define a decorator to get the correct api for a service call."""

View File

@ -19,7 +19,7 @@ _P = ParamSpec("_P")
def async_handle_api_call(
function: Callable[Concatenate[_T, _P], Coroutine[Any, Any, Any]]
function: Callable[Concatenate[_T, _P], Coroutine[Any, Any, Any]],
) -> Callable[Concatenate[_T, _P], Coroutine[Any, Any, Any]]:
"""Decorate api calls."""

View File

@ -30,7 +30,7 @@ _P = ParamSpec("_P")
def with_error_wrapping(
func: Callable[Concatenate[SFRBoxButton, _P], Awaitable[_T]]
func: Callable[Concatenate[SFRBoxButton, _P], Awaitable[_T]],
) -> Callable[Concatenate[SFRBoxButton, _P], Coroutine[Any, Any, _T]]:
"""Catch SFR errors."""

View File

@ -337,7 +337,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
@callback
def extract_system(
func: Callable[[ServiceCall, SystemType], Coroutine[Any, Any, None]]
func: Callable[[ServiceCall, SystemType], Coroutine[Any, Any, None]],
) -> Callable[[ServiceCall], Coroutine[Any, Any, None]]:
"""Define a decorator to get the correct system for a service call."""

View File

@ -112,7 +112,7 @@ async def async_generate_speaker_info(
payload: dict[str, Any] = {}
def get_contents(
item: int | float | str | dict[str, Any]
item: int | float | str | dict[str, Any],
) -> int | float | str | dict[str, Any]:
if isinstance(item, (int, float, str)):
return item

View File

@ -84,7 +84,7 @@ def _user_schema_with_defaults(user_input: dict[str, Any]) -> vol.Schema:
def _ordered_shared_schema(
schema_input: dict[str, Any]
schema_input: dict[str, Any],
) -> dict[vol.Required | vol.Optional, Any]:
return {
vol.Required(CONF_USERNAME, default=schema_input.get(CONF_USERNAME, "")): str,

View File

@ -18,7 +18,7 @@ _P = ParamSpec("_P")
def async_refresh_after(
func: Callable[Concatenate[_T, _P], Awaitable[None]]
func: Callable[Concatenate[_T, _P], Awaitable[None]],
) -> Callable[Concatenate[_T, _P], Coroutine[Any, Any, None]]:
"""Define a wrapper to refresh after."""

View File

@ -19,7 +19,7 @@ from .coordinator import TradfriDeviceDataUpdateCoordinator
def handle_error(
func: Callable[[Command | list[Command]], Any]
func: Callable[[Command | list[Command]], Any],
) -> Callable[[Command | list[Command]], Coroutine[Any, Any, None]]:
"""Handle tradfri api call error."""

View File

@ -48,7 +48,7 @@ def _build_module_diagnostics_info(module: VelbusModule) -> dict[str, Any]:
def _build_channels_diagnostics_info(
channels: dict[str, VelbusChannel]
channels: dict[str, VelbusChannel],
) -> dict[str, Any]:
"""Build diagnostics info for all channels."""
data: dict[str, Any] = {}

View File

@ -48,7 +48,7 @@ _P = ParamSpec("_P")
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."""

View File

@ -44,7 +44,7 @@ def new_options(lights: list[int], exclude: list[int]) -> dict[str, list[int]]:
def options_schema(
options: Mapping[str, Any] | None = None
options: Mapping[str, Any] | None = None,
) -> dict[vol.Optional, type[str]]:
"""Return options schema."""
options = options or {}

View File

@ -45,7 +45,7 @@ async def async_setup_entry(
def catch_vlc_errors(
func: Callable[Concatenate[_VlcDeviceT, _P], Awaitable[None]]
func: Callable[Concatenate[_VlcDeviceT, _P], Awaitable[None]],
) -> Callable[Concatenate[_VlcDeviceT, _P], Coroutine[Any, Any, None]]:
"""Catch VLC errors."""

View File

@ -68,7 +68,7 @@ _P = ParamSpec("_P")
def _require_authentication(
func: Callable[Concatenate[_WallboxCoordinatorT, _P], Any]
func: Callable[Concatenate[_WallboxCoordinatorT, _P], Any],
) -> Callable[Concatenate[_WallboxCoordinatorT, _P], Any]:
"""Authenticate with decorator using Wallbox API."""

View File

@ -84,7 +84,7 @@ _P = ParamSpec("_P")
def cmd(
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."""

View File

@ -650,7 +650,7 @@ async def handle_render_template(
def _serialize_entity_sources(
entity_infos: dict[str, entity.EntityInfo]
entity_infos: dict[str, entity.EntityInfo],
) -> dict[str, Any]:
"""Prepare a websocket response from a dict of entity sources."""
return {

View File

@ -15,7 +15,7 @@ _P = ParamSpec("_P")
def wled_exception_handler(
func: Callable[Concatenate[_WLEDEntityT, _P], Coroutine[Any, Any, Any]]
func: Callable[Concatenate[_WLEDEntityT, _P], Coroutine[Any, Any, Any]],
) -> Callable[Concatenate[_WLEDEntityT, _P], Coroutine[Any, Any, None]]:
"""Decorate WLED calls to handle WLED exceptions.

View File

@ -248,7 +248,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
def _build_homekit_model_lookups(
homekit_models: dict[str, HomeKitDiscoveredIntegration]
homekit_models: dict[str, HomeKitDiscoveredIntegration],
) -> tuple[
dict[str, HomeKitDiscoveredIntegration],
dict[re.Pattern, HomeKitDiscoveredIntegration],

View File

@ -457,7 +457,7 @@ def remove_keys_with_empty_values(config: ConfigType) -> ConfigType:
def check_type_schema_map(
schema_map: dict[str, vol.Schema]
schema_map: dict[str, vol.Schema],
) -> Callable[[ConfigType], ConfigType]:
"""Check type specific schema against config."""

View File

@ -49,7 +49,7 @@ T = TypeVar("T", ZwaveNode, Endpoint)
def parameter_name_does_not_need_bitmask(
val: dict[str, int | str | list[str]]
val: dict[str, int | str | list[str]],
) -> dict[str, int | str | list[str]]:
"""Validate that if a parameter name is provided, bitmask is not as well."""
if (

View File

@ -155,7 +155,7 @@ class IntegrationConfigInfo:
def _no_duplicate_auth_provider(
configs: Sequence[dict[str, Any]]
configs: Sequence[dict[str, Any]],
) -> Sequence[dict[str, Any]]:
"""No duplicate auth provider config allowed in a list.
@ -176,7 +176,7 @@ def _no_duplicate_auth_provider(
def _no_duplicate_auth_mfa_module(
configs: Sequence[dict[str, Any]]
configs: Sequence[dict[str, Any]],
) -> Sequence[dict[str, Any]]:
"""No duplicate auth mfa module item allowed in a list.

View File

@ -93,7 +93,7 @@ FILTER_SCHEMA = vol.All(BASE_FILTER_SCHEMA, convert_filter)
def convert_include_exclude_filter(
config: dict[str, dict[str, list[str]]]
config: dict[str, dict[str, list[str]]],
) -> EntityFilter:
"""Convert the include exclude filter schema into a filter."""
include = config[CONF_INCLUDE]

View File

@ -136,7 +136,7 @@ class EventStateChangedData(TypedDict):
def threaded_listener_factory(
async_factory: Callable[Concatenate[HomeAssistant, _P], Any]
async_factory: Callable[Concatenate[HomeAssistant, _P], Any],
) -> Callable[Concatenate[HomeAssistant, _P], CALLBACK_TYPE]:
"""Convert an async event helper to a threaded one."""

View File

@ -998,7 +998,7 @@ def verify_domain_control(
"""Ensure permission to access any entity under domain in service call."""
def decorator(
service_handler: Callable[[ServiceCall], Any]
service_handler: Callable[[ServiceCall], Any],
) -> Callable[[ServiceCall], Any]:
"""Decorate."""
if not asyncio.iscoroutinefunction(service_handler):

View File

@ -67,7 +67,7 @@ def component_translation_path(
def load_translations_files(
translation_files: dict[str, str]
translation_files: dict[str, str],
) -> dict[str, dict[str, Any]]:
"""Load and parse translation.json files."""
loaded = {}

View File

@ -189,7 +189,7 @@ def catch_log_coro_exception(
def async_create_catching_coro(
target: Coroutine[Any, Any, _T]
target: Coroutine[Any, Any, _T],
) -> Coroutine[Any, Any, _T | None]:
"""Wrap a coroutine to catch and log exceptions.

View File

@ -582,7 +582,6 @@ select = [
"G", # flake8-logging-format
"I", # isort
"ICN001", # import concentions; {name} should be imported as {asname}
"ISC001", # Implicitly concatenated string literals on one line
"N804", # First argument of a class method should be named cls
"N805", # First argument of a method should be named self
"N815", # Variable {name} in class scope should not be mixedCase
@ -658,6 +657,21 @@ ignore = [
# Ignored due to performance: https://github.com/charliermarsh/ruff/issues/2923
"UP038", # Use `X | Y` in `isinstance` call instead of `(X, Y)`
# May conflict with the formatter, https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules
"W191",
"E111",
"E114",
"E117",
"D206",
"D300",
"Q000",
"Q001",
"Q002",
"Q003",
"COM812",
"COM819",
"ISC001",
"ISC002",
]
[tool.ruff.flake8-import-conventions.extend-aliases]

View File

@ -1,5 +1,5 @@
# Automatically generated from .pre-commit-config.yaml by gen_requirements_all.py, do not edit
codespell==2.2.2
ruff==0.1.6
ruff==0.1.8
yamllint==1.32.0

View File

@ -1225,7 +1225,7 @@ class MockEntity(entity.Entity):
@contextmanager
def mock_storage(
data: dict[str, Any] | None = None
data: dict[str, Any] | None = None,
) -> Generator[dict[str, Any], None, None]:
"""Mock storage.

View File

@ -2285,7 +2285,6 @@ async def test_cast_platform_play_media_local_media(
quick_play_mock.assert_called()
app_data = quick_play_mock.call_args[0][2]
# No authSig appended
assert (
app_data["media_id"]
== f"{network.get_url(hass)}/api/hls/bla/master_playlist.m3u8?token=bla"
)
assert app_data[
"media_id"
] == f"{network.get_url(hass)}/api/hls/bla/master_playlist.m3u8?token=bla"

View File

@ -320,7 +320,7 @@ async def mock_bluetooth_entry(
"""Set up an ESPHome entry with bluetooth."""
async def _mock_bluetooth_entry(
bluetooth_proxy_feature_flags: BluetoothProxyFeature
bluetooth_proxy_feature_flags: BluetoothProxyFeature,
) -> MockESPHomeDevice:
return await _mock_generic_device_entry(
hass,
@ -348,7 +348,7 @@ async def mock_bluetooth_entry_with_raw_adv(mock_bluetooth_entry) -> MockESPHome
@pytest.fixture
async def mock_bluetooth_entry_with_legacy_adv(
mock_bluetooth_entry
mock_bluetooth_entry,
) -> MockESPHomeDevice:
"""Set up an ESPHome entry with bluetooth with legacy advertisements."""
return await mock_bluetooth_entry(

View File

@ -37,7 +37,7 @@ async def setup_fronius_integration(
def _load_and_patch_fixture(
override_data: dict[str, list[tuple[list[str], Any]]]
override_data: dict[str, list[tuple[list[str], Any]]],
) -> Callable[[str, str | None], str]:
"""Return a fixture loader that patches values at nested keys for a given filename."""

View File

@ -260,7 +260,7 @@ def mock_events_list(
@pytest.fixture
def mock_events_list_items(
mock_events_list: Callable[[dict[str, Any]], None]
mock_events_list: Callable[[dict[str, Any]], None],
) -> Callable[[list[dict[str, Any]]], None]:
"""Fixture to construct an API response containing event items."""

View File

@ -277,7 +277,7 @@ async def test_climate_change_thermostat_temperature_range(hass: HomeAssistant)
async def test_climate_change_thermostat_temperature_range_iphone(
hass: HomeAssistant
hass: HomeAssistant,
) -> None:
"""Test that we can set all three set points at once (iPhone heat_cool mode support)."""
helper = await setup_test_component(hass, create_thermostat_service)
@ -312,7 +312,7 @@ async def test_climate_change_thermostat_temperature_range_iphone(
async def test_climate_cannot_set_thermostat_temp_range_in_wrong_mode(
hass: HomeAssistant
hass: HomeAssistant,
) -> None:
"""Test that we cannot set range values when not in heat_cool mode."""
helper = await setup_test_component(hass, create_thermostat_service)
@ -371,7 +371,7 @@ def create_thermostat_single_set_point_auto(accessory):
async def test_climate_check_min_max_values_per_mode_sspa_device(
hass: HomeAssistant
hass: HomeAssistant,
) -> None:
"""Test appropriate min/max values for each mode on sspa devices."""
helper = await setup_test_component(hass, create_thermostat_single_set_point_auto)

View File

@ -749,7 +749,7 @@ async def test_v2_oscillate_read(hass: HomeAssistant) -> None:
async def test_v2_set_percentage_non_standard_rotation_range(
hass: HomeAssistant
hass: HomeAssistant,
) -> None:
"""Test that we set fan speed with a non-standard rotation range."""
helper = await setup_test_component(

View File

@ -116,7 +116,7 @@ def mock_config_entry() -> MockConfigEntry:
@pytest.fixture
async def mock_added_config_entry(
mock_add_config_entry: Callable[[], Awaitable[MockConfigEntry]]
mock_add_config_entry: Callable[[], Awaitable[MockConfigEntry]],
) -> MockConfigEntry:
"""Mock ConfigEntry that's been added to HA."""
return await mock_add_config_entry()

View File

@ -302,7 +302,7 @@ async def _test_common_success_w_authorize(
"""Test bluetooth and user flow success paths."""
async def subscribe_state_updates(
state_callback: Callable[[State], None]
state_callback: Callable[[State], None],
) -> Callable[[], None]:
state_callback(State.AUTHORIZED)
return lambda: None
@ -612,7 +612,7 @@ async def test_provision_not_authorized(hass: HomeAssistant, exc, error) -> None
"""Test bluetooth flow with error."""
async def subscribe_state_updates(
state_callback: Callable[[State], None]
state_callback: Callable[[State], None],
) -> Callable[[], None]:
state_callback(State.AUTHORIZED)
return lambda: None

View File

@ -58,7 +58,7 @@ async def init_integration(
@pytest.fixture
async def get_items(
hass_ws_client: WebSocketGenerator
hass_ws_client: WebSocketGenerator,
) -> Callable[[], Awaitable[dict[str, str]]]:
"""Fixture to fetch items from the todo websocket."""

View File

@ -115,7 +115,7 @@ def mock_insert_schedule_response(
@pytest.fixture(name="get_events")
def get_events_fixture(
hass_client: Callable[..., Awaitable[ClientSession]]
hass_client: Callable[..., Awaitable[ClientSession]],
) -> GetEventsFn:
"""Fetch calendar events from the HTTP API."""

View File

@ -118,7 +118,7 @@ def _add_db_entries(
def test_get_full_significant_states_with_session_entity_no_matches(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Test getting states at a specific point in time for entities that never have been recorded."""
hass = hass_recorder()
@ -246,7 +246,7 @@ def test_state_changes_during_period(
def test_state_changes_during_period_descending(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Test state change during period descending."""
hass = hass_recorder()
@ -410,7 +410,7 @@ def test_get_last_state_change(hass_recorder: Callable[..., HomeAssistant]) -> N
def test_ensure_state_can_be_copied(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Ensure a state can pass though copy().
@ -455,7 +455,7 @@ def test_get_significant_states(hass_recorder: Callable[..., HomeAssistant]) ->
def test_get_significant_states_minimal_response(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Test that only significant states are returned.
@ -554,7 +554,7 @@ def test_get_significant_states_with_initial(
def test_get_significant_states_without_initial(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Test that only significant states are returned.
@ -588,7 +588,7 @@ def test_get_significant_states_without_initial(
def test_get_significant_states_entity_id(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Test that only significant states are returned for one entity."""
hass = hass_recorder()
@ -604,7 +604,7 @@ def test_get_significant_states_entity_id(
def test_get_significant_states_multiple_entity_ids(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Test that only significant states are returned for one entity."""
hass = hass_recorder()
@ -626,7 +626,7 @@ def test_get_significant_states_multiple_entity_ids(
def test_get_significant_states_are_ordered(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Test order of results from get_significant_states.
@ -644,7 +644,7 @@ def test_get_significant_states_are_ordered(
def test_get_significant_states_only(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Test significant states when significant_states_only is set."""
hass = hass_recorder()
@ -1082,7 +1082,7 @@ async def test_get_full_significant_states_handles_empty_last_changed(
def test_state_changes_during_period_multiple_entities_single_test(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Test state change during period with multiple entities in the same test.
@ -1141,7 +1141,7 @@ async def test_get_full_significant_states_past_year_2038(
def test_get_significant_states_without_entity_ids_raises(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Test at least one entity id is required for get_significant_states."""
hass = hass_recorder()
@ -1151,7 +1151,7 @@ def test_get_significant_states_without_entity_ids_raises(
def test_state_changes_during_period_without_entity_ids_raises(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Test at least one entity id is required for state_changes_during_period."""
hass = hass_recorder()
@ -1161,7 +1161,7 @@ def test_state_changes_during_period_without_entity_ids_raises(
def test_get_significant_states_with_filters_raises(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Test passing filters is no longer supported."""
hass = hass_recorder()
@ -1173,7 +1173,7 @@ def test_get_significant_states_with_filters_raises(
def test_get_significant_states_with_non_existent_entity_ids_returns_empty(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Test get_significant_states returns an empty dict when entities not in the db."""
hass = hass_recorder()
@ -1182,7 +1182,7 @@ def test_get_significant_states_with_non_existent_entity_ids_returns_empty(
def test_state_changes_during_period_with_non_existent_entity_ids_returns_empty(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Test state_changes_during_period returns an empty dict when entities not in the db."""
hass = hass_recorder()
@ -1193,7 +1193,7 @@ def test_state_changes_during_period_with_non_existent_entity_ids_returns_empty(
def test_get_last_state_changes_with_non_existent_entity_ids_returns_empty(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Test get_last_state_changes returns an empty dict when entities not in the db."""
hass = hass_recorder()

View File

@ -37,7 +37,7 @@ def db_schema_30():
def test_get_full_significant_states_with_session_entity_no_matches(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Test getting states at a specific point in time for entities that never have been recorded."""
hass = hass_recorder()
@ -152,7 +152,7 @@ def test_state_changes_during_period(
def test_state_changes_during_period_descending(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Test state change during period descending."""
hass = hass_recorder()
@ -240,7 +240,7 @@ def test_get_last_state_changes(hass_recorder: Callable[..., HomeAssistant]) ->
def test_ensure_state_can_be_copied(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Ensure a state can pass though copy().
@ -293,7 +293,7 @@ def test_get_significant_states(hass_recorder: Callable[..., HomeAssistant]) ->
def test_get_significant_states_minimal_response(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Test that only significant states are returned.
@ -362,7 +362,7 @@ def test_get_significant_states_minimal_response(
def test_get_significant_states_with_initial(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Test that only significant states are returned.
@ -399,7 +399,7 @@ def test_get_significant_states_with_initial(
def test_get_significant_states_without_initial(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Test that only significant states are returned.
@ -435,7 +435,7 @@ def test_get_significant_states_without_initial(
def test_get_significant_states_entity_id(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Test that only significant states are returned for one entity."""
hass = hass_recorder()
@ -453,7 +453,7 @@ def test_get_significant_states_entity_id(
def test_get_significant_states_multiple_entity_ids(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Test that only significant states are returned for one entity."""
hass = hass_recorder()
@ -480,7 +480,7 @@ def test_get_significant_states_multiple_entity_ids(
def test_get_significant_states_are_ordered(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Test order of results from get_significant_states.
@ -501,7 +501,7 @@ def test_get_significant_states_are_ordered(
def test_get_significant_states_only(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Test significant states when significant_states_only is set."""
hass = hass_recorder()
@ -644,7 +644,7 @@ def record_states(hass) -> tuple[datetime, datetime, dict[str, list[State]]]:
def test_state_changes_during_period_multiple_entities_single_test(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Test state change during period with multiple entities in the same test.
@ -669,7 +669,7 @@ def test_state_changes_during_period_multiple_entities_single_test(
def test_get_significant_states_without_entity_ids_raises(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Test at least one entity id is required for get_significant_states."""
hass = hass_recorder()
@ -679,7 +679,7 @@ def test_get_significant_states_without_entity_ids_raises(
def test_state_changes_during_period_without_entity_ids_raises(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Test at least one entity id is required for state_changes_during_period."""
hass = hass_recorder()
@ -689,7 +689,7 @@ def test_state_changes_during_period_without_entity_ids_raises(
def test_get_significant_states_with_filters_raises(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Test passing filters is no longer supported."""
hass = hass_recorder()
@ -701,7 +701,7 @@ def test_get_significant_states_with_filters_raises(
def test_get_significant_states_with_non_existent_entity_ids_returns_empty(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Test get_significant_states returns an empty dict when entities not in the db."""
hass = hass_recorder()
@ -710,7 +710,7 @@ def test_get_significant_states_with_non_existent_entity_ids_returns_empty(
def test_state_changes_during_period_with_non_existent_entity_ids_returns_empty(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Test state_changes_during_period returns an empty dict when entities not in the db."""
hass = hass_recorder()
@ -721,7 +721,7 @@ def test_state_changes_during_period_with_non_existent_entity_ids_returns_empty(
def test_get_last_state_changes_with_non_existent_entity_ids_returns_empty(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Test get_last_state_changes returns an empty dict when entities not in the db."""
hass = hass_recorder()

View File

@ -37,7 +37,7 @@ def db_schema_32():
def test_get_full_significant_states_with_session_entity_no_matches(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Test getting states at a specific point in time for entities that never have been recorded."""
hass = hass_recorder()
@ -152,7 +152,7 @@ def test_state_changes_during_period(
def test_state_changes_during_period_descending(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Test state change during period descending."""
hass = hass_recorder()
@ -239,7 +239,7 @@ def test_get_last_state_changes(hass_recorder: Callable[..., HomeAssistant]) ->
def test_ensure_state_can_be_copied(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Ensure a state can pass though copy().
@ -292,7 +292,7 @@ def test_get_significant_states(hass_recorder: Callable[..., HomeAssistant]) ->
def test_get_significant_states_minimal_response(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Test that only significant states are returned.
@ -389,7 +389,7 @@ def test_get_significant_states_with_initial(
def test_get_significant_states_without_initial(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Test that only significant states are returned.
@ -425,7 +425,7 @@ def test_get_significant_states_without_initial(
def test_get_significant_states_entity_id(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Test that only significant states are returned for one entity."""
hass = hass_recorder()
@ -443,7 +443,7 @@ def test_get_significant_states_entity_id(
def test_get_significant_states_multiple_entity_ids(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Test that only significant states are returned for one entity."""
hass = hass_recorder()
@ -470,7 +470,7 @@ def test_get_significant_states_multiple_entity_ids(
def test_get_significant_states_are_ordered(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Test order of results from get_significant_states.
@ -491,7 +491,7 @@ def test_get_significant_states_are_ordered(
def test_get_significant_states_only(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Test significant states when significant_states_only is set."""
hass = hass_recorder()
@ -634,7 +634,7 @@ def record_states(hass) -> tuple[datetime, datetime, dict[str, list[State]]]:
def test_state_changes_during_period_multiple_entities_single_test(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Test state change during period with multiple entities in the same test.
@ -659,7 +659,7 @@ def test_state_changes_during_period_multiple_entities_single_test(
def test_get_significant_states_without_entity_ids_raises(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Test at least one entity id is required for get_significant_states."""
hass = hass_recorder()
@ -669,7 +669,7 @@ def test_get_significant_states_without_entity_ids_raises(
def test_state_changes_during_period_without_entity_ids_raises(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Test at least one entity id is required for state_changes_during_period."""
hass = hass_recorder()
@ -679,7 +679,7 @@ def test_state_changes_during_period_without_entity_ids_raises(
def test_get_significant_states_with_filters_raises(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Test passing filters is no longer supported."""
hass = hass_recorder()
@ -691,7 +691,7 @@ def test_get_significant_states_with_filters_raises(
def test_get_significant_states_with_non_existent_entity_ids_returns_empty(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Test get_significant_states returns an empty dict when entities not in the db."""
hass = hass_recorder()
@ -700,7 +700,7 @@ def test_get_significant_states_with_non_existent_entity_ids_returns_empty(
def test_state_changes_during_period_with_non_existent_entity_ids_returns_empty(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Test state_changes_during_period returns an empty dict when entities not in the db."""
hass = hass_recorder()
@ -711,7 +711,7 @@ def test_state_changes_during_period_with_non_existent_entity_ids_returns_empty(
def test_get_last_state_changes_with_non_existent_entity_ids_returns_empty(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Test get_last_state_changes returns an empty dict when entities not in the db."""
hass = hass_recorder()

View File

@ -537,7 +537,7 @@ def test_saving_event(hass_recorder: Callable[..., HomeAssistant]) -> None:
def test_saving_state_with_commit_interval_zero(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Test saving a state with a commit interval of zero."""
hass = hass_recorder({"commit_interval": 0})
@ -594,7 +594,7 @@ def test_setup_without_migration(hass_recorder: Callable[..., HomeAssistant]) ->
def test_saving_state_include_domains(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Test saving and restoring a state."""
hass = hass_recorder({"include": {"domains": "test2"}})
@ -604,7 +604,7 @@ def test_saving_state_include_domains(
def test_saving_state_include_domains_globs(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Test saving and restoring a state."""
hass = hass_recorder(
@ -627,7 +627,7 @@ def test_saving_state_include_domains_globs(
def test_saving_state_incl_entities(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Test saving and restoring a state."""
hass = hass_recorder({"include": {"entities": "test2.recorder"}})
@ -688,7 +688,7 @@ async def test_saving_event_exclude_event_type(
def test_saving_state_exclude_domains(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Test saving and restoring a state."""
hass = hass_recorder({"exclude": {"domains": "test"}})
@ -698,7 +698,7 @@ def test_saving_state_exclude_domains(
def test_saving_state_exclude_domains_globs(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Test saving and restoring a state."""
hass = hass_recorder(
@ -712,7 +712,7 @@ def test_saving_state_exclude_domains_globs(
def test_saving_state_exclude_entities(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Test saving and restoring a state."""
hass = hass_recorder({"exclude": {"entities": "test.recorder"}})
@ -722,7 +722,7 @@ def test_saving_state_exclude_entities(
def test_saving_state_exclude_domain_include_entity(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Test saving and restoring a state."""
hass = hass_recorder(
@ -733,7 +733,7 @@ def test_saving_state_exclude_domain_include_entity(
def test_saving_state_exclude_domain_glob_include_entity(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Test saving and restoring a state."""
hass = hass_recorder(
@ -749,7 +749,7 @@ def test_saving_state_exclude_domain_glob_include_entity(
def test_saving_state_include_domain_exclude_entity(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Test saving and restoring a state."""
hass = hass_recorder(
@ -762,7 +762,7 @@ def test_saving_state_include_domain_exclude_entity(
def test_saving_state_include_domain_glob_exclude_entity(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Test saving and restoring a state."""
hass = hass_recorder(
@ -780,7 +780,7 @@ def test_saving_state_include_domain_glob_exclude_entity(
def test_saving_state_and_removing_entity(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Test saving the state of a removed entity."""
hass = hass_recorder()
@ -1025,7 +1025,7 @@ def test_auto_purge(hass_recorder: Callable[..., HomeAssistant]) -> None:
@pytest.mark.parametrize("enable_nightly_purge", [True])
def test_auto_purge_auto_repack_on_second_sunday(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Test periodic purge scheduling does a repack on the 2nd sunday."""
hass = hass_recorder()
@ -1065,7 +1065,7 @@ def test_auto_purge_auto_repack_on_second_sunday(
@pytest.mark.parametrize("enable_nightly_purge", [True])
def test_auto_purge_auto_repack_disabled_on_second_sunday(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Test periodic purge scheduling does not auto repack on the 2nd sunday if disabled."""
hass = hass_recorder({CONF_AUTO_REPACK: False})
@ -1105,7 +1105,7 @@ def test_auto_purge_auto_repack_disabled_on_second_sunday(
@pytest.mark.parametrize("enable_nightly_purge", [True])
def test_auto_purge_no_auto_repack_on_not_second_sunday(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Test periodic purge scheduling does not do a repack unless its the 2nd sunday."""
hass = hass_recorder()
@ -1431,7 +1431,7 @@ def test_has_services(hass_recorder: Callable[..., HomeAssistant]) -> None:
def test_service_disable_events_not_recording(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Test that events are not recorded when recorder is disabled using service."""
hass = hass_recorder()
@ -1515,7 +1515,7 @@ def test_service_disable_events_not_recording(
def test_service_disable_states_not_recording(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Test that state changes are not recorded when recorder is disabled using service."""
hass = hass_recorder()

View File

@ -432,7 +432,7 @@ def test_rename_entity(hass_recorder: Callable[..., HomeAssistant]) -> None:
def test_statistics_during_period_set_back_compat(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Test statistics_during_period can handle a list instead of a set."""
hass = hass_recorder()

View File

@ -883,7 +883,7 @@ def test_build_mysqldb_conv() -> None:
@patch("homeassistant.components.recorder.util.QUERY_RETRY_WAIT", 0)
def test_execute_stmt_lambda_element(
hass_recorder: Callable[..., HomeAssistant]
hass_recorder: Callable[..., HomeAssistant],
) -> None:
"""Test executing with execute_stmt_lambda_element."""
hass = hass_recorder()

View File

@ -233,7 +233,7 @@ def remotews_fixture() -> Mock:
remotews.app_list_data = None
async def _start_listening(
ws_event_callback: Callable[[str, Any], Awaitable[None] | None] | None = None
ws_event_callback: Callable[[str, Any], Awaitable[None] | None] | None = None,
):
remotews.ws_event_callback = ws_event_callback
@ -272,7 +272,7 @@ def remoteencws_fixture() -> Mock:
remoteencws.__aexit__ = AsyncMock()
def _start_listening(
ws_event_callback: Callable[[str, Any], Awaitable[None] | None] | None = None
ws_event_callback: Callable[[str, Any], Awaitable[None] | None] | None = None,
):
remoteencws.ws_event_callback = ws_event_callback

View File

@ -731,7 +731,7 @@ async def test_zll_device_groups(
mock.MagicMock(),
)
async def test_cluster_no_ep_attribute(
zha_device_mock: Callable[..., ZHADevice]
zha_device_mock: Callable[..., ZHADevice],
) -> None:
"""Test cluster handlers for clusters without ep_attribute."""

View File

@ -973,7 +973,7 @@ async def _mqtt_mock_entry(
mock_mqtt_instance = None
async def _setup_mqtt_entry(
setup_entry: Callable[[HomeAssistant, ConfigEntry], Coroutine[Any, Any, bool]]
setup_entry: Callable[[HomeAssistant, ConfigEntry], Coroutine[Any, Any, bool]],
) -> MagicMock:
"""Set up the MQTT config entry."""
assert await setup_entry(hass, entry)

View File

@ -325,7 +325,7 @@ def test_check_if_deprecated_constant(
def test_test_check_if_deprecated_constant_invalid(
caplog: pytest.LogCaptureFixture
caplog: pytest.LogCaptureFixture,
) -> None:
"""Test check_if_deprecated_constant will raise an attribute error and create an log entry on an invalid deprecation type."""
module_name = "homeassistant.components.hue.light"