Skip to content

Commit e422e53

Browse files
asottilesigmavirus24
authored andcommitted
Add support for PEP 572 assignment expressions (#457)
1 parent fa92556 commit e422e53

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

pyflakes/checker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1329,7 +1329,7 @@ def ignore(self, node):
13291329
# "expr" type nodes
13301330
BOOLOP = UNARYOP = IFEXP = SET = \
13311331
REPR = ATTRIBUTE = SUBSCRIPT = \
1332-
STARRED = NAMECONSTANT = handleChildren
1332+
STARRED = NAMECONSTANT = NAMEDEXPR = handleChildren
13331333

13341334
def _handle_string_dot_format(self, node):
13351335
try:

pyflakes/test/test_other.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1754,6 +1754,15 @@ def test_f_string(self):
17541754
print(f'\x7b4*baz\N{RIGHT CURLY BRACKET}')
17551755
''')
17561756

1757+
@skipIf(version_info < (3, 8), 'new in Python 3.8')
1758+
def test_assign_expr(self):
1759+
"""Test PEP 572 assignment expressions are treated as usage / write."""
1760+
self.flakes('''
1761+
from foo import y
1762+
print(x := y)
1763+
print(x)
1764+
''')
1765+
17571766

17581767
class TestStringFormatting(TestCase):
17591768

0 commit comments

Comments
 (0)