New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse each format-string component separately #3390

Merged
merged 5 commits into from May 30, 2017
Jump to file or symbol
Failed to load files and symbols.
+5 −5
Diff settings

Always

Just for now

Viewing a subset of changes. View all

change docstrings to comments

  • Loading branch information...
lincolnq committed May 27, 2017
commit 4822afd648518ce004247cbd20b7d75ba090108f
View
@@ -858,8 +858,8 @@ def visit_Str(self, n: ast3.Str) -> Union[UnicodeExpr, StrExpr]:
# JoinedStr(expr* values)
@with_line
def visit_JoinedStr(self, n: ast3.JoinedStr) -> Expression:
"""Each of n.values is a str or FormattedValue; we just concatenate
them all using ''.join."""
# Each of n.values is a str or FormattedValue; we just concatenate
# them all using ''.join.
empty_string = StrExpr('')
empty_string.set_line(n.lineno, n.col_offset)
strs_to_join = ListExpr(self.translate_expr_list(n.values))
@@ -874,9 +874,9 @@ def visit_JoinedStr(self, n: ast3.JoinedStr) -> Expression:
# FormattedValue(expr value)
@with_line
def visit_FormattedValue(self, n: ast3.FormattedValue) -> Expression:
"""A FormattedValue is a component of a JoinedStr, or it can exist
on its own. We translate them to individual '{}'.format(value)
calls -- we don't bother with the conversion/format_spec fields."""
# A FormattedValue is a component of a JoinedStr, or it can exist
# on its own. We translate them to individual '{}'.format(value)
# calls -- we don't bother with the conversion/format_spec fields.
exp = self.visit(n.value)
exp.set_line(n.lineno, n.col_offset)
format_string = StrExpr('{}')
ProTip! Use n and p to navigate between commits in a pull request.