From b2b2f93b282f06537e4c775bcc85c79998b8a56b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Fri, 27 Dec 2024 18:14:08 -0500 Subject: [PATCH] style: Ignore R1721: Unnecessary use of a comprehension, use list(self) instead. (unnecessary-comprehension) (#4894) Pylint rule: https://pylint.readthedocs.io/en/latest/user_guide/messages/refactor/unnecessary-comprehension.html These two occurrences already disabled an equivalent Ruff rule coming from flake8, as there was a recursion issue --- gui/wxpython/lmgr/giface.py | 2 +- pyproject.toml | 1 - python/grass/pygrass/gis/__init__.py | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/gui/wxpython/lmgr/giface.py b/gui/wxpython/lmgr/giface.py index 67669039d5d..ecb21c1e9d3 100644 --- a/gui/wxpython/lmgr/giface.py +++ b/gui/wxpython/lmgr/giface.py @@ -56,7 +56,7 @@ def __init__(self, tree): def __len__(self): # The list constructor calls __len__ as an optimization if available, # causing a RecursionError - return len([layer for layer in self]) # noqa: C416 + return len([layer for layer in self]) # noqa: C416 # pylint: disable=R1721 def __iter__(self): """Iterates over the contents of the list.""" diff --git a/pyproject.toml b/pyproject.toml index d25b04e9c52..3672737bdc9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -641,7 +641,6 @@ disable = [ "R1714", # Consider merging these comparisons with 'in' by using '%s %sin (%s)'. Use a set instead if elements are hashable. (consider-using-in) "R1715", # Consider using dict.get for getting values from a dict if a key is present or a default if not (consider-using-get) "R1716", # Simplify chained comparison between the operands (chained-comparison) - "R1721", # Unnecessary use of a comprehension, use %s instead. (unnecessary-comprehension) "R1724", # Unnecessary "%s" after "continue", %s (no-else-continue) "R1727", # Boolean condition '%s' will always evaluate to '%s' (condition-evals-to-constant) "R1732", # Consider using 'with' for resource-allocating operations (consider-using-with) diff --git a/python/grass/pygrass/gis/__init__.py b/python/grass/pygrass/gis/__init__.py index 0393d490f57..e34abc405c4 100644 --- a/python/grass/pygrass/gis/__init__.py +++ b/python/grass/pygrass/gis/__init__.py @@ -272,7 +272,7 @@ def mapsets(self, pattern=None, permissions=True): [...] """ - mapsets = [mapset for mapset in self] # noqa: C416 + mapsets = [mapset for mapset in self] # noqa: C416 # pylint: disable=R1721 if permissions: mapsets = [ mapset