dataclasses: remove HasDataclassFields type parameter, use ClassVar#548
dataclasses: remove HasDataclassFields type parameter, use ClassVar#548jorenham merged 8 commits intojorenham:masterfrom
dataclasses: remove HasDataclassFields type parameter, use ClassVar#548Conversation
Removed unused imports and updated import statements for compatibility with Python versions.
There was a problem hiding this comment.
Pull request overview
Updates the optype.dataclasses.HasDataclassFields runtime protocol to remove its generic type parameter and to model __dataclass_fields__ as a class attribute, aligning the protocol more closely with how dataclasses expose metadata.
Changes:
- Deparametrized
HasDataclassFields(removedTypeVar/Mapping-based generic parameter). - Marked
HasDataclassFields.__dataclass_fields__(and the test fake) asClassVar[...]. - Adjusted tests around
isinstance/issubclasschecks and added/updated type-checker ignores.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
optype/dataclasses.py |
Removes generic parameterization and makes __dataclass_fields__ a ClassVar on the protocol. |
tests/test_dataclasses.py |
Updates test fixtures and assertions to match the new non-generic protocol shape. |
|
Looks like we've run into a pyrefly bug here. Do you want to report it or should I? |
|
Go for it! I'm sure you've interacted with them more. |
|
It looks like it has already been raised: facebook/pyrefly#2477 |
|
What's up with the unverified commits? |
GitHub Codespaces. Something isn't signed in correctly. Or something. |
Hmm, should be possible https://docs.github.com/en/codespaces/managing-your-codespaces/managing-gpg-verification-for-github-codespaces (but you probably already know that) |
Co-authored-by: Joren Hammudoglu <jhammudoglu@gmail.com>
|
Yeah, it's on my trusted repositories list for GPG signing. |
dataclasses: remove HasDataclassFields type parameter, use ClassVar
|
Thanks! |
Motivated by GalacticDynamics/dataclassish#78