From 10465ea620236481b57d547859041853a0af864f Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Wed, 28 May 2025 18:29:10 +0200 Subject: [PATCH 1/2] Apply ruff/flynt rule FLY002 FLY002 Consider f-string instead of string join --- xarray/convert.py | 2 +- xarray/core/formatting.py | 2 +- xarray/tests/test_cftime_offsets.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/xarray/convert.py b/xarray/convert.py index 29d8f9650e3..b6811797a2e 100644 --- a/xarray/convert.py +++ b/xarray/convert.py @@ -138,7 +138,7 @@ def _iris_cell_methods_to_str(cell_methods_obj): f"interval: {interval}" for interval in cell_method.intervals ) comments = " ".join(f"comment: {comment}" for comment in cell_method.comments) - extra = " ".join([intervals, comments]).strip() + extra = f"{intervals} {comments}".strip() if extra: extra = f" ({extra})" cell_methods.append(names + cell_method.method + extra) diff --git a/xarray/core/formatting.py b/xarray/core/formatting.py index fb672997706..69359462cde 100644 --- a/xarray/core/formatting.py +++ b/xarray/core/formatting.py @@ -894,7 +894,7 @@ def extra_items_repr(extra_keys, mapping, ab_side, kwargs): attrs_summary.append(attr_s) temp = [ - "\n".join([var_s, attr_s]) if attr_s else var_s + f"{var_s}\n{attr_s}" if attr_s else var_s for var_s, attr_s in zip(temp, attrs_summary, strict=True) ] diff --git a/xarray/tests/test_cftime_offsets.py b/xarray/tests/test_cftime_offsets.py index 75269286007..de02d431bfa 100644 --- a/xarray/tests/test_cftime_offsets.py +++ b/xarray/tests/test_cftime_offsets.py @@ -274,7 +274,7 @@ def test_to_offset_annual(month_label, month_int, multiple, offset_str): freq = offset_str offset_type = _ANNUAL_OFFSET_TYPES[offset_str] if month_label: - freq = "-".join([freq, month_label]) + freq = f"{freq}-{month_label}" if multiple: freq = f"{multiple}{freq}" result = to_offset(freq) @@ -303,7 +303,7 @@ def test_to_offset_quarter(month_label, month_int, multiple, offset_str): freq = offset_str offset_type = _QUARTER_OFFSET_TYPES[offset_str] if month_label: - freq = "-".join([freq, month_label]) + freq = f"{freq}-{month_label}" if multiple: freq = f"{multiple}{freq}" result = to_offset(freq) From ad1c4527d0a7bb024412b1b54a40f380bb39c740 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Wed, 28 May 2025 18:30:08 +0200 Subject: [PATCH 2/2] Enforce ruff/flynt rules (FLY) --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index a99393de886..c980c204b5f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -255,6 +255,7 @@ extend-select = [ "PIE", # flake8-pie "TID", # flake8-tidy-imports (absolute imports) "PYI", # flake8-pyi + "FLY", # flynt "I", # isort "PERF", # Perflint "W", # pycodestyle warnings
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: