Overhauled typing and stub generation#29
Open
jmriebold wants to merge 1 commit intomr-fatalyst:mainfrom
Open
Conversation
- Fixed mr-fatalyst#10 - Fixed mr-fatalyst#13 - Added filter params for FKs - Updated existing tests to remove obsolete xfail - Added tests for new functionality and edge cases
10ba5a9 to
364f5b6
Compare
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.
Summary
At present, Oxyde's type hints indicate that
Fieldreturns an instance ofOxydeFieldInfo(#13), and that queries return instances ofModelrather than the defined class (#10). In addition, stub generation omitted fields from FKs. These three issues result in type checkers like Pyright and Ty flagging unknown attribute errors and type assignment errors in a codebase that uses Oxyde.Changes
This PR does not change any core functionality, rather it updates the type hinting and stub generation to address the above issues. Specifically:
pydantic_core.PydanticUndefinedin place ofpydantic.fields.PydanticUndefined(a Pydantic v2 API change)order_by()because it doesn't currently support ordering based on FK fields).Testing
Notes
It'd probably be worth investigating why the existing type checks tests aren't catching these issues, since we know Mypy can flag them.
Thanks for an awesome library! Looking forward to migrating more projects over to it.