From f5911bcad6819a82636d5a7b3fb0c1e3c0c09196 Mon Sep 17 00:00:00 2001 From: rlippmann <70883373+rlippmann@users.noreply.github.com> Date: Fri, 14 Apr 2023 14:22:39 -0400 Subject: [PATCH] Add slots to dataclasses in default_config (#91410) * add dataclass slots to default config items * remove slots from sun mixing --- homeassistant/components/automation/__init__.py | 2 +- homeassistant/components/backup/manager.py | 2 +- homeassistant/components/bluetooth/base_scanner.py | 2 +- homeassistant/components/bluetooth/match.py | 2 +- homeassistant/components/bluetooth/models.py | 2 +- .../components/bluetooth/passive_update_processor.py | 4 ++-- homeassistant/components/bluetooth/wrappers.py | 2 +- homeassistant/components/conversation/agent.py | 4 ++-- homeassistant/components/conversation/default_agent.py | 2 +- homeassistant/components/energy/sensor.py | 2 +- homeassistant/components/energy/validate.py | 6 +++--- homeassistant/components/hardware/models.py | 6 +++--- homeassistant/components/hardware/websocket_api.py | 2 +- homeassistant/components/history/websocket_api.py | 2 +- homeassistant/components/homeassistant_alerts/__init__.py | 2 +- homeassistant/components/logbook/models.py | 4 ++-- homeassistant/components/logbook/processor.py | 2 +- homeassistant/components/logbook/websocket_api.py | 2 +- homeassistant/components/logger/helpers.py | 4 ++-- homeassistant/components/media_source/models.py | 4 ++-- homeassistant/components/script/__init__.py | 2 +- homeassistant/components/system_health/__init__.py | 2 +- homeassistant/components/webhook/trigger.py | 2 +- 23 files changed, 32 insertions(+), 32 deletions(-) diff --git a/homeassistant/components/automation/__init__.py b/homeassistant/components/automation/__init__.py index 3cfae999b92..4712592edc7 100644 --- a/homeassistant/components/automation/__init__.py +++ b/homeassistant/components/automation/__init__.py @@ -659,7 +659,7 @@ class AutomationEntity(ToggleEntity, RestoreEntity): ) -@dataclass +@dataclass(slots=True) class AutomationEntityConfig: """Container for prepared automation entity configuration.""" diff --git a/homeassistant/components/backup/manager.py b/homeassistant/components/backup/manager.py index f48a71a78c3..1f8b70f4d35 100644 --- a/homeassistant/components/backup/manager.py +++ b/homeassistant/components/backup/manager.py @@ -26,7 +26,7 @@ from .const import DOMAIN, EXCLUDE_FROM_BACKUP, LOGGER BUF_SIZE = 2**20 * 4 # 4MB -@dataclass +@dataclass(slots=True) class Backup: """Backup class.""" diff --git a/homeassistant/components/bluetooth/base_scanner.py b/homeassistant/components/bluetooth/base_scanner.py index d5e2ca0edbb..a3bd9c29f92 100644 --- a/homeassistant/components/bluetooth/base_scanner.py +++ b/homeassistant/components/bluetooth/base_scanner.py @@ -39,7 +39,7 @@ MONOTONIC_TIME: Final = monotonic_time_coarse _LOGGER = logging.getLogger(__name__) -@dataclass +@dataclass(slots=True) class BluetoothScannerDevice: """Data for a bluetooth device from a given scanner.""" diff --git a/homeassistant/components/bluetooth/match.py b/homeassistant/components/bluetooth/match.py index a7308bfd7ff..1315d0a834a 100644 --- a/homeassistant/components/bluetooth/match.py +++ b/homeassistant/components/bluetooth/match.py @@ -61,7 +61,7 @@ class BluetoothCallbackMatcherWithCallback( """Callback matcher for the bluetooth integration that stores the callback.""" -@dataclass(frozen=False) +@dataclass(slots=True, frozen=False) class IntegrationMatchHistory: """Track which fields have been seen.""" diff --git a/homeassistant/components/bluetooth/models.py b/homeassistant/components/bluetooth/models.py index 40ac86de607..1856ccd5994 100644 --- a/homeassistant/components/bluetooth/models.py +++ b/homeassistant/components/bluetooth/models.py @@ -20,7 +20,7 @@ MANAGER: BluetoothManager | None = None MONOTONIC_TIME: Final = monotonic_time_coarse -@dataclass +@dataclass(slots=True) class HaBluetoothConnector: """Data for how to connect a BLEDevice from a given scanner.""" diff --git a/homeassistant/components/bluetooth/passive_update_processor.py b/homeassistant/components/bluetooth/passive_update_processor.py index e1701487409..607abaa0168 100644 --- a/homeassistant/components/bluetooth/passive_update_processor.py +++ b/homeassistant/components/bluetooth/passive_update_processor.py @@ -20,7 +20,7 @@ if TYPE_CHECKING: from . import BluetoothChange, BluetoothScanningMode, BluetoothServiceInfoBleak -@dataclasses.dataclass(frozen=True) +@dataclasses.dataclass(slots=True, frozen=True) class PassiveBluetoothEntityKey: """Key for a passive bluetooth entity. @@ -36,7 +36,7 @@ class PassiveBluetoothEntityKey: _T = TypeVar("_T") -@dataclasses.dataclass(frozen=True) +@dataclasses.dataclass(slots=True, frozen=True) class PassiveBluetoothDataUpdate(Generic[_T]): """Generic bluetooth data.""" diff --git a/homeassistant/components/bluetooth/wrappers.py b/homeassistant/components/bluetooth/wrappers.py index cf17796105b..7ccbce453c1 100644 --- a/homeassistant/components/bluetooth/wrappers.py +++ b/homeassistant/components/bluetooth/wrappers.py @@ -34,7 +34,7 @@ if TYPE_CHECKING: from .manager import BluetoothManager -@dataclass +@dataclass(slots=True) class _HaWrappedBleakBackend: """Wrap bleak backend to make it usable by Home Assistant.""" diff --git a/homeassistant/components/conversation/agent.py b/homeassistant/components/conversation/agent.py index 2b2c307f824..0056f35def6 100644 --- a/homeassistant/components/conversation/agent.py +++ b/homeassistant/components/conversation/agent.py @@ -9,7 +9,7 @@ from homeassistant.core import Context from homeassistant.helpers import intent -@dataclass +@dataclass(slots=True) class ConversationInput: """User input to be processed.""" @@ -19,7 +19,7 @@ class ConversationInput: language: str -@dataclass +@dataclass(slots=True) class ConversationResult: """Result of async_process.""" diff --git a/homeassistant/components/conversation/default_agent.py b/homeassistant/components/conversation/default_agent.py index d89b938a025..02d90d1c8dd 100644 --- a/homeassistant/components/conversation/default_agent.py +++ b/homeassistant/components/conversation/default_agent.py @@ -47,7 +47,7 @@ def json_load(fp: IO[str]) -> JsonObjectType: return json_loads_object(fp.read()) -@dataclass +@dataclass(slots=True) class LanguageIntents: """Loaded intents for a language.""" diff --git a/homeassistant/components/energy/sensor.py b/homeassistant/components/energy/sensor.py index 6f16d2dc831..b2b29760e5e 100644 --- a/homeassistant/components/energy/sensor.py +++ b/homeassistant/components/energy/sensor.py @@ -74,7 +74,7 @@ async def async_setup_platform( await sensor_manager.async_start() -@dataclass +@dataclass(slots=True) class SourceAdapter: """Adapter to allow sources and their flows to be used as sensors.""" diff --git a/homeassistant/components/energy/validate.py b/homeassistant/components/energy/validate.py index 0a89c3d9270..f1eb7591e83 100644 --- a/homeassistant/components/energy/validate.py +++ b/homeassistant/components/energy/validate.py @@ -107,7 +107,7 @@ def _get_placeholders(hass: HomeAssistant, issue_type: str) -> dict[str, str] | return None -@dataclasses.dataclass +@dataclasses.dataclass(slots=True) class ValidationIssue: """Error or warning message.""" @@ -118,7 +118,7 @@ class ValidationIssue: translation_placeholders: dict[str, str] | None = None -@dataclasses.dataclass +@dataclasses.dataclass(slots=True) class ValidationIssues: """Container for validation issues.""" @@ -142,7 +142,7 @@ class ValidationIssues: issue.affected_entities.add((affected_entity, detail)) -@dataclasses.dataclass +@dataclasses.dataclass(slots=True) class EnergyPreferencesValidation: """Dictionary holding validation information.""" diff --git a/homeassistant/components/hardware/models.py b/homeassistant/components/hardware/models.py index 801bc9b923a..6b852291323 100644 --- a/homeassistant/components/hardware/models.py +++ b/homeassistant/components/hardware/models.py @@ -7,7 +7,7 @@ from typing import Protocol from homeassistant.core import HomeAssistant, callback -@dataclass +@dataclass(slots=True) class BoardInfo: """Board info type.""" @@ -17,7 +17,7 @@ class BoardInfo: revision: str | None -@dataclass(frozen=True) +@dataclass(slots=True, frozen=True) class USBInfo: """USB info type.""" @@ -28,7 +28,7 @@ class USBInfo: description: str | None -@dataclass(frozen=True) +@dataclass(slots=True, frozen=True) class HardwareInfo: """Hardware info type.""" diff --git a/homeassistant/components/hardware/websocket_api.py b/homeassistant/components/hardware/websocket_api.py index 66b90edc893..918c96c5643 100644 --- a/homeassistant/components/hardware/websocket_api.py +++ b/homeassistant/components/hardware/websocket_api.py @@ -20,7 +20,7 @@ from .hardware import async_process_hardware_platforms from .models import HardwareProtocol -@dataclass +@dataclass(slots=True) class SystemStatus: """System status.""" diff --git a/homeassistant/components/history/websocket_api.py b/homeassistant/components/history/websocket_api.py index 9c6cc12eb40..053e006c13b 100644 --- a/homeassistant/components/history/websocket_api.py +++ b/homeassistant/components/history/websocket_api.py @@ -41,7 +41,7 @@ from .helpers import entities_may_have_state_changes_after _LOGGER = logging.getLogger(__name__) -@dataclass +@dataclass(slots=True) class HistoryLiveStream: """Track a history live stream.""" diff --git a/homeassistant/components/homeassistant_alerts/__init__.py b/homeassistant/components/homeassistant_alerts/__init__.py index ffc0594baf3..8b04f845709 100644 --- a/homeassistant/components/homeassistant_alerts/__init__.py +++ b/homeassistant/components/homeassistant_alerts/__init__.py @@ -106,7 +106,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: return True -@dataclasses.dataclass(frozen=True) +@dataclasses.dataclass(slots=True, frozen=True) class IntegrationAlert: """Issue Registry Entry.""" diff --git a/homeassistant/components/logbook/models.py b/homeassistant/components/logbook/models.py index ab073f296f7..e894b19c4d9 100644 --- a/homeassistant/components/logbook/models.py +++ b/homeassistant/components/logbook/models.py @@ -22,7 +22,7 @@ from homeassistant.util.json import json_loads from homeassistant.util.ulid import ulid_to_bytes -@dataclass +@dataclass(slots=True) class LogbookConfig: """Configuration for the logbook integration.""" @@ -95,7 +95,7 @@ class LazyEventPartialState: return bytes_to_ulid_or_none(self.context_parent_id_bin) -@dataclass(frozen=True) +@dataclass(slots=True, frozen=True) class EventAsRow: """Convert an event to a row.""" diff --git a/homeassistant/components/logbook/processor.py b/homeassistant/components/logbook/processor.py index 7d0eec5eb6d..967d0f27ed2 100644 --- a/homeassistant/components/logbook/processor.py +++ b/homeassistant/components/logbook/processor.py @@ -61,7 +61,7 @@ from .queries import statement_for_request from .queries.common import PSEUDO_EVENT_STATE_CHANGED -@dataclass +@dataclass(slots=True) class LogbookRun: """A logbook run which may be a long running event stream or single request.""" diff --git a/homeassistant/components/logbook/websocket_api.py b/homeassistant/components/logbook/websocket_api.py index 6d24285ba11..cbcf0e413f6 100644 --- a/homeassistant/components/logbook/websocket_api.py +++ b/homeassistant/components/logbook/websocket_api.py @@ -39,7 +39,7 @@ BIG_QUERY_RECENT_HOURS = 24 _LOGGER = logging.getLogger(__name__) -@dataclass +@dataclass(slots=True) class LogbookLiveStream: """Track a logbook live stream.""" diff --git a/homeassistant/components/logger/helpers.py b/homeassistant/components/logger/helpers.py index df275eaae93..0f1751c1b2e 100644 --- a/homeassistant/components/logger/helpers.py +++ b/homeassistant/components/logger/helpers.py @@ -77,7 +77,7 @@ async def get_integration_loggers(hass: HomeAssistant, domain: str) -> set[str]: return loggers -@dataclass +@dataclass(slots=True) class LoggerSetting: """Settings for a single module or integration.""" @@ -86,7 +86,7 @@ class LoggerSetting: type: str -@dataclass +@dataclass(slots=True) class LoggerDomainConfig: """Logger domain config.""" diff --git a/homeassistant/components/media_source/models.py b/homeassistant/components/media_source/models.py index 3bf77daf691..cbe71447a3f 100644 --- a/homeassistant/components/media_source/models.py +++ b/homeassistant/components/media_source/models.py @@ -11,7 +11,7 @@ from homeassistant.core import HomeAssistant, callback from .const import DOMAIN, URI_SCHEME, URI_SCHEME_REGEX -@dataclass +@dataclass(slots=True) class PlayMedia: """Represents a playable media.""" @@ -36,7 +36,7 @@ class BrowseMediaSource(BrowseMedia): self.identifier = identifier -@dataclass +@dataclass(slots=True) class MediaSourceItem: """A parsed media item.""" diff --git a/homeassistant/components/script/__init__.py b/homeassistant/components/script/__init__.py index cbfd73e486e..9c4137c1bea 100644 --- a/homeassistant/components/script/__init__.py +++ b/homeassistant/components/script/__init__.py @@ -231,7 +231,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: return True -@dataclass +@dataclass(slots=True) class ScriptEntityConfig: """Container for prepared script entity configuration.""" diff --git a/homeassistant/components/system_health/__init__.py b/homeassistant/components/system_health/__init__.py index 9f45108d61e..3d149b3a40d 100644 --- a/homeassistant/components/system_health/__init__.py +++ b/homeassistant/components/system_health/__init__.py @@ -188,7 +188,7 @@ async def handle_info( ) -@dataclasses.dataclass() +@dataclasses.dataclass(slots=True) class SystemHealthRegistration: """Helper class to track platform registration.""" diff --git a/homeassistant/components/webhook/trigger.py b/homeassistant/components/webhook/trigger.py index 48e484db4a1..8c6051cc4a1 100644 --- a/homeassistant/components/webhook/trigger.py +++ b/homeassistant/components/webhook/trigger.py @@ -49,7 +49,7 @@ TRIGGER_SCHEMA = cv.TRIGGER_BASE_SCHEMA.extend( WEBHOOK_TRIGGERS = f"{DOMAIN}_triggers" -@dataclass +@dataclass(slots=True) class TriggerInstance: """Attached trigger settings."""