Skip to content

Commit ca56bea

Browse files
CopilotiMicknl
andcommitted
Add missing UIClassifier enum and restore explicit enum conversion
- Add UIClassifier to enum exports (was accidentally omitted) - Restore explicit enum conversion in create_server_config for type safety - While ServerConfig.__init__ does convert, explicit conversion is safer and clearer Co-authored-by: iMicknl <1424596+iMicknl@users.noreply.github.com>
1 parent 0fdaa29 commit ca56bea

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

pyoverkiz/enums/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from pyoverkiz.enums.protocol import Protocol
1414
from pyoverkiz.enums.server import APIType, Server
1515
from pyoverkiz.enums.state import OverkizAttribute, OverkizState
16-
from pyoverkiz.enums.ui import UIClass, UIWidget
16+
from pyoverkiz.enums.ui import UIClass, UIClassifier, UIWidget
1717
from pyoverkiz.enums.ui_profile import UIProfile
1818

1919
__all__ = [
@@ -36,6 +36,7 @@
3636
"Protocol",
3737
"Server",
3838
"UIClass",
39+
"UIClassifier",
3940
"UIProfile",
4041
"UIWidget",
4142
"UpdateBoxStatus",

pyoverkiz/utils.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,19 @@ def create_server_config(
3737
configuration_url: str | None = None,
3838
) -> ServerConfig:
3939
"""Generate server configuration with the provided endpoint and metadata."""
40-
# ServerConfig.__init__ accepts str | enum types and converts them internally
40+
# Explicitly convert string values to enums to ensure type safety
41+
# even though ServerConfig.__init__ also handles this conversion
42+
resolved_server = (
43+
server if isinstance(server, Server) or server is None else Server(server)
44+
)
45+
resolved_type = type if isinstance(type, APIType) else APIType(type)
4146
return ServerConfig(
42-
server=server, # type: ignore[arg-type]
47+
server=resolved_server,
4348
name=name,
4449
endpoint=endpoint,
4550
manufacturer=manufacturer,
4651
configuration_url=configuration_url,
47-
type=type, # type: ignore[arg-type]
52+
type=resolved_type,
4853
)
4954

5055

0 commit comments

Comments
 (0)