summaryrefslogtreecommitdiff
path: root/pylint
diff options
context:
space:
mode:
authorgithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>2023-04-17 07:25:14 +0000
committerGitHub <noreply@github.com>2023-04-17 07:25:14 +0000
commit1dba30b43ce7d2c43e6cc94120d8daca5d9ddabd (patch)
treebc8b8094f1b980173a6532ca6a1336d7654a7cf3 /pylint
parentec96bdc206350e378137da27c2f4cd103a94dc63 (diff)
downloadpylint-git-1dba30b43ce7d2c43e6cc94120d8daca5d9ddabd.tar.gz
Improve output of `consider-using-generator` message for `min()` calls with `default` keyword (#8582) (#8583)
(cherry picked from commit 4a485e28f0a5118b37550123c79f1f6d0dec42a4) Co-authored-by: Jacob Walls <jacobtylerwalls@gmail.com>
Diffstat (limited to 'pylint')
-rw-r--r--pylint/checkers/refactoring/refactoring_checker.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/pylint/checkers/refactoring/refactoring_checker.py b/pylint/checkers/refactoring/refactoring_checker.py
index b0a87b4c9..ec4d3d71e 100644
--- a/pylint/checkers/refactoring/refactoring_checker.py
+++ b/pylint/checkers/refactoring/refactoring_checker.py
@@ -1070,11 +1070,15 @@ class RefactoringChecker(checkers.BaseTokenChecker):
and isinstance(node.func, nodes.Name)
and node.func.name in checked_call
):
- # functions in checked_calls take exactly one argument
+ # functions in checked_calls take exactly one positional argument
# check whether the argument is list comprehension
if len(node.args) == 1 and isinstance(node.args[0], nodes.ListComp):
# remove square brackets '[]'
inside_comp = node.args[0].as_string()[1:-1]
+ if node.keywords:
+ inside_comp = f"({inside_comp})"
+ inside_comp += ", "
+ inside_comp += ", ".join(kw.as_string() for kw in node.keywords)
call_name = node.func.name
if call_name in {"any", "all"}:
self.add_message(