Require black and isort for contributions (#3329)

* Add explanation to CONTRIBUTNG.md
* Add sample pre-commit script
* Check for correctly formatted files in CI

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
This commit is contained in:
Sebastian Rittau
2020-06-29 00:28:28 +02:00
committed by GitHub
parent 5d553c9584
commit 4586ed9adc
6 changed files with 48 additions and 12 deletions

View File

@@ -15,6 +15,7 @@ are important to the project's success.
but [contact us](#discussion) before starting significant work.
* Create your stubs [conforming to the coding style](#stub-file-coding-style).
* Make sure your tests pass cleanly on `mypy`, `pytype`, and `flake8`.
* Reformat your stubs with `black` and `isort`.
4. [Submit your changes](#submitting-changes) by opening a pull request.
5. You can expect a reply within a few days:
* Diffs are merged when considered ready by the core team.
@@ -222,8 +223,14 @@ rule is that they should be as concise as possible. Specifically:
* use variable annotations instead of type comments, even for stubs
that target older versions of Python;
* for arguments with a type and a default, use spaces around the `=`.
The code formatter [black](https://github.com/psf/black) will format
stubs according to this standard.
Stubs should be reformatted with the formatters
[black](https://github.com/psf/black) and
[isort](https://github.com/timothycrosley/isort) before submission.
These formatters are included in typeshed's `requirements-tests-py3.txt` file.
A sample `pre-commit` file is included in the typeshed repository. Copy it
to `.git/hooks` and adjust the path to your virtual environment's `bin`
directory to automatically reformat stubs before commit.
Stub files should only contain information necessary for the type
checker, and leave out unnecessary detail: