summaryrefslogtreecommitdiff
path: root/pylint/checkers
diff options
context:
space:
mode:
authorZen Lee <53538590+zenlyj@users.noreply.github.com>2023-02-10 14:21:41 +0800
committerGitHub <noreply@github.com>2023-02-10 07:21:41 +0100
commit32e1545efac4f8b3b1c7b6b3efa160d1cb4f4046 (patch)
tree269042a6d08eb59e8ab4bcd3731f0d87cb4cc45e /pylint/checkers
parenteccba3e17e5f9584f52ed600352d450b39714cc2 (diff)
downloadpylint-git-32e1545efac4f8b3b1c7b6b3efa160d1cb4f4046.tar.gz
Fix `used-before-assignment` false positive for walrus operator in dictionary (#8176)
Diffstat (limited to 'pylint/checkers')
-rw-r--r--pylint/checkers/variables.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/pylint/checkers/variables.py b/pylint/checkers/variables.py
index f1f491eda..adb0faa15 100644
--- a/pylint/checkers/variables.py
+++ b/pylint/checkers/variables.py
@@ -2256,6 +2256,11 @@ class VariablesChecker(BaseChecker):
return True
if isinstance(value, nodes.Lambda) and isinstance(value.body, nodes.IfExp):
return True
+ if isinstance(value, nodes.Dict) and any(
+ isinstance(item[0], nodes.IfExp) or isinstance(item[1], nodes.IfExp)
+ for item in value.items
+ ):
+ return True
if not isinstance(value, nodes.Call):
return False
return any(