-
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: wrapping on type hint #8226
Comments
henryiii
changed the title
formatter: wrapping on type hint (deviation from Black)
formatter: wrapping on type hint
Oct 25, 2023
I think this is a consequence of https://docs.astral.sh/ruff/formatter/black/#type-annotations-may-be-parenthesized-when-expanded, but it's not great in cases like this. |
Merging into #8188 |
5 tasks
charliermarsh
added a commit
that referenced
this issue
Oct 26, 2023
## 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The following Black'd (23.*) code:
is converted by
ruff format
(0.1.2) into:Pretty sure that's not intentional? Wrapping on the type hint looks terrible, IMO. :)
PS: While Black produces the code on the top, it will not rewrite the code on the bottom into the top.
The text was updated successfully, but these errors were encountered: