xarray icon indicating copy to clipboard operation
xarray copied to clipboard

improve typing of DataArray and Dataset reductions

Open rhkleijn opened this issue 2 years ago • 2 comments

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.

rhkleijn avatar Jul 02 '22 21:07 rhkleijn

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...

headtr1ck avatar Jul 03 '22 09:07 headtr1ck

Agreed, I just reached the same conclusion.

rhkleijn avatar Jul 03 '22 09:07 rhkleijn

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!

headtr1ck avatar Aug 13 '23 12:08 headtr1ck

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.

rhkleijn avatar Aug 18 '23 01:08 rhkleijn

Thanks for this PR!

headtr1ck avatar Sep 14 '23 12:09 headtr1ck

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.

rhkleijn avatar Sep 16 '23 18:09 rhkleijn