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

--refactor runs into an error with some f-string syntax like f"{var=}" #31

Closed
TheSkeward opened this issue Mar 4, 2022 · 3 comments
Closed

Comments

@TheSkeward
Copy link

I have a line of code in my project that looks like:

logging.info(f"{OMEGA.message_cache=}, {len(OMEGA.user_cache)=}, "
                 f"{OMEGA.message_cache / max(len(OMEGA.user_cache), 1)=}")

shed works fine but when using shed --refactor it stalls here:

Internal error formatting 'main.py': ParserSyntaxError: Syntax Error @ 794:31.
Incomplete input. Encountered '=', but expected '!', ':', or '}'.

        f"{OMEGA.message_cache=}, {len(OMEGA.user_cache)=}, "
                              ^
    Please report this to https://github.com/Zac-HD/shed/issues
@Zac-HD
Copy link
Owner

Zac-HD commented Mar 4, 2022

Hmm, looks like failed version detection. Does passing --py38-plus fix it, as a quick workaround?

@TheSkeward
Copy link
Author

yep, works fine with shed --refactor --py38-plus

@Zac-HD
Copy link
Owner

Zac-HD commented Mar 5, 2022

Yep, the underlying problem is that Black doesn't detect f-strings with = as requiring Python 3.8.

I've just released shed 0.9.2 with a workaround, 5724e7f. Thanks for the report, and happy formatting!

@Zac-HD Zac-HD closed this as completed Mar 5, 2022
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

2 participants