From d9f2140df3f2f62fa7cf7b741ab7f95817af1ea0 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Sat, 28 Dec 2024 13:17:15 +0100 Subject: [PATCH] Add ClassVar annotation for singleton patterns (#134135) --- homeassistant/components/cast/helpers.py | 4 ++-- homeassistant/components/yeelight/scanner.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/cast/helpers.py b/homeassistant/components/cast/helpers.py index 228c69b65ec..8f4af197b8e 100644 --- a/homeassistant/components/cast/helpers.py +++ b/homeassistant/components/cast/helpers.py @@ -5,7 +5,7 @@ from __future__ import annotations import configparser from dataclasses import dataclass import logging -from typing import TYPE_CHECKING +from typing import TYPE_CHECKING, ClassVar from urllib.parse import urlparse import aiohttp @@ -129,7 +129,7 @@ class ChromecastInfo: class ChromeCastZeroconf: """Class to hold a zeroconf instance.""" - __zconf: zeroconf.HaZeroconf | None = None + __zconf: ClassVar[zeroconf.HaZeroconf | None] = None @classmethod def set_zeroconf(cls, zconf: zeroconf.HaZeroconf) -> None: diff --git a/homeassistant/components/yeelight/scanner.py b/homeassistant/components/yeelight/scanner.py index ac482504880..7e908396ff3 100644 --- a/homeassistant/components/yeelight/scanner.py +++ b/homeassistant/components/yeelight/scanner.py @@ -9,7 +9,7 @@ from datetime import datetime from functools import partial from ipaddress import IPv4Address import logging -from typing import Self +from typing import ClassVar, Self from urllib.parse import urlparse from async_upnp_client.search import SsdpSearchListener @@ -44,11 +44,11 @@ def _set_future_if_not_done(future: asyncio.Future[None]) -> None: class YeelightScanner: """Scan for Yeelight devices.""" - _scanner: Self | None = None + _scanner: ClassVar[Self | None] = None @classmethod @callback - def async_get(cls, hass: HomeAssistant) -> YeelightScanner: + def async_get(cls, hass: HomeAssistant) -> Self: """Get scanner instance.""" if cls._scanner is None: cls._scanner = cls(hass)