-
Notifications
You must be signed in to change notification settings - Fork 799
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
Type hint schemapi.py #3142
Type hint schemapi.py #3142
Conversation
127a4e9
to
f83caa5
Compare
Thanks for working on this @binste! I'll take a look later this week if no one gets to it first |
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.
Looks good. One non-blocking question
altair/utils/schemapi.py
Outdated
_wrapper_classes: Optional[Iterable[Type["SchemaBase"]]] = None, | ||
# Type hints for this method would get rather complicated | ||
# if we want to provide a more specific return type | ||
) -> Any: |
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.
Would _TSchemaBase
work here? I seems like the returned object should be a SchemaBase
subclass.
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.
When I used SchemaBase
as a return type, I got an error for Chart.from_dict
in api.py
so I left it at that. But after your comment I revisited this and indeed the Chart.from_dict
type was wrong :) -> Done in 2732c8f
Thanks for the review @jonmmease! |
See #2951 for an overview of the type hinting effort. For some methods which construct classes based on their input parameters I took the shortcut of typing them as
Any
for now as I think to make it more specific we would need some more complicated type hints. These are not super relevant for users anyway but happy to take suggestions on how to improve it!We need to keep the type of
Undefined
asAny
as long as not all parts of the code are type hinted whereUndefined
is used. Afterwards we can change it to the properUndefinedType
.