-
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
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.