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

Typing of Dataset #6661

Merged
merged 21 commits into from
Jun 4, 2022
Merged

Typing of Dataset #6661

merged 21 commits into from
Jun 4, 2022

Conversation

headtr1ck
Copy link
Collaborator

@headtr1ck headtr1ck commented Jun 3, 2022

Feel free to wait with merging after the 2022.05.0.dev0 release :)

  • This PR adds typing to all Dataset methods (only the ones in Dataset directly and DataWithCoords).
  • On the way it fixes several typing issues and adds small code changes for more consistent typing (hopefully does not break anything).
  • All test_dataset tests are now typed.
  • As usual there are still some mypy bugs open that prevent all typing changes to be final (especially bound TypeVar messes with argument type resolving python/mypy#12846). I choose to remove the TypeVars in these occasions to prevent false positives on the user side.
  • Sorry for updating so many files at once, mostly these are the changes of adding from __future__ import annotations and automatic fixes from pyupdate.

If anyone has some typing expertise:
I think that the way align is typed is wrong. The current implementation only works for aligning a sequence of objects of the same type, but not mixed DataArrays and Datasets. In some placed I had to add some "#type: ignore"s...
I should probably open an issue for that.

@headtr1ck
Copy link
Collaborator Author

It seems that the reductions doc outcome differs on my machine.
Is it possible to generate it in CI?

@dcherian
Copy link
Contributor

dcherian commented Jun 3, 2022

@Illviljan had similar int32 vs int64 issues. I guess you're on Windows too?

CI seems like a good idea. I'll fix it manually for now.

Also thanks for this PR. Amazing work!

@headtr1ck
Copy link
Collaborator Author

headtr1ck commented Jun 3, 2022

@Illviljan had similar int32 vs int64 issues. I guess you're on Windows too?

Yes this was on windows.

@max-sixty
Copy link
Collaborator

Great work @headtr1ck !!

@max-sixty max-sixty merged commit a2edbe4 into pydata:main Jun 4, 2022
@headtr1ck headtr1ck deleted the typingbase branch June 4, 2022 10:17
dcherian added a commit to dcherian/xarray that referenced this pull request Jun 12, 2022
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.

Start using | instead of Union or Optional when typing
3 participants