diff --git a/homeassistant/helpers/collection.py b/homeassistant/helpers/collection.py index 4af524bbbc9..abeef0f0d68 100644 --- a/homeassistant/helpers/collection.py +++ b/homeassistant/helpers/collection.py @@ -136,7 +136,6 @@ class YamlCollection(ObservableCollection): async def async_load(self, data: List[dict]) -> None: """Load the YAML collection. Overrides existing data.""" - old_ids = set(self.data) change_sets = [] diff --git a/homeassistant/helpers/config_validation.py b/homeassistant/helpers/config_validation.py index 4af4744e509..6f1c6f46599 100644 --- a/homeassistant/helpers/config_validation.py +++ b/homeassistant/helpers/config_validation.py @@ -549,7 +549,6 @@ unit_system = vol.All( def template(value: Optional[Any]) -> template_helper.Template: """Validate a jinja2 template.""" - if value is None: raise vol.Invalid("template value is None") if isinstance(value, (list, dict, template_helper.Template)): @@ -566,7 +565,6 @@ def template(value: Optional[Any]) -> template_helper.Template: def dynamic_template(value: Optional[Any]) -> template_helper.Template: """Validate a dynamic (non static) jinja2 template.""" - if value is None: raise vol.Invalid("template value is None") if isinstance(value, (list, dict, template_helper.Template)): diff --git a/homeassistant/helpers/entity.py b/homeassistant/helpers/entity.py index 04c07ef0f36..7d0e38ab119 100644 --- a/homeassistant/helpers/entity.py +++ b/homeassistant/helpers/entity.py @@ -65,7 +65,6 @@ def async_generate_entity_id( hass: Optional[HomeAssistant] = None, ) -> str: """Generate a unique entity ID based on given entity IDs or used IDs.""" - name = (name or DEVICE_DEFAULT_NAME).lower() preferred_string = entity_id_format.format(slugify(name)) diff --git a/homeassistant/helpers/event.py b/homeassistant/helpers/event.py index 44cbd89fde7..102a84863bd 100644 --- a/homeassistant/helpers/event.py +++ b/homeassistant/helpers/event.py @@ -299,7 +299,6 @@ def _async_remove_indexed_listeners( job: HassJob, ) -> None: """Remove a listener.""" - callbacks = hass.data[data_key] for storage_key in storage_keys: @@ -686,7 +685,6 @@ def async_track_template( Callable to unregister the listener. """ - job = HassJob(action) @callback @@ -1105,7 +1103,6 @@ def async_track_point_in_time( point_in_time: datetime, ) -> CALLBACK_TYPE: """Add a listener that fires once after a specific point in time.""" - job = action if isinstance(action, HassJob) else HassJob(action) @callback @@ -1329,7 +1326,6 @@ def async_track_utc_time_change( local: bool = False, ) -> CALLBACK_TYPE: """Add a listener that will fire if time matches a pattern.""" - job = HassJob(action) # We do not have to wrap the function with time pattern matching logic # if no pattern given diff --git a/homeassistant/helpers/frame.py b/homeassistant/helpers/frame.py index def2508ff92..a0517338ec8 100644 --- a/homeassistant/helpers/frame.py +++ b/homeassistant/helpers/frame.py @@ -70,7 +70,6 @@ def report_integration( Async friendly. """ - found_frame, integration, path = integration_frame index = found_frame.filename.index(path) diff --git a/homeassistant/helpers/httpx_client.py b/homeassistant/helpers/httpx_client.py index 0f1719b388d..b86223964b3 100644 --- a/homeassistant/helpers/httpx_client.py +++ b/homeassistant/helpers/httpx_client.py @@ -51,7 +51,6 @@ def create_async_httpx_client( This method must be run in the event loop. """ - client = httpx.AsyncClient( verify=verify_ssl, headers={USER_AGENT: SERVER_SOFTWARE}, diff --git a/homeassistant/helpers/reload.py b/homeassistant/helpers/reload.py index 8ff454eab6f..4a768a79320 100644 --- a/homeassistant/helpers/reload.py +++ b/homeassistant/helpers/reload.py @@ -157,13 +157,11 @@ async def async_setup_reload_service( hass: HomeAssistantType, domain: str, platforms: Iterable ) -> None: """Create the reload service for the domain.""" - if hass.services.has_service(domain, SERVICE_RELOAD): return async def _reload_config(call: Event) -> None: """Reload the platforms.""" - await async_reload_integration_platforms(hass, domain, platforms) hass.bus.async_fire(f"event_{domain}_reloaded", context=call.context) @@ -176,7 +174,6 @@ def setup_reload_service( hass: HomeAssistantType, domain: str, platforms: Iterable ) -> None: """Sync version of async_setup_reload_service.""" - asyncio.run_coroutine_threadsafe( async_setup_reload_service(hass, domain, platforms), hass.loop, diff --git a/homeassistant/helpers/service.py b/homeassistant/helpers/service.py index c83fa4a7763..13dcd779b25 100644 --- a/homeassistant/helpers/service.py +++ b/homeassistant/helpers/service.py @@ -26,6 +26,7 @@ from homeassistant.const import ( ATTR_DEVICE_ID, ATTR_ENTITY_ID, CONF_SERVICE, + CONF_SERVICE_DATA, CONF_SERVICE_TEMPLATE, CONF_TARGET, ENTITY_MATCH_ALL, @@ -62,7 +63,6 @@ if TYPE_CHECKING: CONF_SERVICE_ENTITY_ID = "entity_id" -CONF_SERVICE_DATA = "data" CONF_SERVICE_DATA_TEMPLATE = "data_template" _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/helpers/storage.py b/homeassistant/helpers/storage.py index a969b2cad9a..2bc13fbdf44 100644 --- a/homeassistant/helpers/storage.py +++ b/homeassistant/helpers/storage.py @@ -202,7 +202,6 @@ class Store: async def _async_handle_write_data(self, *_args): """Handle writing the config.""" - async with self._write_lock: self._async_cleanup_delay_listener() self._async_cleanup_final_write_listener() diff --git a/homeassistant/helpers/sun.py b/homeassistant/helpers/sun.py index 818010c3410..a2385ba397c 100644 --- a/homeassistant/helpers/sun.py +++ b/homeassistant/helpers/sun.py @@ -19,7 +19,6 @@ DATA_LOCATION_CACHE = "astral_location_cache" @bind_hass def get_astral_location(hass: HomeAssistantType) -> "astral.Location": """Get an astral location for the current Home Assistant configuration.""" - from astral import Location # pylint: disable=import-outside-toplevel latitude = hass.config.latitude diff --git a/homeassistant/helpers/template.py b/homeassistant/helpers/template.py index af63cab10eb..9da0cbc09eb 100644 --- a/homeassistant/helpers/template.py +++ b/homeassistant/helpers/template.py @@ -1292,7 +1292,6 @@ def relative_time(value): If the input are not a datetime object the input will be returned unmodified. """ - if not isinstance(value, datetime): return value if not value.tzinfo: diff --git a/homeassistant/helpers/update_coordinator.py b/homeassistant/helpers/update_coordinator.py index b2424a06927..8ba355e6489 100644 --- a/homeassistant/helpers/update_coordinator.py +++ b/homeassistant/helpers/update_coordinator.py @@ -264,7 +264,6 @@ class CoordinatorEntity(entity.Entity): Only used by the generic entity update service. """ - # Ignore manual update requests if the entity is disabled if not self.enabled: return