From 6211d2f6c3ae52468d8f3fd3b21de13619d941a0 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Sat, 28 Jun 2025 09:50:58 +0200 Subject: [PATCH 1/2] Apply ruff/Pylint rule PLW3301 PLW3301 Nested `max` calls can be flattened This should work with `tuple[int, ...]`. --- xarray/backends/chunks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xarray/backends/chunks.py b/xarray/backends/chunks.py index 80aac75ecef..64630455e8b 100644 --- a/xarray/backends/chunks.py +++ b/xarray/backends/chunks.py @@ -51,7 +51,7 @@ def align_nd_chunks( # The ideal size of the chunks is the maximum of the two; this would avoid # that we use more memory than expected - max_chunk = max(fixed_chunk, max(var_chunks)) + max_chunk = max(fixed_chunk, *var_chunks) # The algorithm assumes that the chunks on this array are aligned except the last one # because it can be considered a partial one From d8721c0459fe37b3fdd3bc14998e025adee2af22 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Sat, 28 Jun 2025 10:03:57 +0200 Subject: [PATCH 2/2] Enforce ruff/Pylint Warnings (PLW) --- pyproject.toml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index c980c204b5f..36170540135 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -261,6 +261,7 @@ extend-select = [ "W", # pycodestyle warnings "PGH", # pygrep-hooks "PLE", # Pylint Errors + "PLW", # Pylint Warnings "UP", # pyupgrade "FURB", # refurb "RUF", @@ -276,6 +277,10 @@ ignore = [ "PERF203", # try-except within a loop incurs performance overhead "E402", # module level import not at top of file "E731", # do not assign a lambda expression, use a def + "PLW0603", # using the global statement to update is discouraged + "PLW0642", # reassigned `self` variable in instance method + "PLW1641", # object does not implement `__hash__` method + "PLW2901", # `for` loop variable overwritten by assignment target "UP007", # use X | Y for type annotations "FURB105", # unnecessary empty string passed to `print` "RUF001", # string contains ambiguous unicode character