fix: pass type(self) to get_type_hints for Python 3.14 compatibility - #15
Merged
Merged
Conversation
Copilot
AI
changed the title
[WIP] Fix TypeError when instantiating _Base subclasses in Python 3.14
fix: pass type(self) to get_type_hints for Python 3.14 compatibility
Jul 30, 2026
There was a problem hiding this comment.
Pull request overview
This PR restores compatibility with Python 3.14 by updating _Base.__init__ to retrieve type hints from the class (type(self)) rather than the instance, avoiding a TypeError introduced by Python 3.14’s annotation handling changes. It also refreshes the PyPI publish workflow’s Python setup step.
Changes:
- Fix
_Base.__init__to calltyping.get_type_hints(type(self)), preventing Python 3.14 instantiation failures for_Basesubclasses. - Update GitHub Actions
setup-pythonfromv1tov5and adjust the workflow’s Python version.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
wdapy/_types.py |
Uses class-based type-hint lookup to keep _Base subclass initialization working on Python 3.14. |
.github/workflows/publish_to_pypi.yml |
Updates Python setup action version and the configured runtime version for the workflow. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+12
to
15
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: 3.9 | ||
| python-version: '3.10' | ||
| cache: 'pip' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In Python 3.14,
__annotations__became a data descriptor ontype, sotyping.get_type_hints(instance)raisesTypeError: '<ClassName> does not have annotations'instead of falling back to the class. This broke instantiation of all_Basesubclasses (StatusInfo,AppInfo,DeviceInfo,BatteryInfo, etc.).Change
wdapy/_types.py—_Base.__init__: passtype(self)instead ofselftotyping.get_type_hints.