From 2599faa6225a500428935a31e7c36d99c33b39cb Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Sun, 29 Dec 2024 17:16:38 +0100 Subject: [PATCH] Fix method subtyping [helpers] (#134213) --- homeassistant/core_config.py | 22 +++++++++++----------- homeassistant/helpers/httpx_client.py | 8 +++++++- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/homeassistant/core_config.py b/homeassistant/core_config.py index 38ca07e8f31..f080705fced 100644 --- a/homeassistant/core_config.py +++ b/homeassistant/core_config.py @@ -509,25 +509,25 @@ class _ComponentSet(set[str]): self._top_level_components = top_level_components self._all_components = all_components - def add(self, component: str) -> None: + def add(self, value: str) -> None: """Add a component to the store.""" - if "." not in component: - self._top_level_components.add(component) - self._all_components.add(component) + if "." not in value: + self._top_level_components.add(value) + self._all_components.add(value) else: - platform, _, domain = component.partition(".") + platform, _, domain = value.partition(".") if domain in BASE_PLATFORMS: self._all_components.add(platform) - return super().add(component) + return super().add(value) - def remove(self, component: str) -> None: + def remove(self, value: str) -> None: """Remove a component from the store.""" - if "." in component: + if "." in value: raise ValueError("_ComponentSet does not support removing sub-components") - self._top_level_components.remove(component) - return super().remove(component) + self._top_level_components.remove(value) + return super().remove(value) - def discard(self, component: str) -> None: + def discard(self, value: str) -> None: """Remove a component from the store.""" raise NotImplementedError("_ComponentSet does not support discard, use remove") diff --git a/homeassistant/helpers/httpx_client.py b/homeassistant/helpers/httpx_client.py index c3a65943cb5..ade2ce747d5 100644 --- a/homeassistant/helpers/httpx_client.py +++ b/homeassistant/helpers/httpx_client.py @@ -4,6 +4,7 @@ from __future__ import annotations from collections.abc import Callable, Coroutine import sys +from types import TracebackType from typing import Any, Self import httpx @@ -58,7 +59,12 @@ class HassHttpXAsyncClient(httpx.AsyncClient): """Prevent an integration from reopen of the client via context manager.""" return self - async def __aexit__(self, *args: object) -> None: + async def __aexit__( + self, + exc_type: type[BaseException] | None = None, + exc_value: BaseException | None = None, + traceback: TracebackType | None = None, + ) -> None: """Prevent an integration from close of the client via context manager.""" -- GitLab