-
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
formatter prefers to break annotation over arguments list #6352
Comments
I'm pretty sure Black is changing this in their next version. Try running Black with the |
i see the same behaviour even with ( |
This shouldn't be to hard to fix. The arguments group must enclose the arguments and the return type annotation. This will make the printer to expand from left to right (outer most before inner groups) |
https://black.readthedocs.io/en/stable/the_black_code_style/future_style.html#improved-line-breaks Ah, I see, I guess this only applies to assignment. I assumed it would be similar for function definitions. |
not sure i quote follow what you mean by "the arguments group". i tried wrapping ruff/crates/ruff_python_formatter/src/statement/stmt_function_def.rs Lines 84 to 86 in 1ac2699
|
The formatting of |
sorry i can't get it to work. might have to leave for someone else |
I'll give it a look. |
I don't quite understand how to make the composition work here given that |
I will revisit this today. |
You probably need to pull in the relevant parts from parenthesized into the function formatting. It's different enough. We did that previously with other formatting too (I can't recall out of my head which formatting it was but it manually creates the groups and sets the node level) |
) ## Summary This PR removes the group around function definition parameters, instead grouping the parameters with the type parameters and return type annotation. This increases Zulip's similarity score from 0.99385 to 0.99699, so it's a meaningful improvement. However, there's at least one stability error that I'm working on, and I'm really just looking for high-level feedback at this point, because I'm not happy with the solution. Closes #6352. ## Test Plan Before: - `zulip`: 0.99396 - `django`: 0.99784 - `warehouse`: 0.99578 - `build`: 0.75436 - `transformers`: 0.99407 - `cpython`: 0.75987 - `typeshed`: 0.74432 After: - `zulip`: 0.99702 - `django`: 0.99784 - `warehouse`: 0.99585 - `build`: 0.75623 - `transformers`: 0.99470 - `cpython`: 0.75988 - `typeshed`: 0.74853
…tral-sh#6410) ## Summary This PR removes the group around function definition parameters, instead grouping the parameters with the type parameters and return type annotation. This increases Zulip's similarity score from 0.99385 to 0.99699, so it's a meaningful improvement. However, there's at least one stability error that I'm working on, and I'm really just looking for high-level feedback at this point, because I'm not happy with the solution. Closes astral-sh#6352. ## Test Plan Before: - `zulip`: 0.99396 - `django`: 0.99784 - `warehouse`: 0.99578 - `build`: 0.75436 - `transformers`: 0.99407 - `cpython`: 0.75987 - `typeshed`: 0.74432 After: - `zulip`: 0.99702 - `django`: 0.99784 - `warehouse`: 0.99585 - `build`: 0.75623 - `transformers`: 0.99470 - `cpython`: 0.75988 - `typeshed`: 0.74853
input:
black (better choice imo)
ruff
The text was updated successfully, but these errors were encountered: