Skip to content
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

New fstring failures #124

Closed
felixonmars opened this issue Feb 19, 2019 · 0 comments
Closed

New fstring failures #124

felixonmars opened this issue Feb 19, 2019 · 0 comments

Comments

@felixonmars
Copy link
Contributor

I'm not sure how to handle this one, so I did not submit a PR yet.

Source (from Python 3.7's dataclasses.py):
f"{f.name}={{self.{f.name}!r}}"

Parsed as:

JoinedStr(
    values=[
        FormattedValue(value=Attribute(value=Name(id='f'), attr='name'), conversion=-1, format_spec=None),
        Str(s='={self.'),
        FormattedValue(value=Attribute(value=Name(id='f'), attr='name'), conversion=-1, format_spec=None),
        Str(s='!r}')]),

which becomes a syntax error after rtrip:
f'{f.name}={self.{f.name}!r}'

  File "<fstring>", line 1
    (self.{f.name})
          ^
SyntaxError: invalid syntax
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant