-
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 undocumented deviation: annotation wrapping #7315
Comments
Thanks for reporting this deviation. Black seems to preserve parentheses in type annotation positions without ever introducing new parentheses. This is inconsistent with other places where expression appear as a direct child of a statement (other than expression statement) where Black prefers to strip any unnecessary parentheses (and applies the custom "can omit parentheses" layout). This can be solved "easily" by changing this line to use ruff/crates/ruff_python_formatter/src/statement/stmt_ann_assign.rs Lines 22 to 30 in c05e462
Changing the line accordingly improves the similarity index for typeshed by 0.00003 This is probably related to #7322 |
Copied over from #7322
animation_data = (
bpy.types.AnimData
) # TODO(jonathan): Change to Optional when fake-bpy-module is updated
|
This is a known deviation -- can be closed once it's documented. |
## Summary We decided to avoid changing this in #7315, but it's been reported multiple times (e.g., in #8226, also on Discord). I suggest we change it to improve compatibility. In general, it also seems to lend itself to better code style. Closes #8188 Closes #8226 ## Test Plan Shows improvements for CPython, home-assistant, Poetry, and typeshed. Before: | project | similarity index | total files | changed files | |----------------|------------------:|------------------:|------------------:| | cpython | 0.75803 | 1799 | 1647 | | django | 0.99983 | 2772 | 34 | | home-assistant | 0.99953 | 10596 | 186 | | poetry | 0.99891 | 317 | 17 | | transformers | 0.99966 | 2657 | 330 | | twine | 1.00000 | 33 | 0 | | typeshed | 0.99978 | 3669 | 20 | | warehouse | 0.99977 | 654 | 13 | | zulip | 0.99970 | 1459 | 22 | After: | project | similarity index | total files | changed files | |----------------|------------------:|------------------:|------------------:| | cpython | 0.75804 | 1799 | 1647 | | django | 0.99983 | 2772 | 34 | | home-assistant | 0.99960 | 10596 | 156 | | poetry | 0.99897 | 317 | 17 | | transformers | 0.99966 | 2657 | 330 | | twine | 1.00000 | 33 | 0 | | typeshed | 0.99980 | 3669 | 18 | | warehouse | 0.99977 | 654 | 13 | | zulip | 0.99970 | 1459 | 22 |
Black formatting
Ruff formatting
Use ruff 0.0.289.
Both are set to a line length of 100.
The text was updated successfully, but these errors were encountered: