Parenthesize long type annotations in annotated assignments#9210
Conversation
|
95130ad to
d3ce8c9
Compare
| class Test: | ||
| - safe_age: Decimal # the user's age, used to determine if it's safe for them to use ruff | ||
| + safe_age: ( | ||
| + Decimal # the user's age, used to determine if it's safe for them to use ruff |
There was a problem hiding this comment.
I'm not a huge fan of this change but it is consistent to how we would format the same assignment when Decimalis the assigned value
Input
safe_age = Decimal # the user's age....29a97ed to
9ddc579
Compare
9ddc579 to
8e14838
Compare
charliermarsh
left a comment
There was a problem hiding this comment.
Nice, this looks good to me. Thanks for all the clear comments around the intended preview behavior. I wonder if we'd see more ecosystem changes by including the function parameter annotations... maybe?
Yeah, there are more changes if you include the function parameters. It's not a ton but a couple of 100 changed lines. |
Summary
This PR implements #8894 for annotated assignments. It intentionally excludes annotations in function definition because we're internally discussing whether we support the changes or not.
Test Plan
Ran the ecosystem check and there are.... no changes! Which is rather disappointing. I checked the diff shades output from the Black changes and verified that ruff formats the one shade the same as black.
I ran the similarity index script and verified that the numbers remain unchanged.