Improve annotation styling (#118032)
parent
2308ff2cbf
commit
dd22ee3dac
|
@ -27,7 +27,7 @@ class HomeAssistantTCPSite(web.BaseSite):
|
|||
def __init__(
|
||||
self,
|
||||
runner: web.BaseRunner,
|
||||
host: None | str | list[str],
|
||||
host: str | list[str] | None,
|
||||
port: int,
|
||||
*,
|
||||
ssl_context: SSLContext | None = None,
|
||||
|
|
|
@ -414,7 +414,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||
|
||||
async def handle_webhook(
|
||||
hass: HomeAssistant, webhook_id: str, request: Request
|
||||
) -> None | Response:
|
||||
) -> Response | None:
|
||||
"""Handle webhook callback."""
|
||||
|
||||
try:
|
||||
|
|
|
@ -110,7 +110,7 @@ def setup_mysensors_platform(
|
|||
device_class: type[MySensorsChildEntity]
|
||||
| Mapping[SensorType, type[MySensorsChildEntity]],
|
||||
device_args: (
|
||||
None | tuple
|
||||
tuple | None
|
||||
) = None, # extra arguments that will be given to the entity constructor
|
||||
async_add_entities: Callable | None = None,
|
||||
) -> list[MySensorsChildEntity] | None:
|
||||
|
|
|
@ -85,7 +85,7 @@ def _reset_enabled_adapters(adapters: list[Adapter]) -> None:
|
|||
|
||||
|
||||
def _ifaddr_adapter_to_ha(
|
||||
adapter: ifaddr.Adapter, next_hop_address: None | IPv4Address | IPv6Address
|
||||
adapter: ifaddr.Adapter, next_hop_address: IPv4Address | IPv6Address | None
|
||||
) -> Adapter:
|
||||
"""Convert an ifaddr adapter to ha."""
|
||||
ip_v4s: list[IPv4ConfiguredAddress] = []
|
||||
|
|
|
@ -113,7 +113,7 @@ class NibeClimateEntity(CoordinatorEntity[Coordinator], ClimateEntity):
|
|||
|
||||
self._coil_current = _get(climate.current)
|
||||
self._coil_setpoint_heat = _get(climate.setpoint_heat)
|
||||
self._coil_setpoint_cool: None | Coil
|
||||
self._coil_setpoint_cool: Coil | None
|
||||
try:
|
||||
self._coil_setpoint_cool = _get(climate.setpoint_cool)
|
||||
except CoilNotFoundException:
|
||||
|
|
|
@ -76,7 +76,7 @@ async def handle_add_product(
|
|||
)
|
||||
|
||||
|
||||
def product_search(api_client: PicnicAPI, product_name: str | None) -> None | str:
|
||||
def product_search(api_client: PicnicAPI, product_name: str | None) -> str | None:
|
||||
"""Query the api client for the product name."""
|
||||
if product_name is None:
|
||||
return None
|
||||
|
|
|
@ -83,7 +83,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||
return unload_ok
|
||||
|
||||
|
||||
async def _can_use_icmp_lib_with_privilege() -> None | bool:
|
||||
async def _can_use_icmp_lib_with_privilege() -> bool | None:
|
||||
"""Verify we can create a raw socket."""
|
||||
try:
|
||||
await async_ping("127.0.0.1", count=0, timeout=0, privileged=True)
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
"""A pool for sqlite connections."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import logging
|
||||
import threading
|
||||
|
@ -51,7 +53,7 @@ class RecorderPool(SingletonThreadPool, NullPool):
|
|||
self.recorder_and_worker_thread_ids = recorder_and_worker_thread_ids
|
||||
SingletonThreadPool.__init__(self, creator, **kw)
|
||||
|
||||
def recreate(self) -> "RecorderPool":
|
||||
def recreate(self) -> RecorderPool:
|
||||
"""Recreate the pool."""
|
||||
self.logger.info("Pool recreating")
|
||||
return self.__class__(
|
||||
|
|
|
@ -44,7 +44,7 @@ DURATION_SECONDS = "duration_in_s"
|
|||
POSITION_SECONDS = "position_in_s"
|
||||
|
||||
|
||||
def _timespan_secs(timespan: str | None) -> None | int:
|
||||
def _timespan_secs(timespan: str | None) -> int | None:
|
||||
"""Parse a time-span into number of seconds."""
|
||||
if timespan in UNAVAILABLE_VALUES:
|
||||
return None
|
||||
|
|
|
@ -148,7 +148,7 @@ def _format_err(name: str, *args: Any) -> str:
|
|||
async def async_register_callback(
|
||||
hass: HomeAssistant,
|
||||
callback: Callable[[SsdpServiceInfo, SsdpChange], Coroutine[Any, Any, None] | None],
|
||||
match_dict: None | dict[str, str] = None,
|
||||
match_dict: dict[str, str] | None = None,
|
||||
) -> Callable[[], None]:
|
||||
"""Register to receive a callback on ssdp broadcast.
|
||||
|
||||
|
@ -317,7 +317,7 @@ class Scanner:
|
|||
return list(self._device_tracker.devices.values())
|
||||
|
||||
async def async_register_callback(
|
||||
self, callback: SsdpHassJobCallback, match_dict: None | dict[str, str] = None
|
||||
self, callback: SsdpHassJobCallback, match_dict: dict[str, str] | None = None
|
||||
) -> Callable[[], None]:
|
||||
"""Register a callback."""
|
||||
if match_dict is None:
|
||||
|
|
|
@ -205,7 +205,7 @@ class SubaruSensor(
|
|||
self._attr_unique_id = f"{self.vin}_{description.key}"
|
||||
|
||||
@property
|
||||
def native_value(self) -> None | int | float:
|
||||
def native_value(self) -> int | float | None:
|
||||
"""Return the state of the sensor."""
|
||||
vehicle_data = self.coordinator.data[self.vin]
|
||||
current_value = vehicle_data[VEHICLE_STATUS].get(self.entity_description.key)
|
||||
|
|
|
@ -483,7 +483,7 @@ class AutoOffExtraStoredData(ExtraStoredData):
|
|||
|
||||
def as_dict(self) -> dict[str, Any]:
|
||||
"""Return a dict representation of additional data."""
|
||||
auto_off_time: datetime | None | dict[str, str] = self.auto_off_time
|
||||
auto_off_time: datetime | dict[str, str] | None = self.auto_off_time
|
||||
if isinstance(auto_off_time, datetime):
|
||||
auto_off_time = {
|
||||
"__type": str(type(auto_off_time)),
|
||||
|
|
|
@ -257,7 +257,7 @@ class SensorTemplate(TemplateEntity, SensorEntity):
|
|||
self._attr_device_class = config.get(CONF_DEVICE_CLASS)
|
||||
self._attr_state_class = config.get(CONF_STATE_CLASS)
|
||||
self._template: template.Template = config[CONF_STATE]
|
||||
self._attr_last_reset_template: None | template.Template = config.get(
|
||||
self._attr_last_reset_template: template.Template | None = config.get(
|
||||
ATTR_LAST_RESET
|
||||
)
|
||||
if (object_id := config.get(CONF_OBJECT_ID)) is not None:
|
||||
|
|
|
@ -189,7 +189,7 @@ class _TemplateAttribute:
|
|||
self,
|
||||
event: Event[EventStateChangedData] | None,
|
||||
template: Template,
|
||||
last_result: str | None | TemplateError,
|
||||
last_result: str | TemplateError | None,
|
||||
result: str | TemplateError,
|
||||
) -> None:
|
||||
"""Handle a template result event callback."""
|
||||
|
|
|
@ -342,8 +342,8 @@ class TibberSensor(SensorEntity):
|
|||
self._home_name = tibber_home.info["viewer"]["home"]["address"].get(
|
||||
"address1", ""
|
||||
)
|
||||
self._device_name: None | str = None
|
||||
self._model: None | str = None
|
||||
self._device_name: str | None = None
|
||||
self._model: str | None = None
|
||||
|
||||
@property
|
||||
def device_info(self) -> DeviceInfo:
|
||||
|
|
|
@ -352,7 +352,7 @@ async def async_not_from_config(
|
|||
|
||||
def numeric_state(
|
||||
hass: HomeAssistant,
|
||||
entity: None | str | State,
|
||||
entity: str | State | None,
|
||||
below: float | str | None = None,
|
||||
above: float | str | None = None,
|
||||
value_template: Template | None = None,
|
||||
|
@ -373,7 +373,7 @@ def numeric_state(
|
|||
|
||||
def async_numeric_state(
|
||||
hass: HomeAssistant,
|
||||
entity: None | str | State,
|
||||
entity: str | State | None,
|
||||
below: float | str | None = None,
|
||||
above: float | str | None = None,
|
||||
value_template: Template | None = None,
|
||||
|
@ -545,7 +545,7 @@ def async_numeric_state_from_config(config: ConfigType) -> ConditionCheckerType:
|
|||
|
||||
def state(
|
||||
hass: HomeAssistant,
|
||||
entity: None | str | State,
|
||||
entity: str | State | None,
|
||||
req_state: Any,
|
||||
for_period: timedelta | None = None,
|
||||
attribute: str | None = None,
|
||||
|
@ -803,7 +803,7 @@ def time(
|
|||
hass: HomeAssistant,
|
||||
before: dt_time | str | None = None,
|
||||
after: dt_time | str | None = None,
|
||||
weekday: None | str | Container[str] = None,
|
||||
weekday: str | Container[str] | None = None,
|
||||
) -> bool:
|
||||
"""Test if local time condition matches.
|
||||
|
||||
|
@ -902,8 +902,8 @@ def time_from_config(config: ConfigType) -> ConditionCheckerType:
|
|||
|
||||
def zone(
|
||||
hass: HomeAssistant,
|
||||
zone_ent: None | str | State,
|
||||
entity: None | str | State,
|
||||
zone_ent: str | State | None,
|
||||
entity: str | State | None,
|
||||
) -> bool:
|
||||
"""Test if zone-condition matches.
|
||||
|
||||
|
|
|
@ -164,7 +164,7 @@ def _format_err[*_Ts](
|
|||
|
||||
def _generate_job[*_Ts](
|
||||
signal: SignalType[*_Ts] | str, target: Callable[[*_Ts], Any] | Callable[..., Any]
|
||||
) -> HassJob[..., None | Coroutine[Any, Any, None]]:
|
||||
) -> HassJob[..., Coroutine[Any, Any, None] | None]:
|
||||
"""Generate a HassJob for a signal and target."""
|
||||
job_type = get_hassjob_callable_job_type(target)
|
||||
return HassJob(
|
||||
|
|
|
@ -201,8 +201,8 @@ def async_track_state_change(
|
|||
action: Callable[
|
||||
[str, State | None, State | None], Coroutine[Any, Any, None] | None
|
||||
],
|
||||
from_state: None | str | Iterable[str] = None,
|
||||
to_state: None | str | Iterable[str] = None,
|
||||
from_state: str | Iterable[str] | None = None,
|
||||
to_state: str | Iterable[str] | None = None,
|
||||
) -> CALLBACK_TYPE:
|
||||
"""Track specific state changes.
|
||||
|
||||
|
@ -1866,7 +1866,7 @@ track_time_change = threaded_listener_factory(async_track_time_change)
|
|||
|
||||
|
||||
def process_state_match(
|
||||
parameter: None | str | Iterable[str], invert: bool = False
|
||||
parameter: str | Iterable[str] | None, invert: bool = False
|
||||
) -> Callable[[str | None], bool]:
|
||||
"""Convert parameter to function that matches input against parameter."""
|
||||
if parameter is None or parameter == MATCH_ALL:
|
||||
|
|
|
@ -833,7 +833,7 @@ def async_set_service_schema(
|
|||
def _get_permissible_entity_candidates(
|
||||
call: ServiceCall,
|
||||
entities: dict[str, Entity],
|
||||
entity_perms: None | (Callable[[str, str], bool]),
|
||||
entity_perms: Callable[[str, str], bool] | None,
|
||||
target_all_entities: bool,
|
||||
all_referenced: set[str] | None,
|
||||
) -> list[Entity]:
|
||||
|
@ -889,7 +889,7 @@ async def entity_service_call(
|
|||
|
||||
Calls all platforms simultaneously.
|
||||
"""
|
||||
entity_perms: None | (Callable[[str, str], bool]) = None
|
||||
entity_perms: Callable[[str, str], bool] | None = None
|
||||
return_response = call.return_response
|
||||
|
||||
if call.context.user_id:
|
||||
|
|
|
@ -36,7 +36,7 @@ def _async_at_core_state(
|
|||
hass.async_run_hass_job(at_start_job, hass)
|
||||
return lambda: None
|
||||
|
||||
unsub: None | CALLBACK_TYPE = None
|
||||
unsub: CALLBACK_TYPE | None = None
|
||||
|
||||
@callback
|
||||
def _matched_event(event: Event) -> None:
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
"""Common fixtures for Anova."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
from dataclasses import dataclass
|
||||
import json
|
||||
|
@ -40,7 +42,7 @@ class MockedAnovaWebsocketStream:
|
|||
"""Initialize a Anova Websocket Stream that can be manipulated for tests."""
|
||||
self.messages = messages
|
||||
|
||||
def __aiter__(self) -> "MockedAnovaWebsocketStream":
|
||||
def __aiter__(self) -> MockedAnovaWebsocketStream:
|
||||
"""Handle async iteration."""
|
||||
return self
|
||||
|
||||
|
|
|
@ -146,7 +146,7 @@ async def test_update_device(
|
|||
client: MockHAClientWebSocket,
|
||||
device_registry: dr.DeviceRegistry,
|
||||
payload_key: str,
|
||||
payload_value: str | None | dr.DeviceEntryDisabler,
|
||||
payload_value: str | dr.DeviceEntryDisabler | None,
|
||||
) -> None:
|
||||
"""Test update entry."""
|
||||
entry = MockConfigEntry(title=None)
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
"""Tests for the Ruckus Unleashed integration."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from unittest.mock import AsyncMock, patch
|
||||
|
||||
from aioruckus import AjaxSession, RuckusAjaxApi
|
||||
|
@ -181,7 +183,7 @@ class RuckusAjaxApiPatchContext:
|
|||
|
||||
def _patched_async_create(
|
||||
host: str, username: str, password: str
|
||||
) -> "AjaxSession":
|
||||
) -> AjaxSession:
|
||||
return AjaxSession(None, host, username, password)
|
||||
|
||||
self.patchers.append(
|
||||
|
|
|
@ -81,10 +81,10 @@ class MockApiResponseKey(str, Enum):
|
|||
|
||||
def mock_uptimerobot_api_response(
|
||||
data: dict[str, Any]
|
||||
| None
|
||||
| list[UptimeRobotMonitor]
|
||||
| UptimeRobotAccount
|
||||
| UptimeRobotApiError = None,
|
||||
| UptimeRobotApiError
|
||||
| None = None,
|
||||
status: APIStatus = APIStatus.OK,
|
||||
key: MockApiResponseKey = MockApiResponseKey.MONITORS,
|
||||
) -> UptimeRobotApiResponse:
|
||||
|
|
Loading…
Reference in New Issue