Skip to content

Commit

Permalink
Merge pull request #307 from cerfacs-globc/pre-commit-ci-update-config
Browse files Browse the repository at this point in the history
[pre-commit.ci] pre-commit autoupdate
  • Loading branch information
bzah authored Mar 19, 2024
2 parents 2120a2f + aa15e7c commit efd3c16
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ repos:
hooks:
- id: toml-sort-fix
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.2
rev: v0.3.3
hooks:
- id: ruff
args: [ --fix ]
Expand Down
1 change: 1 addition & 0 deletions src/icclim/_generated_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
To modify these, edit the extractor tool in `tools/extract-icclim-funs.py`.
This module exposes each climate index as individual functions for convenience.
"""

from __future__ import annotations

from typing import TYPE_CHECKING
Expand Down
15 changes: 5 additions & 10 deletions src/icclim/generic_indices/generic_indicators.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,10 @@ class MissingMethodLike(metaclass=abc.ABCMeta):
# https://github.com/cerfacs-globc/icclim/issues/289

@abstractmethod
def execute(self, *args, **kwargs) -> MissingBase:
...
def execute(self, *args, **kwargs) -> MissingBase: ...

@abstractmethod
def validate(self, *args, **kwargs) -> bool:
...
def validate(self, *args, **kwargs) -> bool: ...


class Indicator(ABC):
Expand All @@ -85,16 +83,13 @@ class Indicator(ABC):
)

@abc.abstractmethod
def __call__(self, *args, **kwargs) -> DataArray:
...
def __call__(self, *args, **kwargs) -> DataArray: ...

@abc.abstractmethod
def preprocess(self, *args, **kwargs) -> list[DataArray]:
...
def preprocess(self, *args, **kwargs) -> list[DataArray]: ...

@abc.abstractmethod
def postprocess(self, *args, **kwargs) -> DataArray:
...
def postprocess(self, *args, **kwargs) -> DataArray: ...


class ResamplingIndicator(Indicator, ABC):
Expand Down
14 changes: 8 additions & 6 deletions src/icclim/generic_indices/threshold.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,13 @@ class ThresholdBuilderInput(TypedDict, total=False):
interpolation: str | QuantileInterpolation | None
reference_period: Sequence[datetime | str] | None
# bounded conf:
thresholds: tuple[
ThresholdBuilderInput | Threshold,
ThresholdBuilderInput | Threshold,
] | None
thresholds: (
tuple[
ThresholdBuilderInput | Threshold,
ThresholdBuilderInput | Threshold,
]
| None
)
logical_link: LogicalLink


Expand Down Expand Up @@ -233,8 +236,7 @@ def format_metadata(
...

@abc.abstractmethod
def __eq__(self, other: Threshold) -> bool:
...
def __eq__(self, other: Threshold) -> bool: ...

def __and__(self, other: Threshold) -> BoundedThreshold:
"""
Expand Down
1 change: 1 addition & 0 deletions src/icclim/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
generated API.
A convenience function `indices` is also exposed to compute multiple indices at once.
"""

from __future__ import annotations

import datetime as dt
Expand Down
1 change: 1 addition & 0 deletions src/icclim/models/frequency.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
time series. `slice_mode` parameter of `icclim.index` is always converted to a
`Frequency`.
"""

from __future__ import annotations

import dataclasses
Expand Down
24 changes: 15 additions & 9 deletions tests/test_rechunk.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,13 @@ def test_create_optimized_zarr_store_error():
},
).chunk({"time": 2})
# Then
with pytest.raises(InvalidIcclimArgumentError), create_optimized_zarr_store(
in_files=ds,
var_names="TATAYOYO!",
target_zarr_store_name="yolo.zarr",
with (
pytest.raises(InvalidIcclimArgumentError),
create_optimized_zarr_store(
in_files=ds,
var_names="TATAYOYO!",
target_zarr_store_name="yolo.zarr",
),
):
pass

Expand All @@ -80,11 +83,14 @@ def test_create_optimized_zarr_store_no_rechunk(rechunk_mock: MagicMock):
},
).chunk({"time": 2})
# When
with pytest.raises(InvalidIcclimArgumentError), create_optimized_zarr_store(
in_files=ds,
var_names="tas",
target_zarr_store_name="n/a",
chunking={"time": 2},
with (
pytest.raises(InvalidIcclimArgumentError),
create_optimized_zarr_store(
in_files=ds,
var_names="tas",
target_zarr_store_name="n/a",
chunking={"time": 2},
),
):
pass
rechunk_mock.assert_not_called()

0 comments on commit efd3c16

Please sign in to comment.