mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 21:06:19 +00:00
Add Self typing (1) [mypy 1.0] (#87598)
This commit is contained in:
@@ -5,7 +5,9 @@ from abc import ABC, abstractmethod
|
||||
import asyncio
|
||||
from datetime import datetime, timedelta
|
||||
import logging
|
||||
from typing import Any, TypeVar, cast
|
||||
from typing import Any, cast
|
||||
|
||||
from typing_extensions import Self
|
||||
|
||||
from homeassistant.const import ATTR_RESTORED, EVENT_HOMEASSISTANT_STOP
|
||||
from homeassistant.core import HomeAssistant, State, callback, valid_entity_id
|
||||
@@ -32,8 +34,6 @@ STATE_DUMP_INTERVAL = timedelta(minutes=15)
|
||||
# How long should a saved state be preserved if the entity no longer exists
|
||||
STATE_EXPIRATION = timedelta(days=7)
|
||||
|
||||
_StoredStateSelfT = TypeVar("_StoredStateSelfT", bound="StoredState")
|
||||
|
||||
|
||||
class ExtraStoredData(ABC):
|
||||
"""Object to hold extra stored data."""
|
||||
@@ -82,7 +82,7 @@ class StoredState:
|
||||
return result
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls: type[_StoredStateSelfT], json_dict: dict) -> _StoredStateSelfT:
|
||||
def from_dict(cls, json_dict: dict) -> Self:
|
||||
"""Initialize a stored state from a dict."""
|
||||
extra_data_dict = json_dict.get("extra_data")
|
||||
extra_data = RestoredExtraData(extra_data_dict) if extra_data_dict else None
|
||||
|
||||
Reference in New Issue
Block a user