Fix type annotation for DataVariables to use Hashable instead of Any#10960
Merged
dcherian merged 1 commit intopydata:mainfrom Dec 2, 2025
Merged
Fix type annotation for DataVariables to use Hashable instead of Any#10960dcherian merged 1 commit intopydata:mainfrom
dcherian merged 1 commit intopydata:mainfrom
Conversation
jsignell
pushed a commit
to jsignell/xarray
that referenced
this pull request
Dec 2, 2025
…ydata#10960) Co-authored-by: DHRUVA KUMAR KAUSHAL <sanjay@MacBook-Air.local>
Contributor
|
Just FYI, there's a lot of user code out there which assumes the keys/variable names in a Dataset are strings, which fails to typecheck after this change. I get that having stricter checks here is probably the best decision for type-checking of xarray itself, but for a lot of users who only use string keys the Hashable thing is a bit of a pain and the Any type was a nice compromise. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
dataset.data_vars.keys()returnsKeysView[Any]#10906Currently. using [Any] also disables type checking, making it harder to catch type-related errors. Updated the type annotation in [dataset_variables.py] to use instead of [Any], making it consistent with hashables.