Skip to content

Commit

Permalink
style: Ignore R1721: Unnecessary use of a comprehension, use list(sel…
Browse files Browse the repository at this point in the history
…f) 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
  • Loading branch information
echoix authored Dec 27, 2024
1 parent 2731001 commit b2b2f93
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion gui/wxpython/lmgr/giface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion python/grass/pygrass/gis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b2b2f93

Please sign in to comment.