-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Trailing commas in function params cause line splits in type params instead #4254
Labels
T: bug
Something isn't working
Comments
sumezulike
added a commit
to sumezulike/black
that referenced
this issue
Feb 27, 2024
2 tasks
sumezulike
added a commit
to sumezulike/black
that referenced
this issue
Mar 3, 2024
3 tasks
This was referenced May 9, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
A function with type parameters gets formatted incorrectly if the function parameters have a magic trailing comma.
To Reproduce
For example, take this code:
And run it with these arguments:
The resulting code is:
The type parameters are split instead of the function parameters.
Expected behavior
I would expect this result.
Environment
$ black --version
black, 24.2.0 (compiled: yes)
Python (CPython) 3.12.1
Additional context
I am currently drafting a PR to fix this bug.
My current approach is to rework
should_split_funcdef_with_rhs
to also check for the position of the trailing comma in type and function parameters.If I am overlooking something with that approach or if you have a better idea on how to fix this, please feel free to let me know.
The text was updated successfully, but these errors were encountered: