Skip to content

Use black for autoformatting #53

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

Closed
wants to merge 2 commits into from
Closed

Use black for autoformatting #53

wants to merge 2 commits into from

Conversation

alok
Copy link
Contributor

@alok alok commented Aug 7, 2019

black has become popular enough for
Python formatting that it was officially adopted by the PSF, and is
being used to format the standard library. I like it because it makes
code that's very consistent to read, which makes development ever so
slightly easier for everyone.

In case this PR is desired but the actual formatting changes interfere
with other current branches, I can rebase to leave out the actual
formatting for now.

@williamFalcon
Copy link
Contributor

thanks for the PR.

2 things:

  1. does this conflict with pep8? we already have that coming in a different PR.
  2. make sure to submit proposals and that we both agree on the improvement before adding any future PRs. that way we can deconflict and align with the project goals.

but nevertheless, thanks for contributing!

@williamFalcon
Copy link
Contributor

williamFalcon commented Aug 7, 2019

if we do bring this in, let's use single quotes not double quotes.

@alok also, please resolve the conflicts first.

@alok
Copy link
Contributor Author

alok commented Aug 7, 2019

Yeah normally I'd discuss first but this was a really quick PR since I've set it up for other projects before. Black is a stricter subset of pep 8 that's meant to make reading diffs as easy as possible. It's not the prettiest style, but like gofmt, is meant to eliminate pointless style debates.

The tool doesn't use single quotes on purpose and it has some reasoning on its readme, but FWIW you can use any quote style you want and it'll change it at the end.

@alok
Copy link
Contributor Author

alok commented Aug 7, 2019

If you look at it and decide you want it, let me know and I'll rebase.

@Borda
Copy link
Member

Borda commented Aug 7, 2019

you can run black with the parameter -S which should hold whatever ' or " you have
and black is just another PEP8 formatting utility, but in particular, it adds something extra like splitting lines (which personally I do not like very much)

@williamFalcon
Copy link
Contributor

@alok thanks for this but we're going to pass at the moment. In the future get a verbal ok from me so we both agree on a new feature.

We're done adding formatting and engineering "best practices" to the package. @Borda has already added the last few missing pieces for better test coverage and package stability. From here forward let's focus on feature or speed improvements in the package.

luiscape pushed a commit to luiscape/pytorch-lightning that referenced this pull request Jan 17, 2020
@hadim
Copy link
Contributor

hadim commented Feb 15, 2020

In CONTRIBUTING.md, you say to lint the code with flake8. But you don't say anything about Python formatting tools such as black, autopep8 or yapf?

It would be nice to agree on one so it's easy to format the code the same way for everyone when contributing to the project. I also found I save time when developing using such a tool.

I personally like black because it has no configuration and works just well. I would be fine configuring my IDE to use another one for this project. But that would be nice if you guys can decide on one.

(I can also open a new issue if needed)

@Borda
Copy link
Member

Borda commented Feb 15, 2020

We have been using black in a company and personally don't line some splitting lines which makes too long and harder to navigate... On the other hand it make sense to relay on some tool so I will check autopep8 and yarf :)

@Borda
Copy link
Member

Borda commented Feb 15, 2020

Black is formatting the code similar to autopep8 but is moving the closing brackets to a new line and also does not format the tuple in an unnecessary way. Yapf with the Facebook setting is formatting very similar to black here but is not changing the quotes here again. The only difference which happened

https://medium.com/3yourmind/auto-formatters-for-python-8925065f9505

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants