8000 Enforce ruff/refurb rules (FURB) by DimitriPapadopoulos · Pull Request #10367 · pydata/xarray · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Enforce ruff/refurb rules (FURB) #10367

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ extend-select = [
"TID", # flake8-tidy-imports (absolute imports)
"PGH", # pygrep-hooks
"PERF", # Perflint
"FURB", # refurb
"RUF",
]
extend-safe-fixes = [
Expand All @@ -270,6 +271,7 @@ ignore = [
"C40", # unnecessary generator, comprehension, or literal
"PIE790", # unnecessary pass statement
"PERF203", # try-except within a loop incurs performance overhead
"FURB105", # unnecessary empty string passed to `print`
"RUF001", # string contains ambiguous unicode character
"RUF002", # docstring contains ambiguous acute accent unicode character
"RUF003", # comment contains ambiguous no-break space unicode character
Expand Down
2 changes: 1 addition & 1 deletion xarray/core/accessor_str.py
Original file line number Diff line number Diff line change
Expand Up @@ -1944,7 +1944,7 @@ def replace(
if regex:
pat = self._re_compile(pat=pat, flags=flags, case=case)
func = lambda x, ipat, irepl, i_n: ipat.sub(
repl=irepl, string=x, count=i_n if i_n >= 0 else 0
repl=irepl, string=x, count=max(i_n, 0)
)
else:
pat = self._stringify(pat)
Expand Down
16 changes: 8 additions & 8 deletions xarray/tests/test_accessor_str.py
Original file line number Diff line number Diff line change
Expand Up @@ -906,7 +906,7 @@ def test_extractall_single_single_nocase(dtype) -> None:
pat_re: str | bytes = (
pat_str if dtype == np.str_ else bytes(pat_str, encoding="UTF-8")
)
pat_compiled = re.compile(pat_re, flags=re.I)
pat_compiled = re.compile(pat_re, flags=re.IGNORECASE)

value = xr.DataArray(
[["a_Xy_0", "ab_xY_10", "abc_Xy_01"], ["abcd_Xy_", "", "abcdef_Xy_101"]],
Expand Down Expand Up @@ -981,7 +981,7 @@ def test_extractall_single_multi_nocase(dtype) -> None:
pat_re: str | bytes = (
pat_str if dtype == np.str_ else bytes(pat_str, encoding="UTF-8")
)
pat_compiled = re.compile(pat_re, flags=re.I)
pat_compiled = re.compile(pat_re, flags=re.IGNORECASE)

value = xr.DataArray(
[
Expand Down Expand Up @@ -1063,7 +1063,7 @@ def test_extractall_multi_single_nocase(dtype) -> None:
pat_re: str | bytes = (
pat_str if dtype == np.str_ else bytes(pat_str, encoding="UTF-8")
)
pat_compiled = re.compile(pat_re, flags=re.I)
pat_compiled = re.compile(pat_re, flags=re.IGNORECASE)

value = xr.DataArray(
[["a_Xy_0", "ab_xY_10", "abc_Xy_01"], ["abcd_Xy_", "", "abcdef_Xy_101"]],
Expand Down Expand Up @@ -1145,7 +1145,7 @@ def test_extractall_multi_multi_nocase(dtype) -> None:
pat_re: str | bytes = (
pat_str if dtype == np.str_ else bytes(pat_str, encoding="UTF-8")
)
pat_compiled = re.compile(pat_re, flags=re.I)
pat_compiled = re.compile(pat_re, flags=re.IGNORECASE)

value = xr.DataArray(
[
Expand Down Expand Up @@ -1245,7 +1245,7 @@ def test_findall_single_single_case(dtype) -> None:

def test_findall_single_single_nocase(dtype) -> None:
pat_str = r"(\w+)_Xy_\d*"
pat_re = re.compile(dtype(pat_str), flags=re.I)
pat_re = re.compile(dtype(pat_str), flags=re.IGNORECASE)

value = xr.DataArray(
[["a_Xy_0", "ab_xY_10", "abc_Xy_01"], ["abcd_Xy_", "", "abcdef_Xy_101"]],
Expand Down Expand Up @@ -1313,7 +1313,7 @@ def test_findall_single_multi_case(dtype) -> None:

def test_findall_single_multi_nocase(dtype) -> None:
pat_str = r"(\w+)_Xy_\d*"
pat_re = re.compile(dtype(pat_str), flags=re.I)
pat_re = re.compile(dtype(pat_str), flags=re.IGNORECASE)

value = xr.DataArray(
[
Expand Down Expand Up @@ -1387,7 +1387,7 @@ def test_findall_multi_single_case(dtype) -> None:

def test_findall_multi_single_nocase(dtype) -> None:
pat_str = r"(\w+)_Xy_(\d*)"
pat_re = re.compile(dtype(pat_str), flags=re.I)
pat_re = re.compile(dtype(pat_str), flags=re.IGNORECASE)

value = xr.DataArray(
[["a_Xy_0", "ab_xY_10", "abc_Xy_01"], ["abcd_Xy_", "", "abcdef_Xy_101"]],
Expand Down Expand Up @@ -1463,7 +1463,7 @@ def test_findall_multi_multi_case(dtype) -> None:

def test_findall_multi_multi_nocase(dtype) -> None:
pat_str = r"(\w+)_Xy_(\d*)"
pat_re = re.compile(dtype(pat_str), flags=re.I)
pat_re = re.compile(dtype(pat_str), flags=re.IGNORECASE)

value = xr.DataArray(
[
Expand Down
Loading
0