feat(typing): Further simplify generated Literal aliases#3469
Merged
feat(typing): Further simplify generated Literal aliases#3469
Literal aliases#3469Conversation
dangotbanned
commented
Jul 10, 2024
| AutosizeType_T: TypeAlias = Literal["pad", "none", "fit", "fit-x", "fit-y"] | ||
| AxisOrient_T: TypeAlias = Literal["top", "bottom", "left", "right"] | ||
| Baseline_T: TypeAlias = Literal["top", "middle", "bottom"] | ||
| BinnedTimeUnit_T: TypeAlias = Literal[ |
Member
Author
There was a problem hiding this comment.
This was the alias that I was aiming for when I opened this and below is an example of where it would appear.
Before
After
Everything else was a bonus
dangotbanned
commented
Jul 10, 2024
| elif (alias := self._literals_invert.get(tp)) and replace: | ||
| tp = alias | ||
| elif replace and info.is_union_enum(): | ||
| # Handles one very specific edge case `WindowFieldDef` |
Member
Author
There was a problem hiding this comment.
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.
Follow-up to: #3464 and #3431
Literals that only appear as part of aUnionare now replaced by theUnion(in all but 1 case)Literals in docstrings &TypeAlias's in annotations now appear after all other types_typing.pynow has an autogenerated__all__