From 93df7c818cbbebcc4165738aa2aa4f25ba11cf20 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 13 Jan 2025 03:50:07 +0000 Subject: [PATCH 1/2] [CI] Update .pre-commit-config.yaml --- .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 8065b3605..268e75b0a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -14,7 +14,7 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: 89c421dff2e1026ba12cdb9ebd731f4a83aa8021 # frozen: v0.8.6 + rev: 18ba2d02dcafd1cc608bd83eff6c17fb0108ca71 # frozen: v0.9.1 hooks: - id: ruff args: [ --fix, --show-fixes, --exit-non-zero-on-fix ] From 13c2012b2f0e9d84a5ed45b4ae8e82ff5155099f Mon Sep 17 00:00:00 2001 From: James Frost Date: Mon, 13 Jan 2025 11:39:52 +0000 Subject: [PATCH 2/2] Format code to Ruff 2025 style --- cset-workflow/lib/python/jinja_utils.py | 2 +- src/CSET/_workflow_utils/finish_website.py | 2 +- src/CSET/graph.py | 2 +- src/CSET/operators/plot.py | 10 +++++----- tests/operators/test_aggregate.py | 6 +++--- tests/workflow_utils/test_fetch_data.py | 6 +++--- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/cset-workflow/lib/python/jinja_utils.py b/cset-workflow/lib/python/jinja_utils.py index 7246d88cf..65590edf4 100644 --- a/cset-workflow/lib/python/jinja_utils.py +++ b/cset-workflow/lib/python/jinja_utils.py @@ -39,7 +39,7 @@ def get_models(rose_variables: dict): """ models = [] for model in range(0, 10): - model_prefix = f"m{model+1:02d}_" + model_prefix = f"m{model + 1:02d}_" model_vars = { key.removeprefix(model_prefix): value for key, value in rose_variables.items() diff --git a/src/CSET/_workflow_utils/finish_website.py b/src/CSET/_workflow_utils/finish_website.py index 156b505df..712cfaf22 100644 --- a/src/CSET/_workflow_utils/finish_website.py +++ b/src/CSET/_workflow_utils/finish_website.py @@ -34,7 +34,7 @@ def construct_index(): plot_metadata = json.load(fp) record = { plot_metadata["category"]: { - directory.name: f'{plot_metadata["title"]} {os.getenv("CYLC_TASK_CYCLE_POINT", "")}'.strip() + directory.name: f"{plot_metadata['title']} {os.getenv('CYLC_TASK_CYCLE_POINT', '')}".strip() } } except FileNotFoundError: diff --git a/src/CSET/graph.py b/src/CSET/graph.py index 7404d3ae6..b4692bf4c 100644 --- a/src/CSET/graph.py +++ b/src/CSET/graph.py @@ -75,7 +75,7 @@ def step_parser(step: dict, prev_node: str) -> str: graph.add_edge(prev_node, node) if detailed: - graph.get_node(node).attr["label"] = f'{step["operator"]}\n' + "".join( + graph.get_node(node).attr["label"] = f"{step['operator']}\n" + "".join( f"<{key}: {kwargs[key]}>\n" for key in kwargs ) return node diff --git a/src/CSET/operators/plot.py b/src/CSET/operators/plot.py index d95dcc9d7..84f7f8d08 100644 --- a/src/CSET/operators/plot.py +++ b/src/CSET/operators/plot.py @@ -286,11 +286,11 @@ def _plot_and_save_spatial_plot( axes.set_yscale("log") axes.set_title( - f'{title}\n' - f'Start Lat: {cube.attributes["transect_coords"].split("_")[0]}' - f' Start Lon: {cube.attributes["transect_coords"].split("_")[1]}' - f' End Lat: {cube.attributes["transect_coords"].split("_")[2]}' - f' End Lon: {cube.attributes["transect_coords"].split("_")[3]}', + f"{title}\n" + f"Start Lat: {cube.attributes['transect_coords'].split('_')[0]}" + f" Start Lon: {cube.attributes['transect_coords'].split('_')[1]}" + f" End Lat: {cube.attributes['transect_coords'].split('_')[2]}" + f" End Lon: {cube.attributes['transect_coords'].split('_')[3]}", fontsize=16, ) diff --git a/tests/operators/test_aggregate.py b/tests/operators/test_aggregate.py index cdd2a8dc7..7f4f6f264 100644 --- a/tests/operators/test_aggregate.py +++ b/tests/operators/test_aggregate.py @@ -31,6 +31,6 @@ def test_aggregate(cube): ) # Check if number of coords on aggregated cube is same as original cube. - assert len(aggregated_cube.coords()) == len( - cube.coords() - ), "aggregated cube does not have additional aux coordinate" + assert len(aggregated_cube.coords()) == len(cube.coords()), ( + "aggregated cube does not have additional aux coordinate" + ) diff --git a/tests/workflow_utils/test_fetch_data.py b/tests/workflow_utils/test_fetch_data.py index 66e998dad..452e3cda5 100644 --- a/tests/workflow_utils/test_fetch_data.py +++ b/tests/workflow_utils/test_fetch_data.py @@ -91,9 +91,9 @@ def test_get_needed_environment_variables_data_period_handling(monkeypatch): # Check DATA_PERIOD is not there for initiation. monkeypatch.setenv("DATE_TYPE", "initiation") initiation_actual = fetch_data._get_needed_environment_variables() - assert ( - initiation_actual["data_period"] is None - ), "data_period should not be set for initiation time" + assert initiation_actual["data_period"] is None, ( + "data_period should not be set for initiation time" + ) # Check exception when data period is not specified for validity time. monkeypatch.setenv("DATE_TYPE", "validity")