feat: Adds @register_theme decorator#3526
Conversation
Resolves one item in vega#3519
Adds `@register_theme` to top-level
The latter may give false-positives for json-incompatible dicts
|
Will probably need to resolve some conflicts after merging EditAll good to go again |
binste
left a comment
There was a problem hiding this comment.
Very useful! Thanks for adding this and sorry that you had to wait a month for a review and keep this branch in sync ;)
Only one small question regarding LiteralString, otherwise this looks good to me.
Thanks for getting to this @binste and no worries on the timing; this is a mini-feature after all 😄 |
binste
left a comment
There was a problem hiding this comment.
Good point, having autocompletion trumps type hint flexibility in this case, wasn't aware that we can't have both. Thanks for the explanation!
Would you mind just adding the link to your GitHub comment as a Python comment next to the LiteralString type hints in register_theme and in the ThemeRegistry? Else, I'll probably change the type hint in a few months when I've forgotten why LiteralString is better :)
Important
Prior to
v5.5.0, (#3618) refactored this intoalt.theme.register.See updated examples in https://altair-viz.github.io/user_guide/customization.html#defining-a-custom-theme
Resolves one item in #3519
Fairly simple addition, but it is a nice convenience when you only use a single theme.
I also added an example that might be relevant to @joelostblom #3519 (comment)
The decorator also works well with type checkers: