Skip to content

Commit

Permalink
Apply ruff/flake8-pyi rule PYI041
Browse files Browse the repository at this point in the history
PYI041 Use `complex` instead of `float | complex`
PYI041 Use `float` instead of `int | float`
  • Loading branch information
DimitriPapadopoulos committed Sep 24, 2024
1 parent 576d774 commit 0f7f703
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/zarr/core/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ async def _create_v2(
dtype: npt.DTypeLike,
chunks: ChunkCoords,
dimension_separator: Literal[".", "/"] | None = None,
fill_value: None | int | float = None,
fill_value: None | float = None,
order: Literal["C", "F"] | None = None,
filters: list[dict[str, JSON]] | None = None,
compressor: dict[str, JSON] | None = None,
Expand Down
12 changes: 6 additions & 6 deletions src/zarr/core/metadata/v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,35 +292,35 @@ def update_attributes(self, attributes: dict[str, JSON]) -> Self:

@overload
def parse_fill_value(
fill_value: int | float | complex | str | bytes | np.generic | Sequence[Any] | bool | None,
fill_value: complex | str | bytes | np.generic | Sequence[Any] | bool | None,
dtype: BOOL_DTYPE,
) -> BOOL: ...


@overload
def parse_fill_value(
fill_value: int | float | complex | str | bytes | np.generic | Sequence[Any] | bool | None,
fill_value: complex | str | bytes | np.generic | Sequence[Any] | bool | None,
dtype: INTEGER_DTYPE,
) -> INTEGER: ...


@overload
def parse_fill_value(
fill_value: int | float | complex | str | bytes | np.generic | Sequence[Any] | bool | None,
fill_value: complex | str | bytes | np.generic | Sequence[Any] | bool | None,
dtype: FLOAT_DTYPE,
) -> FLOAT: ...


@overload
def parse_fill_value(
fill_value: int | float | complex | str | bytes | np.generic | Sequence[Any] | bool | None,
fill_value: complex | str | bytes | np.generic | Sequence[Any] | bool | None,
dtype: COMPLEX_DTYPE,
) -> COMPLEX: ...


@overload
def parse_fill_value(
fill_value: int | float | complex | str | bytes | np.generic | Sequence[Any] | bool | None,
fill_value: complex | str | bytes | np.generic | Sequence[Any] | bool | None,
dtype: np.dtype[Any],
) -> Any:
# This dtype[Any] is unfortunately necessary right now.
Expand All @@ -334,7 +334,7 @@ def parse_fill_value(


def parse_fill_value(
fill_value: int | float | complex | str | bytes | np.generic | Sequence[Any] | bool | None,
fill_value: complex | str | bytes | np.generic | Sequence[Any] | bool | None,
dtype: BOOL_DTYPE | INTEGER_DTYPE | FLOAT_DTYPE | COMPLEX_DTYPE | np.dtype[Any],
) -> BOOL | INTEGER | FLOAT | COMPLEX | Any:
"""
Expand Down
2 changes: 1 addition & 1 deletion tests/v3/test_metadata/test_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ def test_parse_invalid_dtype_raises(data):
@pytest.mark.parametrize(
"data_type,fill_value", [("uint8", -1), ("int32", 22.5), ("float32", "foo")]
)
async def test_invalid_fill_value_raises(data_type: str, fill_value: int | float) -> None:
async def test_invalid_fill_value_raises(data_type: str, fill_value: float) -> None:
metadata_dict = {
"zarr_format": 3,
"node_type": "array",
Expand Down

0 comments on commit 0f7f703

Please sign in to comment.