remove magic comma in some places #5880
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I discovered these while working on #5879.
By default
black
treats a trailing comma in a sequence as "magic" and explodes it regardless of the number of items in it. This is usually useful if you want to communicate that a sequence might grow in the future and you than only need to add a new line rather than reformatting the sequence.However, sometimes the original author did not intend this and in turn
black
turns legible code into a mess. This PR fixes two instances where the new format is especially bad. In general, we can detect all such cases by runningblack -C
and looking at the differences. There are 105 files in thetorchvision
package that will be formatted. I haven't looked at the diffs to see how bad the situation is.