-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Fix internal magic commas not being force expanded #3377
base: main
Are you sure you want to change the base?
Conversation
Copied the examples from the bug report and added an additional test case with the failing behavior multiple times in the same expression.
Can someone verify that the test output is correct? I checked some simplified versions of the test and used that was my reference for what the output should be. |
Black always uses double quotes. Test would also fail on this, but that's not the reason the test is failing to begin with.
Does this overlap with #3370? |
So I did some code coverage comparison and lines 207 and 208 in Lines 195 to 210 in 8429ebc
I ran two test minimal test cases with code coverage, shown below.
The failing test did not run lines 207 and 208, while the passing test did. Some other test cases which more clearly show the issue are below.
|
Some other missed lines in the buggy test case are 116 and 216 in |
So a clear point where things go wrong is in |
Correct output was missing a parentheses group in the original.
Fix `omit` generator exiting early after seeing two consecutive non-empty bracket pairs before seeing a magic comma. This does cause a regression with `trailing_comma_optional_parens2` and it still does not fix lines with multiple magic commas.
So the problem that I'm finding is that
I moved the
|
So in general, in the case of several magic commas on the same line, unless there is not enough room on the line, only the rightmost one will be forcefully split. Is this intended behavior? The documentation suggests that Black will always expand the collection to fit, but this is clearly not the case. |
diff-shades results comparing this PR (48042ee) to main (2793249). The full diff is available in the logs under the "Generate HTML diff report" step.
|
I looked at a few of the diff-shades changes and I'm unfortunately not a fan; they mostly seem like gratuitous changes that don't make the formatting better. Can this fix be limited to only cases where a magic trailing comma is present? |
I'm not sure what changes to make at this point. One problem has to do with sibling-level magic trailing commas. In Another problem is that the "fix" that I made changes how long lines are handled by always returning all trailers found by
|
Description
Fix for issue #3268, #2052
As per the Black spec
This means the current formatting output (the code below)
should instead be
Checklist - did you ...
CHANGES.md
if necessary?