Skip to content

Commit ba27c6a

Browse files
Enforce ruff/flynt rules (FLY) (pydata#10375)
* Apply ruff/flynt rule FLY002 FLY002 Consider f-string instead of string join * Enforce ruff/flynt rules (FLY)
1 parent 6300288 commit ba27c6a

File tree

4 files changed

+5
-4
lines changed

4 files changed

+5
-4
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ extend-select = [
255255
"PIE", # flake8-pie
256256
"TID", # flake8-tidy-imports (absolute imports)
257257
"PYI", # flake8-pyi
258+
"FLY", # flynt
258259
"I", # isort
259260
"PERF", # Perflint
260261
"W", # pycodestyle warnings

xarray/convert.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def _iris_cell_methods_to_str(cell_methods_obj):
138138
f"interval: {interval}" for interval in cell_method.intervals
139139
)
140140
comments = " ".join(f"comment: {comment}" for comment in cell_method.comments)
141-
extra = " ".join([intervals, comments]).strip()
141+
extra = f"{intervals} {comments}".strip()
142142
if extra:
143143
extra = f" ({extra})"
144144
cell_methods.append(names + cell_method.method + extra)

xarray/core/formatting.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -894,7 +894,7 @@ def extra_items_repr(extra_keys, mapping, ab_side, kwargs):
894894
attrs_summary.append(attr_s)
895895

896896
temp = [
897-
"\n".join([var_s, attr_s]) if attr_s else var_s
897+
f"{var_s}\n{attr_s}" if attr_s else var_s
898898
for var_s, attr_s in zip(temp, attrs_summary, strict=True)
899899
]
900900

xarray/tests/test_cftime_offsets.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ def test_to_offset_annual(month_label, month_int, multiple, offset_str):
274274
freq = offset_str
275275
offset_type = _ANNUAL_OFFSET_TYPES[offset_str]
276276
if month_label:
277-
freq = "-".join([freq, month_label])
277+
freq = f"{freq}-{month_label}"
278278
if multiple:
279279
freq = f"{multiple}{freq}"
280280
result = to_offset(freq)
@@ -303,7 +303,7 @@ def test_to_offset_quarter(month_label, month_int, multiple, offset_str):
303303
freq = offset_str
304304
offset_type = _QUARTER_OFFSET_TYPES[offset_str]
305305
if month_label:
306-
freq = "-".join([freq, month_label])
306+
freq = f"{freq}-{month_label}"
307307
if multiple:
308308
freq = f"{multiple}{freq}"
309309
result = to_offset(freq)

0 commit comments

Comments
 (0)