Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ClassVar annotation for singleton patterns #134135

Merged
merged 1 commit into from
Dec 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions homeassistant/components/cast/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
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
Expand Down Expand Up @@ -129,7 +129,7 @@ def fill_out_missing_chromecast_info(self, hass: HomeAssistant) -> ChromecastInf
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:
Expand Down
6 changes: 3 additions & 3 deletions homeassistant/components/yeelight/scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
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
Expand Down Expand Up @@ -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)
Expand Down
Loading