-
-
Notifications
You must be signed in to change notification settings - Fork 111
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
Enhance converter docstring and keyword definitions #1481
Comments
Thinking a bit more about this, I don't think there's a need to add all the keywords to the signature, it'll make it crazier than it is and we'd have to deal with default values, as now most of these keywords are passed downstream only when they're passed to the converter. Instead, one issue we seem to have is that, while the Converter class defines lists of keywords (
These lists are used for different purposes, including dynamically building the signature (e.g. useful in IPython) and for warning the user when they pass some unexpected keyword. To build the Plotting Options Reference, we'll need to have a way to dynamically collect these keywords, their docstring, the group they belong to, and even maybe their type hints. To get there, I think the first step is to ensure we have the right data:
There are also a few cases of keywords that are not part of the signature, not in the docstring, and not in any of these special lists. One way to find them is just to go through the code of the Converter class and spot things like
To make sure this all works well long-term:
|
In the future we could maybe leverage import typing as t
class AxisOptions(t.TypedDict, total=False):
height: int
width: int
logx: bool
class GeoOptions(t.TypedDict, total=False):
geo: bool
project: bool
class AllOptions(AxisOptions, GeoOptions):
pass
print(AxisOptions.__optional_keys__)
print(AxisOptions.__annotations__)
# frozenset({'logx', 'width', 'height'})
# {'height': <class 'int'>, 'width': <class 'int'>, 'logx': <class 'bool'>}
def plot(
**kwargs: t.Unpack[AllOptions],
):
height = kwargs['height']
geo = kwargs['geo'] |
Comparing the keyword documented in the signature and defined in the docstring of the
HoloViewsConverter
class:The text was updated successfully, but these errors were encountered: