Skip to content

Commit 434bbb0

Browse files
jgarstjayvdb
authored andcommitted
Fix format string checking (#80)
format strings (PEP 498) defines a new AST node, JOINEDSTR which contains a list of string expressions.
1 parent 2f50952 commit 434bbb0

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

pyflakes/checker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -937,7 +937,7 @@ def ignore(self, node):
937937
MATMULT = ignore
938938

939939
# additional node types
940-
COMPREHENSION = KEYWORD = FORMATTEDVALUE = handleChildren
940+
COMPREHENSION = KEYWORD = FORMATTEDVALUE = JOINEDSTR = handleChildren
941941

942942
def DICT(self, node):
943943
# Complain if there are duplicate keys with different values

pyflakes/test/test_other.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1800,3 +1800,11 @@ def test_matmul(self):
18001800
def foo(a, b):
18011801
return a @ b
18021802
''')
1803+
1804+
@skipIf(version_info < (3, 6), 'new in Python 3.6')
1805+
def test_formatstring(self):
1806+
self.flakes('''
1807+
hi = 'hi'
1808+
mom = 'mom'
1809+
f'{hi} {mom}'
1810+
''')

0 commit comments

Comments
 (0)