Skip to content

Comments

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

Merged
binste merged 3 commits intovega:mainfrom
dangotbanned:type-alias-tracer-ext
Jul 13, 2024
Merged

feat(typing): Further simplify generated Literal aliases#3469
binste merged 3 commits intovega:mainfrom
dangotbanned:type-alias-tracer-ext

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.

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
@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