-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[WIP] Keep lambda parameters on one line and parenthesize the body if it expands #21385
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
base: main
Are you sure you want to change the base?
Conversation
|
...uff_python_formatter/tests/snapshots/black_compatibility@cases__preview_long_strings.py.snap
Outdated
Show resolved
Hide resolved
b65c407 to
68e09d5
Compare
Co-authored-by: Micha Reiser <micha@reiser.io>
68e09d5 to
19326a7
Compare
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
|
I reverted the indentation changes and tried throwing in But the current state of this branch at least resolves the initial deviation from Black reported in #8179. |
| + f=lambda self, araa, kkkwargs, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, args, kwargs, e=1, f=2, g=2: ( | ||
| + d | ||
| + ), |
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.
Wrapping the body here is a bit silly since the ( and the d have the same length. But this seems like it should be quite rare in real code.
Ecosystem resultsMost of them look good with a few exceptions:
|
Summary
This PR makes two changes to our formatting of
lambdaexpressions:The latter of these fixes #8179:
Black formatting and this PR's formatting:
Stable Ruff formatting
We don't parenthesize the body expression here because the call to
aaaa...has its own parentheses, but adding a binary operator shows the new parenthesization:This is actually a new divergence from Black, which formats this input like this:
But I think this is an improvement, unlike the case from #8179.
Test Plan
New tests taken from #8465 and probably a few more I should grab from the ecosystem results.