Skip to content
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

Merged
merged 3 commits into from
Aug 10, 2023
Merged

Type hint schemapi.py #3142

merged 3 commits into from
Aug 10, 2023

Conversation

binste
Copy link
Contributor

@binste binste commented Aug 6, 2023

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 as Any as long as not all parts of the code are type hinted where Undefined is used. Afterwards we can change it to the proper UndefinedType.

@binste binste mentioned this pull request Aug 9, 2023
14 tasks
@jonmmease
Copy link
Contributor

Thanks for working on this @binste! I'll take a look later this week if no one gets to it first

Copy link
Contributor

@jonmmease jonmmease left a 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

_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:
Copy link
Contributor

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.

Copy link
Contributor Author

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

@binste
Copy link
Contributor Author

binste commented Aug 10, 2023

Thanks for the review @jonmmease!

@binste binste merged commit 0db6525 into vega:main Aug 10, 2023
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants