Skip to content

Commit fc03182

Browse files
author
Adrien Chauve
committed
Handle python 3.6 f-strings without error
1 parent f887e87 commit fc03182

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

mypy/fastparse.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,11 @@ def visit_Str(self, n: ast35.Str) -> Union[UnicodeExpr, StrExpr]:
769769
else:
770770
return UnicodeExpr(n.s)
771771

772+
# JoinedStr(expr* values)
773+
@with_line
774+
def visit_JoinedStr(self, n: ast35.JoinedStr) -> StrExpr:
775+
return StrExpr(n.values[0])
776+
772777
# Bytes(bytes s)
773778
@with_line
774779
def visit_Bytes(self, n: ast35.Bytes) -> Union[BytesExpr, StrExpr]:

test-data/unit/check-expressions.test

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,6 +1157,15 @@ b'%c' % (123)
11571157
[case testUnicodeInterpolation_python2]
11581158
u'%s' % (u'abc',)
11591159

1160+
1161+
-- F-String
1162+
-- --------
1163+
1164+
1165+
[case testFStringParseOk]
1166+
a = f'foobar'
1167+
1168+
11601169
-- Lambdas
11611170
-- -------
11621171

0 commit comments

Comments
 (0)