Add auto-formatting via isort and black#3062
Add auto-formatting via isort and black#3062Eric-Arellano wants to merge 11 commits intopython:masterfrom Eric-Arellano:autoformat
Conversation
We run both isort and black on the same shard because there is a nontrivial startup cost to adding an additional shard. It reduces the available worker pool and each shard takes some time to clone the repository and get set up properly.
|
Reviewers: GitHub's review page puts all of the non-automated changes at the top of the review. Alternatively, each commit may be meaningfully reviewed independently. |
They handle comments in the import section differently. The best solution for now is to turn off Black, because isort has the more desirable behavior.
This complies more with the original style. The only reason I didn't have this on was that I didn't know it was an option.
|
I'm not able to figure out the Pytype issue. It doesn't appear to be due to trailing commas, which is what I was suspecting, as setting black's I've been struggling to understand (On that note, thoughts on requiring Python 3.6 for these scripts so that we can use f-strings?) -- I also can't figure out why isort is trying to change three files in CI: https://travis-ci.org/python/typeshed/jobs/546514620#L265. Locally, isort isn't making the same changes. |
|
Regarding the pytype issue - I wasn't able to tell from the Travis logs what the specific problem(s) are this time, but pytype has a custom pyi parser that only recognizes a subset of the Python grammar. (Someday we'll find time to to replace the custom parser with something more maintainable like typed_ast...) Feel free to open issues against https://github.com/google/pytype if you can figure out what constructs pytype is barfing on. |
|
I think we should split this PR:
|
Agreed, I prefer a smaller diff. I'll close this PR so that we have it still for reference. I would tweak the order to go 1) procedural, 2) Big Reformat, 3) documentation (and/or bot and/or script to simplify running tests and autormatters) + Travis. Shouldn't document how to run for users until it's guaranteed that them running the tool won't cause unrelated files to change, which is a jarring experience.
Sounds good. Before we can do that, we must fix the pytype issues. The feedback is much more useful with Thanks! |
Will close #3058.
Autoformatting makes it easier for readers to have a consistent code style and easier for developers to not waste time dealing with formatting.
We achieve this via isort and black, with a new
pyproject.tomlto configure both to use a line limit of 130.Followup: script to run tests and autoformatters
This change adds two additional steps that we expect contributors to do before submitting a PR. Instead, to make it easier for contributors, we can automate much of the validation flow via a new script, as proposed in #3058 (comment).