-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Formatter: Target version support #7234
Comments
Do we have a list of syntax that would change formatter behaviour that is not in 3.7/3.8? I can only think of nested f-string quotes in 3.12 |
f-strings will be fun because they now can contain comments too, yeah. I don't have more than what's outlined in the issue above and is derived from Black's documentation. We could do a quick search on Black's repository to identify other version-specific formatting (or look at their version-specific tests) |
Parenthesized with items (mentioned above) -- need to make sure we don't introduce parentheses there if unsupported. I don't know if this needs changes or not, but it was new in Python 3.10. (They have See also |
|
I've confirmed that the unparenthesized walruses is handled correctly (we never remove those parentheses, so we're fine). |
We also get the |
As far as I can tell, there's nothing that we need to do here, assuming...
Some notes on Black's behavior:
This last piece ( For example, given: with a as b, c as d, e(1,) as f:
pass Black stable formats as: with a as b, c as d, e(
1,
) as f:
pass But preview gives you: with (
a as b,
c as d,
e(
1,
) as f,
):
pass |
This may no longer be true if we implement #7243
I'm unsure whether I would expect my formatter to downgrade the syntax. I guess mainly because I'm just not used to having this setting in a formatter. Removing parentheses raises interesting question when it comes to comments, especially leading and trailing commnts |
What's the status on this? Do we plan to support this for the Beta? |
My assessment is that there's nothing to do here until we support preview style. |
Adjust the formatting based on the syntax supported by the targeted python versions.
Source
Relevant features:
The text was updated successfully, but these errors were encountered: