Skip to content

Commit be2ec71

Browse files
authored
Modernize StrEnum usage (#233)
1 parent e5c7152 commit be2ec71

3 files changed

Lines changed: 15 additions & 15 deletions

File tree

homeassistant_api/models/config_entries.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
"""File for models used in responses from config entries."""
22

3-
from enum import Enum
3+
from enum import StrEnum
44
from typing import Any
55

66
from .base import BaseModel
77

88

9-
class FlowResultType(Enum):
9+
class FlowResultType(StrEnum):
1010
"""Result type for a data entry flow."""
1111

1212
FORM = "form"
@@ -79,7 +79,7 @@ class DisableEnableResult(BaseModel):
7979
require_restart: bool
8080

8181

82-
class IntegrationTypes(Enum):
82+
class IntegrationTypes(StrEnum):
8383
"""Types of integrations."""
8484

8585
ENTITY = "entity"
@@ -92,7 +92,7 @@ class IntegrationTypes(Enum):
9292
VIRTUAL = "virtual"
9393

9494

95-
class ConfigEntryState(str, Enum):
95+
class ConfigEntryState(StrEnum):
9696
"""Config entry state."""
9797

9898
LOADED = "loaded"
@@ -105,7 +105,7 @@ class ConfigEntryState(str, Enum):
105105
UNLOAD_IN_PROGRESS = "unload_in_progress"
106106

107107

108-
class ConfigEntryDisabler(Enum):
108+
class ConfigEntryDisabler(StrEnum):
109109
"""What disabled a config entry."""
110110

111111
USER = "user"
@@ -144,7 +144,7 @@ class ConfigSubEntry(BaseModel):
144144
unique_id: str | None
145145

146146

147-
class ConfigEntryChange(str, Enum):
147+
class ConfigEntryChange(StrEnum):
148148
"""What was changed in a config entry."""
149149

150150
ADDED = "added"

homeassistant_api/models/domains.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from __future__ import annotations
44

5-
from enum import Enum
5+
from enum import StrEnum
66
from typing import TYPE_CHECKING
77
from typing import Any
88
from typing import cast
@@ -159,25 +159,25 @@ class SelectBoxOptionImage(BaseModel):
159159
flip_rtl: bool | None = None
160160

161161

162-
class ServiceFieldSelectorNumberMode(str, Enum):
162+
class ServiceFieldSelectorNumberMode(StrEnum):
163163
BOX = "box"
164164
SLIDER = "slider"
165165

166166

167-
class ServiceFieldSelectorSelectMode(str, Enum):
167+
class ServiceFieldSelectorSelectMode(StrEnum):
168168
LIST = "list"
169169
DROPDOWN = "dropdown"
170170
BOX = "box"
171171

172172

173-
class ServiceFieldSelectorQRCodeErrorCorrectionLevel(str, Enum):
173+
class ServiceFieldSelectorQRCodeErrorCorrectionLevel(StrEnum):
174174
LOW = "low"
175175
MEDIUM = "medium"
176176
QUARTILE = "quartile"
177177
HIGH = "high"
178178

179179

180-
class ServiceFieldSelectorTextType(str, Enum):
180+
class ServiceFieldSelectorTextType(StrEnum):
181181
NUMBER = "number"
182182
TEXT = "text"
183183
SEARCH = "search"

homeassistant_api/models/entity_registry.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Models for Home Assistant entity registry responses."""
22

3-
from enum import Enum
3+
from enum import StrEnum
44
from typing import Any
55
from typing import TypedDict
66

@@ -11,7 +11,7 @@
1111
from .base import DatetimeIsoField
1212

1313

14-
class EntityDisabledBy(str, Enum):
14+
class EntityDisabledBy(StrEnum):
1515
"""What disabled an entity."""
1616

1717
CONFIG_ENTRY = "config_entry"
@@ -21,14 +21,14 @@ class EntityDisabledBy(str, Enum):
2121
USER = "user"
2222

2323

24-
class EntityHiddenBy(str, Enum):
24+
class EntityHiddenBy(StrEnum):
2525
"""What hid an entity."""
2626

2727
INTEGRATION = "integration"
2828
USER = "user"
2929

3030

31-
class EntityCategory(str, Enum):
31+
class EntityCategory(StrEnum):
3232
"""Category of an entity."""
3333

3434
CONFIG = "config"

0 commit comments

Comments
 (0)