Skip to content

Commit

Permalink
Use inline TypedDict for nested TypedDicts
Browse files Browse the repository at this point in the history
  • Loading branch information
cdce8p committed Dec 6, 2024
1 parent 800de10 commit 508fe77
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 52 deletions.
29 changes: 14 additions & 15 deletions homeassistant/helpers/area_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,24 +41,23 @@
STORAGE_VERSION_MINOR = 7


class _AreaStoreData(TypedDict):
"""Data type for individual area. Used in AreasRegistryStoreData."""

aliases: list[str]
floor_id: str | None
icon: str | None
id: str
labels: list[str]
name: str
picture: str | None
created_at: str
modified_at: str


# ruff: noqa: F821,UP037
class AreasRegistryStoreData(TypedDict):
"""Store data type for AreaRegistry."""

areas: list[_AreaStoreData]
areas: list[
{
"aliases": list[str],
"floor_id": str | None,
"icon": str | None,
"id": str,
"labels": list[str],
"name": str,
"picture": str | None,
"created_at": str,
"modified_at": str,
}
]


class EventAreaRegistryUpdatedData(TypedDict):
Expand Down
24 changes: 13 additions & 11 deletions homeassistant/helpers/category_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,22 @@
STORAGE_VERSION_MINOR = 2


class _CategoryStoreData(TypedDict):
"""Data type for individual category. Used in CategoryRegistryStoreData."""

category_id: str
created_at: str
icon: str | None
modified_at: str
name: str


# ruff: noqa: F821,UP037
class CategoryRegistryStoreData(TypedDict):
"""Store data type for CategoryRegistry."""

categories: dict[str, list[_CategoryStoreData]]
categories: dict[
str,
list[
{
"category_id": str,
"created_at": str,
"icon": str | None,
"modified_at": str,
"name": str,
}
],
]


class EventCategoryRegistryUpdatedData(TypedDict):
Expand Down
25 changes: 12 additions & 13 deletions homeassistant/helpers/floor_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,21 @@
STORAGE_VERSION_MINOR = 2


class _FloorStoreData(TypedDict):
"""Data type for individual floor. Used in FloorRegistryStoreData."""

aliases: list[str]
floor_id: str
icon: str | None
level: int | None
name: str
created_at: str
modified_at: str


# ruff: noqa: F821,UP037
class FloorRegistryStoreData(TypedDict):
"""Store data type for FloorRegistry."""

floors: list[_FloorStoreData]
floors: list[
{
"aliases": list[str],
"floor_id": str,
"icon": str | None,
"level": int | None,
"name": str,
"created_at": str,
"modified_at": str,
}
]


class EventFloorRegistryUpdatedData(TypedDict):
Expand Down
25 changes: 12 additions & 13 deletions homeassistant/helpers/label_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,21 @@
STORAGE_VERSION_MINOR = 2


class _LabelStoreData(TypedDict):
"""Data type for individual label. Used in LabelRegistryStoreData."""

color: str | None
description: str | None
icon: str | None
label_id: str
name: str
created_at: str
modified_at: str


# ruff: noqa: F821,UP037
class LabelRegistryStoreData(TypedDict):
"""Store data type for LabelRegistry."""

labels: list[_LabelStoreData]
labels: list[
{
"color": str | None,
"description": str | None,
"icon": str | None,
"label_id": str,
"name": str,
"created_at": str,
"modified_at": str,
}
]


class EventLabelRegistryUpdatedData(TypedDict):
Expand Down

0 comments on commit 508fe77

Please sign in to comment.