Skip to content

Commit d6ba5fd

Browse files
author
Adrien Chauve
committed
Use casts to fix typechecking of visitor method
-> should we use a more complex solution by building an ast expression of `str(...)` to get rid of the casts?
1 parent e8cb282 commit d6ba5fd

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

mypy/fastparse.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,8 @@ def visit_Str(self, n: ast35.Str) -> Union[UnicodeExpr, StrExpr]:
776776
def visit_JoinedStr(self, n: ast35.JoinedStr) -> StrExpr:
777777
result_string_expression = StrExpr('')
778778
for value in n.values:
779-
result_string_expression = OpExpr('+', result_string_expression, self.visit(value))
779+
value_as_string_expr = cast(StrExpr, self.visit(value))
780+
result_string_expression = cast(StrExpr, OpExpr('+', result_string_expression, value_as_string_expr))
780781
return result_string_expression
781782

782783
# FormattedValue(expr value)

0 commit comments

Comments
 (0)