From 5a046ae7be68f0e8c6e8e1aae8b82f030ba7959b Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Sat, 13 Aug 2022 18:46:34 +0200 Subject: [PATCH] Fix implicit Optional [a-n] (#76720) --- homeassistant/components/climacell/config_flow.py | 4 +++- homeassistant/components/directv/config_flow.py | 2 +- homeassistant/components/escea/climate.py | 2 +- homeassistant/components/harmony/subscriber.py | 5 ++++- homeassistant/components/huisbaasje/sensor.py | 2 +- homeassistant/components/ipp/config_flow.py | 2 +- homeassistant/components/izone/climate.py | 2 +- homeassistant/components/minecraft_server/__init__.py | 2 +- homeassistant/components/motioneye/__init__.py | 2 +- homeassistant/components/motioneye/camera.py | 8 ++++---- homeassistant/components/netgear/router.py | 6 +++--- 11 files changed, 21 insertions(+), 16 deletions(-) diff --git a/homeassistant/components/climacell/config_flow.py b/homeassistant/components/climacell/config_flow.py index ffc76479a4d..07b85e4a4ab 100644 --- a/homeassistant/components/climacell/config_flow.py +++ b/homeassistant/components/climacell/config_flow.py @@ -19,7 +19,9 @@ class ClimaCellOptionsConfigFlow(config_entries.OptionsFlow): """Initialize ClimaCell options flow.""" self._config_entry = config_entry - async def async_step_init(self, user_input: dict[str, Any] = None) -> FlowResult: + async def async_step_init( + self, user_input: dict[str, Any] | None = None + ) -> FlowResult: """Manage the ClimaCell options.""" if user_input is not None: return self.async_create_entry(title="", data=user_input) diff --git a/homeassistant/components/directv/config_flow.py b/homeassistant/components/directv/config_flow.py index 34a09a04811..b3209638012 100644 --- a/homeassistant/components/directv/config_flow.py +++ b/homeassistant/components/directv/config_flow.py @@ -100,7 +100,7 @@ class DirecTVConfigFlow(ConfigFlow, domain=DOMAIN): return await self.async_step_ssdp_confirm() async def async_step_ssdp_confirm( - self, user_input: dict[str, Any] = None + self, user_input: dict[str, Any] | None = None ) -> FlowResult: """Handle a confirmation flow initiated by SSDP.""" if user_input is None: diff --git a/homeassistant/components/escea/climate.py b/homeassistant/components/escea/climate.py index 7bd7d54353c..1ddea9cb026 100644 --- a/homeassistant/components/escea/climate.py +++ b/homeassistant/components/escea/climate.py @@ -152,7 +152,7 @@ class ControllerEntity(ClimateEntity): ) @callback - def set_available(self, available: bool, ex: Exception = None) -> None: + def set_available(self, available: bool, ex: Exception | None = None) -> None: """Set availability for the controller.""" if self._attr_available == available: return diff --git a/homeassistant/components/harmony/subscriber.py b/homeassistant/components/harmony/subscriber.py index efb46f5c6e6..092eb0d6859 100644 --- a/homeassistant/components/harmony/subscriber.py +++ b/homeassistant/components/harmony/subscriber.py @@ -1,4 +1,5 @@ """Mixin class for handling harmony callback subscriptions.""" +from __future__ import annotations import asyncio import logging @@ -85,7 +86,9 @@ class HarmonySubscriberMixin: self.async_unlock_start_activity() self._call_callbacks("activity_started", activity_info) - def _call_callbacks(self, callback_func_name: str, argument: tuple = None) -> None: + def _call_callbacks( + self, callback_func_name: str, argument: tuple | None = None + ) -> None: for subscription in self._subscriptions: current_callback = getattr(subscription, callback_func_name) if current_callback: diff --git a/homeassistant/components/huisbaasje/sensor.py b/homeassistant/components/huisbaasje/sensor.py index 2f7f607d493..c963f366323 100644 --- a/homeassistant/components/huisbaasje/sensor.py +++ b/homeassistant/components/huisbaasje/sensor.py @@ -42,7 +42,7 @@ class HuisbaasjeSensor(CoordinatorEntity, SensorEntity): user_id: str, name: str, source_type: str, - device_class: str = None, + device_class: str | None = None, sensor_type: str = SENSOR_TYPE_RATE, unit_of_measurement: str = POWER_WATT, icon: str = "mdi:lightning-bolt", diff --git a/homeassistant/components/ipp/config_flow.py b/homeassistant/components/ipp/config_flow.py index 432094eee8e..7f953c4cd9a 100644 --- a/homeassistant/components/ipp/config_flow.py +++ b/homeassistant/components/ipp/config_flow.py @@ -174,7 +174,7 @@ class IPPFlowHandler(ConfigFlow, domain=DOMAIN): return await self.async_step_zeroconf_confirm() async def async_step_zeroconf_confirm( - self, user_input: dict[str, Any] = None + self, user_input: dict[str, Any] | None = None ) -> FlowResult: """Handle a confirmation flow initiated by zeroconf.""" if user_input is None: diff --git a/homeassistant/components/izone/climate.py b/homeassistant/components/izone/climate.py index a26490e78c8..58834f995dd 100644 --- a/homeassistant/components/izone/climate.py +++ b/homeassistant/components/izone/climate.py @@ -216,7 +216,7 @@ class ControllerDevice(ClimateEntity): return self._available @callback - def set_available(self, available: bool, ex: Exception = None) -> None: + def set_available(self, available: bool, ex: Exception | None = None) -> None: """ Set availability for the controller. diff --git a/homeassistant/components/minecraft_server/__init__.py b/homeassistant/components/minecraft_server/__init__.py index 4abfbca9a2f..b2f7698d969 100644 --- a/homeassistant/components/minecraft_server/__init__.py +++ b/homeassistant/components/minecraft_server/__init__.py @@ -150,7 +150,7 @@ class MinecraftServer: ) self.online = False - async def async_update(self, now: datetime = None) -> None: + async def async_update(self, now: datetime | None = None) -> None: """Get server data from 3rd party library and update properties.""" # Check connection status. server_online_old = self.online diff --git a/homeassistant/components/motioneye/__init__.py b/homeassistant/components/motioneye/__init__.py index 7c87dda1bd2..6a650142995 100644 --- a/homeassistant/components/motioneye/__init__.py +++ b/homeassistant/components/motioneye/__init__.py @@ -544,7 +544,7 @@ class MotionEyeEntity(CoordinatorEntity): client: MotionEyeClient, coordinator: DataUpdateCoordinator, options: MappingProxyType[str, Any], - entity_description: EntityDescription = None, + entity_description: EntityDescription | None = None, ) -> None: """Initialize a motionEye entity.""" self._camera_id = camera[KEY_ID] diff --git a/homeassistant/components/motioneye/camera.py b/homeassistant/components/motioneye/camera.py index e5e4f224fe6..ff825b43bf7 100644 --- a/homeassistant/components/motioneye/camera.py +++ b/homeassistant/components/motioneye/camera.py @@ -266,10 +266,10 @@ class MotionEyeMjpegCamera(MotionEyeEntity, MjpegCamera): async def async_set_text_overlay( self, - left_text: str = None, - right_text: str = None, - custom_left_text: str = None, - custom_right_text: str = None, + left_text: str | None = None, + right_text: str | None = None, + custom_left_text: str | None = None, + custom_right_text: str | None = None, ) -> None: """Set text overlay for a camera.""" # Fetch the very latest camera config to reduce the risk of updating with a diff --git a/homeassistant/components/netgear/router.py b/homeassistant/components/netgear/router.py index 8e370a6b5e0..f69e88e83e2 100644 --- a/homeassistant/components/netgear/router.py +++ b/homeassistant/components/netgear/router.py @@ -42,9 +42,9 @@ _LOGGER = logging.getLogger(__name__) def get_api( password: str, - host: str = None, - username: str = None, - port: int = None, + host: str | None = None, + username: str | None = None, + port: int | None = None, ssl: bool = False, ) -> Netgear: """Get the Netgear API and login to it."""