Use Mapping[str, Any] instead of dict in Entity (#48421)

This commit is contained in:
Ruslan Sayfutdinov 2021-03-31 18:34:00 +01:00 committed by GitHub
parent bb7f64596c
commit a6759d731d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,6 +3,7 @@ from __future__ import annotations
from abc import ABC from abc import ABC
import asyncio import asyncio
from collections.abc import Mapping
from datetime import datetime, timedelta from datetime import datetime, timedelta
import functools as ft import functools as ft
import logging import logging
@ -151,7 +152,7 @@ class Entity(ABC):
return STATE_UNKNOWN return STATE_UNKNOWN
@property @property
def capability_attributes(self) -> dict[str, Any] | None: def capability_attributes(self) -> Mapping[str, Any] | None:
"""Return the capability attributes. """Return the capability attributes.
Attributes that explain the capabilities of an entity. Attributes that explain the capabilities of an entity.
@ -171,7 +172,7 @@ class Entity(ABC):
return None return None
@property @property
def device_state_attributes(self) -> dict[str, Any] | None: def device_state_attributes(self) -> Mapping[str, Any] | None:
"""Return entity specific state attributes. """Return entity specific state attributes.
This method is deprecated, platform classes should implement This method is deprecated, platform classes should implement
@ -180,7 +181,7 @@ class Entity(ABC):
return None return None
@property @property
def extra_state_attributes(self) -> dict[str, Any] | None: def extra_state_attributes(self) -> Mapping[str, Any] | None:
"""Return entity specific state attributes. """Return entity specific state attributes.
Implemented by platform classes. Convention for attribute names Implemented by platform classes. Convention for attribute names
@ -189,7 +190,7 @@ class Entity(ABC):
return None return None
@property @property
def device_info(self) -> dict[str, Any] | None: def device_info(self) -> Mapping[str, Any] | None:
"""Return device specific attributes. """Return device specific attributes.
Implemented by platform classes. Implemented by platform classes.