-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Parenthesize long type annotations in annotated assignments #9210
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a huge fan of this change but it is consistent to how we would format the same assignment when Decimal
is the assigned value
Input
safe_age = Decimal # the user's age....
29a97ed
to
9ddc579
Compare
9ddc579
to
8e14838
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.