Make dataclasses in HA core slotted (#91208)

This commit is contained in:
rlippmann 2023-04-11 13:58:28 -04:00 committed by GitHub
parent eb63bc7967
commit 3a72054f93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 22 additions and 22 deletions

View File

@ -32,7 +32,7 @@ class TemplateError(HomeAssistantError):
super().__init__(f"{exception.__class__.__name__}: {exception}") super().__init__(f"{exception.__class__.__name__}: {exception}")
@dataclass @dataclass(slots=True)
class ConditionError(HomeAssistantError): class ConditionError(HomeAssistantError):
"""Error during condition evaluation.""" """Error during condition evaluation."""
@ -52,7 +52,7 @@ class ConditionError(HomeAssistantError):
return "\n".join(list(self.output(indent=0))) return "\n".join(list(self.output(indent=0)))
@dataclass @dataclass(slots=True)
class ConditionErrorMessage(ConditionError): class ConditionErrorMessage(ConditionError):
"""Condition error message.""" """Condition error message."""
@ -64,7 +64,7 @@ class ConditionErrorMessage(ConditionError):
yield self._indent(indent, f"In '{self.type}' condition: {self.message}") yield self._indent(indent, f"In '{self.type}' condition: {self.message}")
@dataclass @dataclass(slots=True)
class ConditionErrorIndex(ConditionError): class ConditionErrorIndex(ConditionError):
"""Condition error with index.""" """Condition error with index."""
@ -87,7 +87,7 @@ class ConditionErrorIndex(ConditionError):
yield from self.error.output(indent + 1) yield from self.error.output(indent + 1)
@dataclass @dataclass(slots=True)
class ConditionErrorContainer(ConditionError): class ConditionErrorContainer(ConditionError):
"""Condition error with subconditions.""" """Condition error with subconditions."""

View File

@ -35,7 +35,7 @@ CHANGE_REMOVED = "removed"
_T = TypeVar("_T") _T = TypeVar("_T")
@dataclass @dataclass(slots=True)
class CollectionChangeSet: class CollectionChangeSet:
"""Class to represent a change set. """Class to represent a change set.

View File

@ -205,7 +205,7 @@ class EntityPlatformState(Enum):
REMOVED = auto() REMOVED = auto()
@dataclass @dataclass(slots=True)
class EntityDescription: class EntityDescription:
"""A class that describes Home Assistant entities.""" """A class that describes Home Assistant entities."""
@ -981,7 +981,7 @@ class Entity(ABC):
return report_issue return report_issue
@dataclass @dataclass(slots=True)
class ToggleEntityDescription(EntityDescription): class ToggleEntityDescription(EntityDescription):
"""A class that describes toggle entities.""" """A class that describes toggle entities."""

View File

@ -66,7 +66,7 @@ RANDOM_MICROSECOND_MAX = 500000
_P = ParamSpec("_P") _P = ParamSpec("_P")
@dataclass @dataclass(slots=True)
class TrackStates: class TrackStates:
"""Class for keeping track of states being tracked. """Class for keeping track of states being tracked.
@ -80,7 +80,7 @@ class TrackStates:
domains: set[str] domains: set[str]
@dataclass @dataclass(slots=True)
class TrackTemplate: class TrackTemplate:
"""Class for keeping track of a template with variables. """Class for keeping track of a template with variables.
@ -94,7 +94,7 @@ class TrackTemplate:
rate_limit: timedelta | None = None rate_limit: timedelta | None = None
@dataclass @dataclass(slots=True)
class TrackTemplateResult: class TrackTemplateResult:
"""Class for result of template tracking. """Class for result of template tracking.

View File

@ -16,7 +16,7 @@ _LOGGER = logging.getLogger(__name__)
DATA_INTEGRATION_PLATFORMS = "integration_platforms" DATA_INTEGRATION_PLATFORMS = "integration_platforms"
@dataclass(frozen=True) @dataclass(slots=True, frozen=True)
class IntegrationPlatform: class IntegrationPlatform:
"""An integration platform.""" """An integration platform."""

View File

@ -568,7 +568,7 @@ class IntentResponseTargetType(str, Enum):
CUSTOM = "custom" CUSTOM = "custom"
@dataclass @dataclass(slots=True)
class IntentResponseTarget: class IntentResponseTarget:
"""Target of the intent response.""" """Target of the intent response."""

View File

@ -32,7 +32,7 @@ class IssueSeverity(StrEnum):
WARNING = "warning" WARNING = "warning"
@dataclasses.dataclass(frozen=True) @dataclasses.dataclass(slots=True, frozen=True)
class IssueEntry: class IssueEntry:
"""Issue Registry Entry.""" """Issue Registry Entry."""

View File

@ -9,7 +9,7 @@ from homeassistant.core import HomeAssistant, callback
DOMAIN = "recorder" DOMAIN = "recorder"
@dataclass @dataclass(slots=True)
class RecorderData: class RecorderData:
"""Recorder data stored in hass.data.""" """Recorder data stored in hass.data."""

View File

@ -27,7 +27,7 @@ class SchemaFlowStep:
"""Define a config or options flow step.""" """Define a config or options flow step."""
@dataclass @dataclass(slots=True)
class SchemaFlowFormStep(SchemaFlowStep): class SchemaFlowFormStep(SchemaFlowStep):
"""Define a config or options flow form step.""" """Define a config or options flow form step."""
@ -79,7 +79,7 @@ class SchemaFlowFormStep(SchemaFlowStep):
""" """
@dataclass @dataclass(slots=True)
class SchemaFlowMenuStep(SchemaFlowStep): class SchemaFlowMenuStep(SchemaFlowStep):
"""Define a config or options flow menu step.""" """Define a config or options flow menu step."""

View File

@ -199,7 +199,7 @@ class ServiceTargetSelector:
return bool(self.entity_ids or self.device_ids or self.area_ids) return bool(self.entity_ids or self.device_ids or self.area_ids)
@dataclasses.dataclass @dataclasses.dataclass(slots=True)
class SelectedEntities: class SelectedEntities:
"""Class to hold the selected entities.""" """Class to hold the selected entities."""

View File

@ -7,7 +7,7 @@ from homeassistant.data_entry_flow import BaseServiceInfo
ReceivePayloadType = str | bytes ReceivePayloadType = str | bytes
@dataclass @dataclass(slots=True)
class MqttServiceInfo(BaseServiceInfo): class MqttServiceInfo(BaseServiceInfo):
"""Prepared info from mqtt entries.""" """Prepared info from mqtt entries."""

View File

@ -95,7 +95,7 @@ class TriggerInfo(TypedDict):
trigger_data: TriggerData trigger_data: TriggerData
@dataclass @dataclass(slots=True)
class PluggableActionsEntry: class PluggableActionsEntry:
"""Holder to keep track of all plugs and actions for a given trigger.""" """Holder to keep track of all plugs and actions for a given trigger."""

View File

@ -123,7 +123,7 @@ class USBMatcher(USBMatcherRequired, USBMatcherOptional):
"""Matcher for the bluetooth integration.""" """Matcher for the bluetooth integration."""
@dataclass @dataclass(slots=True)
class HomeKitDiscoveredIntegration: class HomeKitDiscoveredIntegration:
"""HomeKit model.""" """HomeKit model."""

View File

@ -34,7 +34,7 @@ ALPINE_RELEASE_FILE = "/etc/alpine-release"
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@dataclasses.dataclass @dataclasses.dataclass(slots=True)
class RuntimeConfig: class RuntimeConfig:
"""Class to hold the information for running Home Assistant.""" """Class to hold the information for running Home Assistant."""

View File

@ -18,7 +18,7 @@ class NodeDictClass(dict):
"""Wrapper class to be able to add attributes on a dict.""" """Wrapper class to be able to add attributes on a dict."""
@dataclass(frozen=True) @dataclass(slots=True, frozen=True)
class Input: class Input:
"""Input that should be substituted.""" """Input that should be substituted."""