Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(typing): Further simplify generated Literal aliases #3469

Merged
merged 3 commits into from
Jul 13, 2024

Conversation

dangotbanned
Copy link
Member

@dangotbanned dangotbanned commented Jul 10, 2024

Follow-up to: #3464 and #3431

  • Literals that only appear as part of a Union are now replaced by the Union (in all but 1 case)
  • Literals in docstrings & TypeAlias's in annotations now appear after all other types
  • _typing.py now has an autogenerated __all__
  • A nice reduction of 5.5k lines of code

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[
Copy link
Member Author

@dangotbanned dangotbanned Jul 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -101,23 +101,47 @@ def add_literal(
tp = alias
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`
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@binste binste left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice, thanks! :)

@binste binste merged commit 40a0b44 into vega:main Jul 13, 2024
12 checks passed
@dangotbanned dangotbanned deleted the type-alias-tracer-ext branch July 13, 2024 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants