Skip to content

Commit d032395

Browse files
CopilotiMicknl
andauthored
Address code review feedback: fix import pollution and remove redundant enum conversion (#1926)
## Progress Plan - [x] Add missing UIClassifier enum to exports - [x] Revert to simpler approach without explicit enum conversion (maintainer preference) - [x] Verify all linting and type checking passes - [x] Test functionality works correctly <!-- START COPILOT CODING AGENT TIPS --> --- ✨ Let Copilot coding agent [set things up for you](https://github.com/iMicknl/python-overkiz-api/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot) — coding agent works faster and does higher quality work when set up for your repo. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: iMicknl <1424596+iMicknl@users.noreply.github.com>
1 parent b8a8369 commit d032395

2 files changed

Lines changed: 43 additions & 49 deletions

File tree

pyoverkiz/enums/__init__.py

Lines changed: 40 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,43 @@
11
"""Convenience re-exports for the enums package."""
22

3-
# flake8: noqa: F403
4-
5-
from enum import Enum
6-
7-
from pyoverkiz.enums import command as _command
8-
from pyoverkiz.enums import execution as _execution
9-
from pyoverkiz.enums import gateway as _gateway
10-
from pyoverkiz.enums import general as _general
11-
from pyoverkiz.enums import measured_value_type as _measured_value_type
12-
from pyoverkiz.enums import protocol as _protocol
13-
from pyoverkiz.enums import server as _server
14-
from pyoverkiz.enums import state as _state
15-
from pyoverkiz.enums import ui as _ui
16-
from pyoverkiz.enums import ui_profile as _ui_profile
17-
from pyoverkiz.enums.command import *
18-
from pyoverkiz.enums.execution import *
19-
from pyoverkiz.enums.gateway import *
20-
from pyoverkiz.enums.general import *
21-
from pyoverkiz.enums.measured_value_type import *
22-
from pyoverkiz.enums.protocol import *
23-
from pyoverkiz.enums.server import *
24-
from pyoverkiz.enums.state import *
25-
from pyoverkiz.enums.ui import *
26-
from pyoverkiz.enums.ui_profile import *
27-
28-
__all__ = sorted(
29-
{
30-
name
31-
for module in (
32-
_command,
33-
_execution,
34-
_gateway,
35-
_general,
36-
_measured_value_type,
37-
_protocol,
38-
_server,
39-
_state,
40-
_ui,
41-
_ui_profile,
42-
)
43-
for name, obj in vars(module).items()
44-
if isinstance(obj, type) and issubclass(obj, Enum)
45-
}
3+
# Explicitly re-export all Enum subclasses to avoid wildcard import issues
4+
from pyoverkiz.enums.command import CommandMode, OverkizCommand, OverkizCommandParam
5+
from pyoverkiz.enums.execution import (
6+
ExecutionState,
7+
ExecutionSubType,
8+
ExecutionType,
469
)
10+
from pyoverkiz.enums.gateway import GatewaySubType, GatewayType, UpdateBoxStatus
11+
from pyoverkiz.enums.general import DataType, EventName, FailureType, ProductType
12+
from pyoverkiz.enums.measured_value_type import MeasuredValueType
13+
from pyoverkiz.enums.protocol import Protocol
14+
from pyoverkiz.enums.server import APIType, Server
15+
from pyoverkiz.enums.state import OverkizAttribute, OverkizState
16+
from pyoverkiz.enums.ui import UIClass, UIClassifier, UIWidget
17+
from pyoverkiz.enums.ui_profile import UIProfile
18+
19+
__all__ = [
20+
"APIType",
21+
"CommandMode",
22+
"DataType",
23+
"EventName",
24+
"ExecutionState",
25+
"ExecutionSubType",
26+
"ExecutionType",
27+
"FailureType",
28+
"GatewaySubType",
29+
"GatewayType",
30+
"MeasuredValueType",
31+
"OverkizAttribute",
32+
"OverkizCommand",
33+
"OverkizCommandParam",
34+
"OverkizState",
35+
"ProductType",
36+
"Protocol",
37+
"Server",
38+
"UIClass",
39+
"UIClassifier",
40+
"UIProfile",
41+
"UIWidget",
42+
"UpdateBoxStatus",
43+
]

pyoverkiz/utils.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,14 @@ def create_server_config(
3737
configuration_url: str | None = None,
3838
) -> ServerConfig:
3939
"""Generate server configuration with the provided endpoint and metadata."""
40-
resolved_server = (
41-
server if isinstance(server, Server) or server is None else Server(server)
42-
)
43-
resolved_type = type if isinstance(type, APIType) else APIType(type)
40+
# ServerConfig.__init__ accepts str | enum types and converts them internally
4441
return ServerConfig(
45-
server=resolved_server,
42+
server=server, # type: ignore[arg-type]
4643
name=name,
4744
endpoint=endpoint,
4845
manufacturer=manufacturer,
4946
configuration_url=configuration_url,
50-
type=resolved_type,
47+
type=type, # type: ignore[arg-type]
5148
)
5249

5350

0 commit comments

Comments
 (0)