From dcff36a95cf917e556a9d523e293287623699f53 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 18 Mar 2024 16:25:46 +0000 Subject: [PATCH 1/2] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.2.2 → v0.3.3](https://github.com/astral-sh/ruff-pre-commit/compare/v0.2.2...v0.3.3) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5882754d..7b045547 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 ] From aa15e7cf2d6d9cb9d08e8b8432ce60896e7d302c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 18 Mar 2024 16:27:50 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks --- src/icclim/_generated_api.py | 1 + .../generic_indices/generic_indicators.py | 15 ++++-------- src/icclim/generic_indices/threshold.py | 14 ++++++----- src/icclim/main.py | 1 + src/icclim/models/frequency.py | 1 + tests/test_rechunk.py | 24 ++++++++++++------- 6 files changed, 31 insertions(+), 25 deletions(-) diff --git a/src/icclim/_generated_api.py b/src/icclim/_generated_api.py index 8e063eac..55db0b69 100644 --- a/src/icclim/_generated_api.py +++ b/src/icclim/_generated_api.py @@ -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 diff --git a/src/icclim/generic_indices/generic_indicators.py b/src/icclim/generic_indices/generic_indicators.py index ce6b6d74..4666bcc8 100644 --- a/src/icclim/generic_indices/generic_indicators.py +++ b/src/icclim/generic_indices/generic_indicators.py @@ -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): @@ -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): diff --git a/src/icclim/generic_indices/threshold.py b/src/icclim/generic_indices/threshold.py index 5b9fedbc..99b13161 100644 --- a/src/icclim/generic_indices/threshold.py +++ b/src/icclim/generic_indices/threshold.py @@ -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 @@ -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: """ diff --git a/src/icclim/main.py b/src/icclim/main.py index 1e090ff9..0d63da61 100644 --- a/src/icclim/main.py +++ b/src/icclim/main.py @@ -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 diff --git a/src/icclim/models/frequency.py b/src/icclim/models/frequency.py index cdd80999..dd867c3c 100644 --- a/src/icclim/models/frequency.py +++ b/src/icclim/models/frequency.py @@ -3,6 +3,7 @@ time series. `slice_mode` parameter of `icclim.index` is always converted to a `Frequency`. """ + from __future__ import annotations import dataclasses diff --git a/tests/test_rechunk.py b/tests/test_rechunk.py index 36e7efa6..1b307147 100644 --- a/tests/test_rechunk.py +++ b/tests/test_rechunk.py @@ -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 @@ -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()