Home Assistant Unofficial Reference 2024.12.1
types.py
Go to the documentation of this file.
1 """Common code for permissions."""
2 
3 from collections.abc import Mapping
4 
5 # MyPy doesn't support recursion yet. So writing it out as far as we need.
6 
7 type ValueType = (
8  # Example: entities.all = { read: true, control: true }
9  Mapping[str, bool] | bool | None
10 )
11 
12 # Example: entities.domains = { light: … }
13 type SubCategoryDict = Mapping[str, ValueType]
14 
15 type SubCategoryType = SubCategoryDict | bool | None
16 
17 type CategoryType = (
18  # Example: entities.domains
19  Mapping[str, SubCategoryType]
20  # Example: entities.all
21  | Mapping[str, ValueType]
22  | bool
23  | None
24 )
25 
26 # Example: { entities: … }
27 type PolicyType = Mapping[str, CategoryType]