Coverage for src/homeassistant_repl/plugin.py: 0%
12 statements
« prev ^ index » next coverage.py v7.17.2, created at 2026-11-17 19:05 +0000
« prev ^ index » next coverage.py v7.17.2, created at 2026-11-17 19:05 +0000
1"""The names a shell puts in a session before plugins run, declared for
2linters and type checkers - nothing is bound here, so import them only
3where a type checker looks:
5 from typing import TYPE_CHECKING
7 if TYPE_CHECKING:
8 from homeassistant_repl.plugin import MODE, hass, obj # noqa: TC004
10See docs/configuration/plugins.md. `homeassistant` isn't a dependency of
11this package; `hass` is typed wherever the checker can find it, which is any
12component's own development environment.
13"""
15from __future__ import annotations
17from collections.abc import Callable
18from typing import TYPE_CHECKING, Any, Literal
20if TYPE_CHECKING:
21 from homeassistant.core import HomeAssistant
22 from homeassistant_api import AsyncClient
24 from .sql import SqlTool
26__all__ = ["MODE", "SERVER", "hass", "hass_api", "obj", "rebind", "show", "sql"]
28MODE: Literal["live", "exec", "api"]
29SERVER: str | None # the configured server's name, None if connected by URL
31# live and exec only - a statement using it runs inside Home Assistant
32hass: HomeAssistant
34# The server's own tree in live and exec, ApiObjTree in api - alike, not identical.
35obj: Any
37# live and exec only
38sql: SqlTool
40# Looks inside an object, on whichever side the object is
41show: Callable[..., Any]
43# Puts back any of these names that has been assigned over, and runs the
44# plugins again unless plugins=False
45rebind: Callable[..., Any]
47# None in api mode if the REST API couldn't be reached
48hass_api: AsyncClient | None