xarray
xarray copied to clipboard
Overload DataArray's argmin and argmax methods on dim parameter
Is your feature request related to a problem?
DataArray's argmin and argmax methods currently have a return type of Self | dict[Hashable, Self]. However, based on the argument provided to dim I know which element of the union it will be, making the return value less convenient to type check than it could be (e.g., requires casting or type checker suppression comments).
Describe the solution you'd like
Provide overloads for the methods that give a more specific return type depending on the type of the argument to dim.
Describe alternatives you've considered
No response
Additional context
No response
There is the trap where str is a subtype of Collection[str] to watch out for, but since type checkers are supposed to select the first matching overload this improvement should be feasible.