From 61f902108e0978dfb57178faa3fb594655f75501 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Sat, 28 Jun 2025 10:25:09 +0200 Subject: [PATCH 1/5] Apply ruff/Pylint rule PLC0105 PLC0105 `TypeVar` name does not reflect its covariance --- xarray/core/types.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xarray/core/types.py b/xarray/core/types.py index 2124aee0ad4..01b908cb723 100644 --- a/xarray/core/types.py +++ b/xarray/core/types.py @@ -195,7 +195,7 @@ def copy( # Temporary placeholder for indicating an array api compliant type. # hopefully in the future we can narrow this down more: -T_DuckArray = TypeVar("T_DuckArray", bound=Any, covariant=True) +T_DuckArray = TypeVar("T_DuckArray", bound=Any, covariant=True) # noqa: PLC0105 # For typing pandas extension arrays. T_ExtensionArray = TypeVar("T_ExtensionArray", bound=pd.api.extensions.ExtensionArray) From e17dc60d5db9221d4a6b1721e7c420624d891857 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Sat, 28 Jun 2025 10:29:52 +0200 Subject: [PATCH 2/5] Apply ruff/Pylint rule PLC0206 PLC0206 Extracting value from dictionary without calling `.items()` --- xarray/tests/test_groupby.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/xarray/tests/test_groupby.py b/xarray/tests/test_groupby.py index a64dfc97bb6..ac90d216144 100644 --- a/xarray/tests/test_groupby.py +++ b/xarray/tests/test_groupby.py @@ -1321,8 +1321,7 @@ def test_groupby_properties(self) -> None: grouped = self.da.groupby("abc") expected_groups = {"a": range(9), "c": [9], "b": range(10, 20)} assert expected_groups.keys() == grouped.groups.keys() - for key in expected_groups: - expected_group = expected_groups[key] + for key, expected_group in expected_groups.items(): actual_group = grouped.groups[key] # TODO: array_api doesn't allow slice: From 138a2a4d85cecbc051da9570367af84d8336ed61 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Sat, 28 Jun 2025 10:30:48 +0200 Subject: [PATCH 3/5] Apply ruff/Pylint rule PLC1802 PLC1802 `len()` used as condition without comparison --- xarray/tests/test_dask.py | 2 +- xarray/ufuncs.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/xarray/tests/test_dask.py b/xarray/tests/test_dask.py index 50870ca6976..eefa3c2b4f8 100644 --- a/xarray/tests/test_dask.py +++ b/xarray/tests/test_dask.py @@ -1372,7 +1372,7 @@ def test_map_blocks_da_ds_with_template(obj): # Check that indexes are written into the graph directly dsk = dict(actual.__dask_graph__()) - assert len({k for k in dsk if "x-coordinate" in k}) + assert {k for k in dsk if "x-coordinate" in k} assert all( isinstance(v, PandasIndex) for k, v in dsk.items() if "x-coordinate" in k ) diff --git a/xarray/ufuncs.py b/xarray/ufuncs.py index e25657216fd..83acbde858b 100644 --- a/xarray/ufuncs.py +++ b/xarray/ufuncs.py @@ -39,7 +39,7 @@ def get_array_namespace(*args): names = [module.__name__ for module in xps] raise ValueError(f"Mixed array types {names} are not supported.") - return next(iter(xps)) if len(xps) else np + return next(iter(xps)) if xps else np class _ufunc_wrapper(ABC): From 5cf892b7049baea85edf47ab0933d65095f3af88 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Sat, 28 Jun 2025 10:31:38 +0200 Subject: [PATCH 4/5] Ignore ruff/Pylint rule PLC2401 PLC2401 Variable name contains a non-ASCII character --- xarray/tests/test_dataset.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xarray/tests/test_dataset.py b/xarray/tests/test_dataset.py index 8e527faa5c7..3e0734c8a1a 100644 --- a/xarray/tests/test_dataset.py +++ b/xarray/tests/test_dataset.py @@ -1214,7 +1214,7 @@ def test_chunk_by_frequency(self, freq: str, calendar: str, add_gap: bool) -> No import dask.array N = 365 * 2 - ΔN = 28 + ΔN = 28 # noqa: PLC2401 time = xr.date_range( "2001-01-01", periods=N + ΔN, freq="D", calendar=calendar ).to_numpy(copy=True) From b15e0df27ea5fbb8ea7b4157f3f9aee6b3c19d8d Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Sat, 28 Jun 2025 10:34:07 +0200 Subject: [PATCH 5/5] Enforce ruff/Pylint Convention rules (PLC) --- pyproject.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index f303623d553..9df8241aad1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -260,6 +260,7 @@ extend-select = [ "PERF", # Perflint "W", # pycodestyle warnings "PGH", # pygrep-hooks + "PLC", # Pylint Convention "PLE", # Pylint Errors "PLR", # Pylint Refactor "PLW", # Pylint Warnings @@ -278,6 +279,8 @@ 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 + "PLC0415", # `import` should be at the top-level of a file + "PLC0206", # extracting value from dictionary without calling `.items()` "PLR091", # too many arguments / branches / statements "PLR2004", # magic value used in comparison "PLW0603", # using the global statement to update is discouraged
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: