diff options
author | Jacob Walls <jacobtylerwalls@gmail.com> | 2023-04-16 13:34:35 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-16 13:34:35 -0400 |
commit | 4a485e28f0a5118b37550123c79f1f6d0dec42a4 (patch) | |
tree | f712c50f0321f8855c6e76443ced7f583bd69cff /pylint/checkers | |
parent | f80a683efc2edb10d4c3780b9866f66a70d397d8 (diff) | |
download | pylint-git-4a485e28f0a5118b37550123c79f1f6d0dec42a4.tar.gz |
Improve output of `consider-using-generator` message for `min()` calls with `default` keyword (#8582)
Diffstat (limited to 'pylint/checkers')
-rw-r--r-- | pylint/checkers/refactoring/refactoring_checker.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/pylint/checkers/refactoring/refactoring_checker.py b/pylint/checkers/refactoring/refactoring_checker.py index bfe0f46d0..f8d0bc7bc 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( |