mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 13:47:35 +00:00
Add ClassVar annotation for singleton patterns (#134135)
This commit is contained in:
parent
cc80108629
commit
d9f2140df3
@ -5,7 +5,7 @@ from __future__ import annotations
|
|||||||
import configparser
|
import configparser
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
import logging
|
import logging
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING, ClassVar
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
@ -129,7 +129,7 @@ class ChromecastInfo:
|
|||||||
class ChromeCastZeroconf:
|
class ChromeCastZeroconf:
|
||||||
"""Class to hold a zeroconf instance."""
|
"""Class to hold a zeroconf instance."""
|
||||||
|
|
||||||
__zconf: zeroconf.HaZeroconf | None = None
|
__zconf: ClassVar[zeroconf.HaZeroconf | None] = None
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def set_zeroconf(cls, zconf: zeroconf.HaZeroconf) -> None:
|
def set_zeroconf(cls, zconf: zeroconf.HaZeroconf) -> None:
|
||||||
|
@ -9,7 +9,7 @@ from datetime import datetime
|
|||||||
from functools import partial
|
from functools import partial
|
||||||
from ipaddress import IPv4Address
|
from ipaddress import IPv4Address
|
||||||
import logging
|
import logging
|
||||||
from typing import Self
|
from typing import ClassVar, Self
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
from async_upnp_client.search import SsdpSearchListener
|
from async_upnp_client.search import SsdpSearchListener
|
||||||
@ -44,11 +44,11 @@ def _set_future_if_not_done(future: asyncio.Future[None]) -> None:
|
|||||||
class YeelightScanner:
|
class YeelightScanner:
|
||||||
"""Scan for Yeelight devices."""
|
"""Scan for Yeelight devices."""
|
||||||
|
|
||||||
_scanner: Self | None = None
|
_scanner: ClassVar[Self | None] = None
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@callback
|
@callback
|
||||||
def async_get(cls, hass: HomeAssistant) -> YeelightScanner:
|
def async_get(cls, hass: HomeAssistant) -> Self:
|
||||||
"""Get scanner instance."""
|
"""Get scanner instance."""
|
||||||
if cls._scanner is None:
|
if cls._scanner is None:
|
||||||
cls._scanner = cls(hass)
|
cls._scanner = cls(hass)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user