-
Notifications
You must be signed in to change notification settings - Fork 795
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: 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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: