Skip to content

Conversation

pmeier
Copy link
Collaborator

@pmeier pmeier commented Apr 26, 2022

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 running black -C and looking at the differences. There are 105 files in the torchvision package that will be formatted. I haven't looked at the diffs to see how bad the situation is.

Copy link
Member

@NicolasHug NicolasHug left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

black turns legible code into a mess

image

(Couldn't resist trolling)

Thanks Philip, LGTM!

@pmeier pmeier merged commit 01b0a00 into pytorch:main Apr 26, 2022
@pmeier pmeier deleted the remove-magic-comma branch April 26, 2022 09:14
@github-actions
Copy link

Hey @pmeier!

You merged this PR, but no labels were added. The list of valid labels is available at https://github.com/pytorch/vision/blob/main/.github/process_commit.py

facebook-github-bot pushed a commit that referenced this pull request May 6, 2022
Reviewed By: jdsgomes, NicolasHug

Differential Revision: D36095662

fbshipit-source-id: aa1d3fb99f743c0a7108011581b8db6da9d3d3b8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants