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

Fix type annotations for get_axis_num (GH 9822) #9827

Merged
merged 4 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ Deprecations

Bug fixes
~~~~~~~~~
- Fix type annotations for ``get_axis_num``. (:issue:`9822`, :pull:`9827`).
By `Bruce Merry <https://github.com/bmerry>`_.
- Fix unintended load on datasets when calling :py:meth:`DataArray.plot.scatter` (:pull:`9818`).
By `Jimmy Westling <https://github.com/illviljan>`_.

Expand Down
3 changes: 3 additions & 0 deletions xarray/core/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,9 @@ def __iter__(self: Any) -> Iterator[Any]:
raise TypeError("iteration over a 0-d array")
return self._iter()

@overload
def get_axis_num(self, dim: str) -> int: ... # type: ignore [overload-overlap]

@overload
def get_axis_num(self, dim: Iterable[Hashable]) -> tuple[int, ...]: ...

Expand Down
3 changes: 3 additions & 0 deletions xarray/namedarray/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,9 @@ def _dask_finalize(
data = array_func(results, *args, **kwargs)
return type(self)(self._dims, data, attrs=self._attrs)

@overload
def get_axis_num(self, dim: str) -> int: ... # type: ignore [overload-overlap]

@overload
def get_axis_num(self, dim: Iterable[Hashable]) -> tuple[int, ...]: ...

Expand Down
Loading