Skip to content

Commit 25043d4

Browse files
author
Adrien Chauve
committed
Remove casts and fix return type of visit_JoinedStr
1 parent d6ba5fd commit 25043d4

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

mypy/fastparse.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -773,12 +773,11 @@ def visit_Str(self, n: ast35.Str) -> Union[UnicodeExpr, StrExpr]:
773773
if hasattr(ast35, 'JoinedStr'):
774774
# JoinedStr(expr* values)
775775
@with_line
776-
def visit_JoinedStr(self, n: ast35.JoinedStr) -> StrExpr:
777-
result_string_expression = StrExpr('')
778-
for value in n.values:
779-
value_as_string_expr = cast(StrExpr, self.visit(value))
780-
result_string_expression = cast(StrExpr, OpExpr('+', result_string_expression, value_as_string_expr))
781-
return result_string_expression
776+
def visit_JoinedStr(self, n: ast35.JoinedStr) -> Expression:
777+
result_expression = StrExpr('') # type: Expression
778+
for value_expr in self.translate_expr_list(n.values):
779+
result_expression = OpExpr('+', result_expression, value_expr)
780+
return result_expression
782781

783782
# FormattedValue(expr value)
784783
@with_line

0 commit comments

Comments
 (0)