summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Sottile <asottile@umich.edu>2019-08-12 06:00:58 -0700
committerIan Stapleton Cordasco <graffatcolmingov@gmail.com>2019-08-12 08:00:58 -0500
commite422e53042ada656f7a485f2d053dc1885193026 (patch)
tree2a6b23a0084af1738241908b0651334d1948d716
parentfa92556ca04214fbe292b3d007b34059e8490b5e (diff)
downloadpyflakes-e422e53042ada656f7a485f2d053dc1885193026.tar.gz
Add support for PEP 572 assignment expressions (#457)
-rw-r--r--pyflakes/checker.py2
-rw-r--r--pyflakes/test/test_other.py9
2 files changed, 10 insertions, 1 deletions
diff --git a/pyflakes/checker.py b/pyflakes/checker.py
index f2e579f..3ed398d 100644
--- a/pyflakes/checker.py
+++ b/pyflakes/checker.py
@@ -1329,7 +1329,7 @@ class Checker(object):
# "expr" type nodes
BOOLOP = UNARYOP = IFEXP = SET = \
REPR = ATTRIBUTE = SUBSCRIPT = \
- STARRED = NAMECONSTANT = handleChildren
+ STARRED = NAMECONSTANT = NAMEDEXPR = handleChildren
def _handle_string_dot_format(self, node):
try:
diff --git a/pyflakes/test/test_other.py b/pyflakes/test/test_other.py
index 775fdde..df2f790 100644
--- a/pyflakes/test/test_other.py
+++ b/pyflakes/test/test_other.py
@@ -1754,6 +1754,15 @@ class TestUnusedAssignment(TestCase):
print(f'\x7b4*baz\N{RIGHT CURLY BRACKET}')
''')
+ @skipIf(version_info < (3, 8), 'new in Python 3.8')
+ def test_assign_expr(self):
+ """Test PEP 572 assignment expressions are treated as usage / write."""
+ self.flakes('''
+ from foo import y
+ print(x := y)
+ print(x)
+ ''')
+
class TestStringFormatting(TestCase):