Skip to content

Commit

Permalink
Fix formatting mistakes moving mypy comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Armavica committed Sep 26, 2024
1 parent 33b4576 commit 700a426
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
5 changes: 3 additions & 2 deletions xarray/core/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,9 @@ def factorize(self) -> EncodedGroups:
# NaNs; as well as values outside the bins are coded by -1
# Restore these after the raveling
mask = functools.reduce(
np.logical_or, [(code == -1) for code in broadcasted_codes]
) # type: ignore[arg-type]
np.logical_or, # type: ignore[arg-type]
[(code == -1) for code in broadcasted_codes],
)
_flatcodes[mask] = -1

midx = pd.MultiIndex.from_product(
Expand Down
8 changes: 4 additions & 4 deletions xarray/core/resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,9 @@ def _interpolate(self, kind="linear", **kwargs) -> T_Xarray:


# https://github.com/python/mypy/issues/9031
class DataArrayResample(
class DataArrayResample( # type: ignore[misc]
Resample["DataArray"], DataArrayGroupByBase, DataArrayResampleAggregations
): # type: ignore[misc]
):
"""DataArrayGroupBy object specialized to time resampling operations over a
specified dimension
"""
Expand Down Expand Up @@ -331,9 +331,9 @@ def asfreq(self) -> DataArray:


# https://github.com/python/mypy/issues/9031
class DatasetResample(
class DatasetResample( # type: ignore[misc]
Resample["Dataset"], DatasetGroupByBase, DatasetResampleAggregations
): # type: ignore[misc]
):
"""DatasetGroupBy object specialized to resampling a specified dimension"""

def map(
Expand Down
8 changes: 4 additions & 4 deletions xarray/namedarray/_array_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ def astype(


def imag(
x: NamedArray[_ShapeType, np.dtype[_SupportsImag[_ScalarType]]],
/, # type: ignore[type-var]
x: NamedArray[_ShapeType, np.dtype[_SupportsImag[_ScalarType]]], # type: ignore[type-var]
/,
) -> NamedArray[_ShapeType, np.dtype[_ScalarType]]:
"""
Returns the imaginary component of a complex number for each element x_i of the
Expand Down Expand Up @@ -112,8 +112,8 @@ def imag(


def real(
x: NamedArray[_ShapeType, np.dtype[_SupportsReal[_ScalarType]]],
/, # type: ignore[type-var]
x: NamedArray[_ShapeType, np.dtype[_SupportsReal[_ScalarType]]], # type: ignore[type-var]
/,
) -> NamedArray[_ShapeType, np.dtype[_ScalarType]]:
"""
Returns the real component of a complex number for each element x_i of the
Expand Down
5 changes: 3 additions & 2 deletions xarray/tests/test_coordinates.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@ def test_init_index_error(self) -> None:

with pytest.raises(TypeError, match=".* is not an `xarray.indexes.Index`"):
Coordinates(
coords={"x": ("x", [1, 2, 3])}, indexes={"x": "not_an_xarray_index"}
) # type: ignore[dict-item]
coords={"x": ("x", [1, 2, 3])},
indexes={"x": "not_an_xarray_index"}, # type: ignore[dict-item]
)

def test_init_dim_sizes_conflict(self) -> None:
with pytest.raises(ValueError):
Expand Down

0 comments on commit 700a426

Please sign in to comment.