Skip to content

Commit 413e990

Browse files
authored
Fix/type annotations (#211)
* correct missing/old references in state_manage.pyi * update changelog * bump version * fix init method type annotation
1 parent 6edee36 commit 413e990

File tree

4 files changed

+34
-13
lines changed

4 files changed

+34
-13
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## Unreleased
99

10+
## [0.19.1] - 2026-01-25
11+
12+
### Fixed
13+
- Update `state_manager.pyi` to fix type hints
14+
1015
## [0.19.0] - 2026-01-25
1116

1217
### Fixed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "uv_build"
44

55
[project]
66
name = "hassette"
7-
version = "0.19.0"
7+
version = "0.19.1"
88
description = "Hassette is a simple, modern, async-first Python framework for building Home Assistant automations."
99
readme = "README.md"
1010
authors = [{ name = "Jessica", email = "12jessicasmith34@gmail.com" }]

src/hassette/state_manager/state_manager.pyi

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,46 @@ For custom domains not listed here, users should use:
99
"""
1010

1111
import typing
12+
from collections.abc import Iterator
13+
from typing import Generic, NamedTuple
14+
15+
from frozendict import frozendict
1216

1317
from hassette.models import states
14-
from hassette.models.states import BaseState, StateT
18+
from hassette.models.states import StateT
1519
from hassette.resources.base import Resource
1620

1721
if typing.TYPE_CHECKING:
1822
from hassette import Hassette
1923
from hassette.core.state_proxy import StateProxy
24+
from hassette.events import HassStateDict
2025

21-
class _TypedStateGetter(typing.Generic[StateT]):
22-
def __init__(self, proxy: StateProxy, model: type[StateT]): ...
23-
def __call__(self, entity_id: str) -> StateT: ...
24-
def get(self, entity_id: str) -> StateT | None: ...
25-
26-
class _StateGetter:
27-
def __init__(self, proxy: StateProxy): ...
28-
def __getitem__(self, model: type[StateT]) -> _TypedStateGetter[StateT]: ...
26+
class CacheValue(Generic[StateT], NamedTuple):
27+
context_id: str | None
28+
frozen_state: frozendict
29+
model: StateT
2930

3031
class DomainStates(typing.Generic[StateT]):
31-
def __init__(self, states_dict: dict[str, BaseState], domain: str) -> None: ...
32+
_state_proxy: StateProxy
33+
_model: type[StateT]
34+
_domain: str
35+
_cache: dict[str, CacheValue[StateT]]
36+
37+
def _validate_or_return_from_cache(self, entity_id: str, state: HassStateDict) -> StateT: ...
38+
def __init__(self, state_proxy: StateProxy, model: type[StateT]) -> None: ...
3239
def __iter__(self) -> typing.Generator[tuple[str, StateT], typing.Any, None]: ...
3340
def __len__(self) -> int: ...
34-
def get(self, entity_id: str) -> StateT | None: ...
3541
def __getitem__(self, entity_id: str) -> StateT: ...
42+
def __contains__(self, entity_id: str) -> bool: ...
43+
def __repr__(self) -> str: ...
44+
def __bool__(self) -> bool: ...
45+
def get(self, entity_id: str) -> StateT | None: ...
46+
def items(self) -> Iterator[tuple[str, StateT]]: ...
47+
def keys(self) -> list[str]: ...
48+
def iterkeys(self) -> typing.Iterator[str]: ...
49+
def values(self) -> list[StateT]: ...
50+
def itervalues(self) -> Iterator[StateT]: ...
51+
def to_dict(self) -> dict[str, StateT]: ...
3652

3753
class StateManager(Resource):
3854
"""Resource for managing Home Assistant states.

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)