summaryrefslogtreecommitdiff
path: root/pylint/checkers/refactoring/recommendation_checker.py
diff options
context:
space:
mode:
authorTim Martin <tim@asymptotic.co.uk>2021-10-06 20:56:32 +0100
committerGitHub <noreply@github.com>2021-10-06 21:56:32 +0200
commitf963868f6b46d31ef7ae1bd1196eafe50bc4bad7 (patch)
treebf03bfc20aa347f2ffa3266f816b2b4e8e51bdf7 /pylint/checkers/refactoring/recommendation_checker.py
parent6ad9d6ce38988c55fa8d2c0cccfe03df8a08de54 (diff)
downloadpylint-git-f963868f6b46d31ef7ae1bd1196eafe50bc4bad7.tar.gz
Fix a crash if ``str.format`` is referenced without being called (#5109)
Closes #5058 Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
Diffstat (limited to 'pylint/checkers/refactoring/recommendation_checker.py')
-rw-r--r--pylint/checkers/refactoring/recommendation_checker.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/pylint/checkers/refactoring/recommendation_checker.py b/pylint/checkers/refactoring/recommendation_checker.py
index 81a7dd7b1..3bccd5fcb 100644
--- a/pylint/checkers/refactoring/recommendation_checker.py
+++ b/pylint/checkers/refactoring/recommendation_checker.py
@@ -341,8 +341,8 @@ class RecommendationChecker(checkers.BaseChecker):
isinstance(node.parent, nodes.Attribute)
and node.parent.attrname == "format"
):
- # Allow assigning .format to a variable
- if isinstance(node.parent.parent, nodes.Assign):
+ # Don't warn on referencing / assigning .format without calling it
+ if not isinstance(node.parent.parent, nodes.Call):
return
if node.parent.parent.args: