Fix method subtyping [helpers] (#134213)

This commit is contained in:
Marc Mueller 2024-12-29 17:16:38 +01:00 committed by GitHub
parent 3df91cfba5
commit 2599faa622
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 12 deletions

View File

@ -509,25 +509,25 @@ class _ComponentSet(set[str]):
self._top_level_components = top_level_components self._top_level_components = top_level_components
self._all_components = all_components self._all_components = all_components
def add(self, component: str) -> None: def add(self, value: str) -> None:
"""Add a component to the store.""" """Add a component to the store."""
if "." not in component: if "." not in value:
self._top_level_components.add(component) self._top_level_components.add(value)
self._all_components.add(component) self._all_components.add(value)
else: else:
platform, _, domain = component.partition(".") platform, _, domain = value.partition(".")
if domain in BASE_PLATFORMS: if domain in BASE_PLATFORMS:
self._all_components.add(platform) 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.""" """Remove a component from the store."""
if "." in component: if "." in value:
raise ValueError("_ComponentSet does not support removing sub-components") raise ValueError("_ComponentSet does not support removing sub-components")
self._top_level_components.remove(component) self._top_level_components.remove(value)
return super().remove(component) return super().remove(value)
def discard(self, component: str) -> None: def discard(self, value: str) -> None:
"""Remove a component from the store.""" """Remove a component from the store."""
raise NotImplementedError("_ComponentSet does not support discard, use remove") raise NotImplementedError("_ComponentSet does not support discard, use remove")

View File

@ -4,6 +4,7 @@ from __future__ import annotations
from collections.abc import Callable, Coroutine from collections.abc import Callable, Coroutine
import sys import sys
from types import TracebackType
from typing import Any, Self from typing import Any, Self
import httpx import httpx
@ -58,7 +59,12 @@ class HassHttpXAsyncClient(httpx.AsyncClient):
"""Prevent an integration from reopen of the client via context manager.""" """Prevent an integration from reopen of the client via context manager."""
return self 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.""" """Prevent an integration from close of the client via context manager."""