xarray
xarray copied to clipboard
improve typing of DataArray and Dataset reductions
This PR makes the typing of reduction methods (count
, all
, any
, max
, min
, mean
, prod
, sum
, std
, var
, median
) for Dataset
and DataArray
consistent with the typing of most other methods of Dataset
and DataArray
after the great recent improvements by @headtr1ck in e.g. #6661.
Noble effort, but I think we will have to wait until https://github.com/python/mypy/issues/12846 is solved, otherwise users will get false positives...
Agreed, I just reached the same conclusion.
Since https://github.com/python/mypy/issues/12846 seems to have been fixed, we could give this another go.
Edit: Actually, now that the Self
type should be fully supported, we could just move to this directly!
Rebasing my branch required solving quite some merge conflicts, which was to be expected as this PR had run more than 400 commits behind. I adapted the PR to now use Self
as you suggested.
It took a few iterations to satisfy both mypy 1.4.1 (in my development enviroment) and mypy 1.5.1 (in CI) at the same time, but now CI is fully green.
Thanks for this PR!
Thank you for taking care of the last few steps yourself and merging this PR! I just came back from vacation and just realized it would have been nicer if I had mentioned that I was going to be unresponsive for several weeks.