-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Switch to T_DataArray in .coords #7285
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
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
9c149f2
Switch to T_DataArray in .coords
Illviljan 816dbb5
Update coordinates.py
Illviljan f85901d
Update coordinates.py
Illviljan c6a5713
mypy understands the type from items better apparanetly
Illviljan 047ef1b
Update coordinates.py
Illviljan 130754d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] cdc6272
Merge branch 'main' into mypy_coords_t_dataarray
headtr1ck 5d3319f
resolve DataArrayCoords generic type
headtr1ck d7ae38d
fix import
headtr1ck d8bef27
Test adding __class_getitem__
Illviljan db6270d
Update coordinates.py
Illviljan bbb2ca3
Test adding a _data slot.
Illviljan af0afa4
Adding class_getitem seems to work.
Illviljan de84097
Merge branch 'main' into mypy_coords_t_dataarray
Illviljan 12fbd72
test mypy on 3.8
Illviljan 387ee98
Merge branch 'main' into mypy_coords_t_dataarray
Illviljan eceeacf
Update ci-additional.yaml
Illviljan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I don't really understand this error, why should the method have at least one argument with the same TypeVar? The TypeVar is stored in self already.
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.
That's what I meant with making coordinates a generic class.
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.
Sorry, I'm not following. Feel free to push to this PR or link me to an example you think is similar.
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.
done :)
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.
Ok, nvmd. This does not seem to work in python 3.8....
Anyone has an idea how to solve this? haha.
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.
Yeah, a little surprised it worked. :D
Taken from:
https://github.com/python/cpython/blob/b0e1f9c241cd8f8c864d51059217f997d3b792bf/Lib/_collections_abc.py#L428
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.
Does it work though? What does a
reveal_type(da.coords)
give?Or a
reveal_type(da.coords["x"])
?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.
I get this on main:
Do you as well?
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.
No, I get
note: Revealed type is "xarray.core.dataarray.DataArray"
as expected.(python 3.9.13 and mypy 0.990)
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.
Hmm, I use: