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 for numpy 1.20 #4878

Merged
merged 10 commits into from
Feb 23, 2021
Merged

typing for numpy 1.20 #4878

merged 10 commits into from
Feb 23, 2021

Conversation

mathause
Copy link
Collaborator

@mathause mathause commented Feb 7, 2021

numpy v1.20.0 introduced type hints which leads to some mypy errors in xarray. This is the minimum set of changes to make mypy happy again. I tried to avoid #type: ignore and Any but in some instances I think it was not worth it.

I am sure there is much more fun to be had with numpy typing ;-)

@mathause mathause mentioned this pull request Feb 7, 2021
1 task
@max-sixty
Copy link
Collaborator

Looks good! Thanks a lot for doing these @mathause

@@ -1397,17 +1397,17 @@ def __init__(self, array: Any, dtype: DTypeLike = None):
self.array = utils.safe_cast_to_index(array)
if dtype is None:
if isinstance(array, pd.PeriodIndex):
dtype = np.dtype("O")
dtype_ = np.dtype("O")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could potentially be simplified by allowing-redefinitions

@mathause
Copy link
Collaborator Author

Thanks. I'd like to make sure this gets properly tested (#4881) before merging.

@mathause mathause merged commit 0f65307 into pydata:master Feb 23, 2021
@mathause mathause deleted the typing_numpy_1_20 branch February 23, 2021 20:52
dcherian added a commit to dcherian/xarray that referenced this pull request Mar 8, 2021
* upstream/master: (46 commits)
  pin netCDF4=1.5.3 in min-all-deps (pydata#4982)
  fix matplotlib errors for single level discrete colormaps (pydata#4256)
  Adapt exception handling in CFTimeIndex.__sub__ and __rsub__ (pydata#5006)
  Update options.py (pydata#5000)
  Adjust tests to use updated pandas syntax for offsets (pydata#4537)
  add a combine_attrs parameter to Dataset.merge (pydata#4895)
  Support for dask.graph_manipulation (pydata#4965)
  raise on passing axis to Dataset.reduce methods (pydata#4940)
  Whatsnew for 0.17.1 (pydata#4963)
  Refinements to how-to-release (pydata#4964)
  DOC: add example for reindex (pydata#4956)
  DOC: rm np import (pydata#4949)
  Add 0.17.0 release notes (pydata#4953)
  document update as inplace (pydata#4932)
  bump the dependencies (pydata#4942)
  Upstream CI: limit runtime (pydata#4946)
  typing for numpy 1.20 (pydata#4878)
  Use definition of DTypeLike from Numpy if found (pydata#4941)
  autoupdate mypy (pydata#4943)
  Add DataArrayCoarsen.reduce and DatasetCoarsen.reduce methods (pydata#4939)
  ...
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.

2 participants