Skip to content

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

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

binste merged 3 commits into
vega:mainfrom
dangotbanned:type-alias-tracer-ext

Conversation

@dangotbanned

@dangotbanned dangotbanned commented Jul 10, 2024 •

Copy link
Copy Markdown
Member

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[

@dangotbanned dangotbanned Jul 10, 2024 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Comment thread tools/schemapi/utils.py
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
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@binste binste left a comment

Copy link
Copy Markdown
Contributor

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