diff --git a/homeassistant/components/recorder/db_schema.py b/homeassistant/components/recorder/db_schema.py index 2afbed9cb7534ce2679d924b68f1d83ea64cf3ea..cefce9c4e72da871b35f6355c926d3ad11a5cb40 100644 --- a/homeassistant/components/recorder/db_schema.py +++ b/homeassistant/components/recorder/db_schema.py @@ -6,7 +6,7 @@ from collections.abc import Callable from datetime import datetime, timedelta import logging import time -from typing import Any, Final, Self, cast +from typing import Any, Final, Protocol, Self, cast import ciso8601 from fnv_hash_fast import fnv1a_32 @@ -233,10 +233,14 @@ CONTEXT_BINARY_TYPE = LargeBinary(CONTEXT_ID_BIN_MAX_LENGTH).with_variant( TIMESTAMP_TYPE = DOUBLE_TYPE +class _LiteralProcessorType(Protocol): + def __call__(self, value: Any) -> str: ... + + class JSONLiteral(JSON): """Teach SA how to literalize json.""" - def literal_processor(self, dialect: Dialect) -> Callable[[Any], str]: + def literal_processor(self, dialect: Dialect) -> _LiteralProcessorType: """Processor to convert a value to JSON.""" def process(value: Any) -> str: diff --git a/homeassistant/components/recorder/migration.py b/homeassistant/components/recorder/migration.py index 8c9252ba28bbd24348c4624d0c998bb879d2b224..6ae1e2659010293ffba86c7a1738d05a6d7bf8e7 100644 --- a/homeassistant/components/recorder/migration.py +++ b/homeassistant/components/recorder/migration.py @@ -2453,7 +2453,7 @@ class BaseMigration(ABC): self.migration_changes = migration_changes @abstractmethod - def migrate_data(self, instance: Recorder) -> bool: + def migrate_data(self, instance: Recorder, /) -> bool: """Migrate some data, return True if migration is completed.""" def _migrate_data(self, instance: Recorder) -> bool: