fix(typing): Revise generated annotation order#3655
Merged
dangotbanned merged 5 commits intomainfrom Oct 23, 2024
Merged
Conversation
The doc stated that `None` would appear after builtins, but any builtin with a length greater than 4 appeared after. The issue is not new, but became more apparent to me while writing #3653 (comment)
Bit of a driveby commit, but I want to enable doctests on `tools`. These were blocking for that
Member
Author
|
Pinging @binste so that you see this when you're available again. Happy to revert later if you have any objections 👍 |
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.
Description
The doc stated that
Nonewould appear after builtins.altair/tools/schemapi/utils.py
Lines 855 to 864 in 2ba89d5
However, this assertion doesn't hold for any
builtinwith a name length greater than 4.The issue is not new, but became more apparent to me while writing #3653 (comment)
Example
Below
floatappears afterNoneBefore
altair/altair/vegalite/v5/schema/_config.py
Line 5004 in 2ba89d5
After
altair/altair/vegalite/v5/schema/_config.py
Line 5004 in e656661
Note
I was unable to work out a sorting strategy to achieve what the doc had intended.
Instead, I've opted to always place
Nonelast in the context it appears.This is much easier to do, and is generally what most people would write (and expect to see).
In the non-generated code, this is already the pattern we use:
altair/altair/vegalite/v5/api.py
Line 2091 in 2ba89d5
altair/altair/vegalite/v5/api.py
Line 3494 in 2ba89d5
altair/altair/vegalite/v5/api.py
Line 3859 in 2ba89d5
Preventing regressions
I've started small, but have included a few doctests (f9f0a53) that are now run alongside (20d5c17) those in
altair,tests.