-
Notifications
You must be signed in to change notification settings - Fork 34
Improve enum structure #1925
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: v2/main
Are you sure you want to change the base?
Improve enum structure #1925
Conversation
* Bump minimum required Python version to 3.12 * Update CI/CD
…oup for Execution typing (#1864) * Rename scenario to action group * Rename test * Fix docstring formatting in ActionGroup class * Remove unnecessary assertions in ActionGroup initialization
…methods. (#1862) - `client.execute_command()` and `client.execute_commands()` are replaced by `client.execute_action_group()` - `client.execute_action_group()` now supports multiple execution modes (high priority, internal, geolocated) - `client.execute_action_group()` now supports multiple device actions in the same request The current execution methods are poorly typed and do not support concurrent execution across multiple devices, which makes it impossible to properly work around TooManyExecutionsException and TooManyConcurrentRequestsException. The main change is the move from `client.execute_command()` and `client.execute_commands()` to a single `client.execute_action_group()`. An action group takes a list of actions, each of which can include multiple device actions, including multiple commands per action. ```python3 await client.execute_action_group( actions=[ Action( device_url="io://1234-5678-1234/12345678", commands=[ Command(name="down"), Command(name="refresh") ] ) ], label="Execution via Home Assistant" ) ``` New (mode) options like high priority will be possible now: ```python3 await client.execute_action_group( actions=[ Action( device_url="io://1234-5678-1234/12345678", commands=[ Command(name=OverkizCommand.SET_CLOSURE, parameters=[0]) ] ) ], label="Execution via Home Assistant", mode=CommandMode.HIGH_PRIORITY ) ``` This could serve as a foundation for grouping commands that are executed within a short time window, for example when triggered by a scene or automation in Home Assistant. Requests issued close together could be batched and sent as a single action group, reducing the impact of current Overkiz limitations. The open question is where this queue should live: inside this integration itself, or as part of the Home Assistant core implementation. --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…ial classes (#1867) - Introduced UsernamePasswordCredentials and LocalTokenCredentials for better credential management. - Updated OverkizClient to utilize the new credential classes and refactored login logic. - Added authentication strategies for various servers, including Somfy and Rexel. - Created new modules for auth strategies and credentials to improve code organization. - Enhanced README with updated usage examples for the new authentication methods. - `OverkizServer` class is renamed to `ServerConfig` and has additional `server` and `type` (cloud/local) property - `generate_local_server` is renamed to `create_local_server_config` - `client.api_type` is removed and now available via `ServerConfig` (e.g. `client.server_config.type`) - The `OverkizClient` constructor now requires passing a `ServerConfig` via `server` - The `OverkizClient` constructur now requires passing an `Credentials` class via `credentials`, e.g. `UsernamePasswordCredentials(USERNAME, PASSWORD)` for most server. - The OverkizClient constructor now supports passing a Server enum directly, such as `OverkizClient(server=Server.SOMFY_EUROPE, ...)`. --------- Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: iMicknl <1424596+iMicknl@users.noreply.github.com>
## Enhancement - Publish detailed developer documentation via GitHub Pages [imicknl.github.io/python-overkiz-api](https://imicknl.github.io/python-overkiz-api/). Fixes #190, #1522
…ty (#1917) Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Fixes #1865 --------- Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: iMicknl <1424596+iMicknl@users.noreply.github.com>
…prove module imports
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR refactors the enum structure by introducing a shared UnknownEnumMixin class to eliminate duplicated _missing_ method implementations across multiple enum files. The refactoring consolidates common enum fallback behavior and logging into a reusable mixin.
Changes:
- Introduces
UnknownEnumMixininpyoverkiz/enums/base.pyto provide shared_missing_andfrom_valuemethods - Migrates 8 enum classes across 5 files to use the new mixin (UIClass, UIWidget, Protocol, FailureType, EventName, GatewayType, GatewaySubType, ExecutionType, ExecutionState, ExecutionSubType)
- Updates
pyoverkiz/enums/__init__.pyto explicitly construct__all__by filtering Enum subclasses
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 20 comments.
Show a summary per file
| File | Description |
|---|---|
| pyoverkiz/enums/base.py | New file introducing UnknownEnumMixin with shared missing and from_value methods |
| pyoverkiz/enums/ui.py | Adds UnknownEnumMixin to UIClass and UIWidget, removes logging imports and UIClass's missing method |
| pyoverkiz/enums/protocol.py | Adds UnknownEnumMixin to Protocol, removes logging imports and missing method, adds custom missing_message |
| pyoverkiz/enums/general.py | Adds UnknownEnumMixin to FailureType and EventName, removes logging imports and FailureType's missing method |
| pyoverkiz/enums/gateway.py | Adds UnknownEnumMixin to GatewayType and GatewaySubType, removes logging imports and their missing methods |
| pyoverkiz/enums/execution.py | Adds UnknownEnumMixin to ExecutionType, ExecutionState, and ExecutionSubType, removes logging imports and their missing methods |
| pyoverkiz/enums/init.py | Constructs explicit all list by filtering Enum subclasses from enum modules |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated 10 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…um with labels, and implement protocol enum generation script
…type to list[str]
- Implemented `generate_ui_profiles` function to fetch and generate UIProfile enums. - Added error handling for fetching profile details. - Included detailed comments for commands and states in the generated enum. - Updated the main generation function to include UIProfile generation.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…improved type hinting
…t UI profile fetching in generate_enums
|
@copilot do a thorough review and fix all your suggestions in a new PR. Make sure the CI is green (so run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 13 out of 13 changed files in this pull request and generated 16 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…nt 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>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
The `UnknownEnumMixin._missing_` method overrides `StrEnum._missing_`
but lacked explicit acknowledgment, causing type checker ambiguity about
the intentional override in the mixin pattern.
## Changes
- Added `# type: ignore[override]` to `_missing_` method signature
- Enhanced docstring to document the intentional override of
`StrEnum._missing_`
- Removed unused `Any` import
## Context
Mixin classes can't use `@override` decorator since they don't directly
inherit from the classes they'll be mixed with. The type ignore
annotation is the standard pattern for acknowledging overrides in
mixins.
```python
class UnknownEnumMixin:
@classmethod
def _missing_(cls, value: object) -> Self: # type: ignore[override]
"""Return `UNKNOWN` and log unrecognized values.
Intentionally overrides `StrEnum._missing_` to provide UNKNOWN fallback.
"""
# ... implementation
```
<!-- START COPILOT CODING AGENT TIPS -->
---
💡 You can make Copilot smarter by setting up custom instructions,
customizing its development environment and configuring Model Context
Protocol (MCP) servers. Learn more [Copilot coding agent
tips](https://gh.io/copilot-coding-agent-tips) in the docs.
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: iMicknl <1424596+iMicknl@users.noreply.github.com>
Co-authored-by: Mick Vleeshouwer <mick@imick.nl>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
No description provided.