black
black copied to clipboard
Fix type param formatting in funcdef with trailing comma
Description
This change adds additional checks to the decision whether to split a funcdef from the left or right-hand side.
Specifically, this adds the following condition to should_split_funcdef_with_rhs
:
If a funcdef has type parameters and its parameters also have a trailing comma, return True
, to indicate that the funcdef should not be split from the left first.
This fixes the bug described in #4254.
I am currently trying to also fix #3929 and #4071 since they seem related, but that seems to require a little more work. Any suggestions are appreciated.
Checklist - did you ...
- [x] Add an entry in
CHANGES.md
if necessary? - [x] Add / update tests if necessary?
- [-] Add new / update outdated documentation?
diff-shades reports zero changes comparing this PR (eb47bf05208ee616e86a515a466d964f68ebc45c) to main (f03ee113c9f3dfeb477f2d4247bfb7de2e5f465c).
I thought it might be best to just submit a fix for the bug and work on the other changes in a separate PR. Happy about any feedback!
Closing this in favor of #4272