The Wayback Machine - https://web.archive.org/web/20210119193612/https://github.com/realpython/python-guide/issues/931
Skip to content
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

Recommended autoformatters? #931

Open
cxong opened this issue Oct 30, 2018 · 5 comments
Open

Recommended autoformatters? #931

cxong opened this issue Oct 30, 2018 · 5 comments

Comments

@cxong
Copy link

@cxong cxong commented Oct 30, 2018

In the Code Style document https://github.com/realpython/python-guide/blob/master/docs/writing/style.rst there's a small mention of autopep8 which can be used to format code to meet PEP8 standards. But there's at least two other autoformatters (black and yapf) which are as good if not better. There's a blog comparing the three here: https://medium.com/3yourmind/auto-formatters-for-python-8925065f9505
The gist of it is: autopep8 is the most conservative, black is the most opinionated, and yapf is somewhere in between depending on how you configure it.

Should the python guide have an opinion on which auto formatters should be used? In addition to the current mention of autopep8. I think it would be good to expand this section; auto formatters are quite useful and of great interest to developers coming from tools like gofmt and prettier.

@dbader
Copy link
Member

@dbader dbader commented Oct 30, 2018

@cxong Agreed, would be great to expand this section. Personally I'm a big fan of black, I think it's awesome. If you want to put together a pull-request that expands the section that'd be fantastic!

@cxong
Copy link
Author

@cxong cxong commented Nov 1, 2018

I've only used black a little, so I don't think I have enough experience to author this section. Happy for someone else to take it up in the meantime.

@schilli91
Copy link
Contributor

@schilli91 schilli91 commented Oct 8, 2020

@dbader I'm thinking about adding a PR for this. Do you think this is still relevant? I'd add a sub section about auto-formatting giving brief instructions on how to install and use autopep8, yapf, and black.

@dbader
Copy link
Member

@dbader dbader commented Oct 8, 2020

@schilli91 Yes I think that'd be beautiful!

@schilli91
Copy link
Contributor

@schilli91 schilli91 commented Oct 11, 2020

@dbader I just opened the PR #1081. I'm happy to receive some feedback.

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

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.