Skip to content

Commit 71690a8

Browse files
Balandatfacebook-github-bot
authored andcommitted
Update CONTRIBUTING with latest formatting / linting practices. (pytorch#1798)
Summary: Updated to simply run `ufmt` instead of `black` separately. Some other minor updates. Pull Request resolved: pytorch#1798 Reviewed By: sdaulton Differential Revision: D45095294 Pulled By: Balandat fbshipit-source-id: 2b08dc1d0a5c7be66892e771581c5f411dee75a3
1 parent a58d034 commit 71690a8

File tree

1 file changed

+21
-26
lines changed

1 file changed

+21
-26
lines changed

CONTRIBUTING.md

+21-26
Original file line numberDiff line numberDiff line change
@@ -18,44 +18,39 @@ pip install -e .[dev]
1818

1919
#### Code Style
2020

21-
BoTorch uses the [black](https://github.com/ambv/black) code formatter to
22-
enforce a common code style across the code base. black is installed easily via
23-
pip using `pip install black`, and run locally by calling
21+
BoTorch uses [ufmt](https://github.com/omnilib/ufmt) to enforce consistent
22+
code formatting (based on [black](https://github.com/ambv/black)) and
23+
import sorting (based on [µsort](https://github.com/facebook/usort))
24+
across the code base. Install via `pip install ufmt`, and
25+
auto-format and auto-sort by running
2426
```bash
25-
black .
26-
```
27-
from the repository root. No additional configuration should be needed (see the
28-
[black documentation](https://black.readthedocs.io/en/stable/installation_and_usage.html#usage)
29-
for advanced usage).
30-
31-
Docstring formatting: We recommend [Google-style](https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html) docstrings.
32-
To make sure documentation is rendered correctly, we require that every `__init__`
33-
function contains an "Args" block.
34-
We use `flake8-docstrings` to check this, as well as `flake8` to check code style. To use these tools, run
35-
`pip install flake8` and `pip install flake8-docstrings`, and then run
36-
```bash
37-
flake8 .
27+
ufmt format .
3828
```
29+
from the repository root.
3930

4031

41-
#### Import Sorting
32+
#### Flake8 linting
4233

43-
BoTorch uses [ufmt]https://github.com/omnilib/ufmt library for consistent
44-
sorting of imports across the codebase. Install via `pip install ufmt`, and
45-
auto-sort with
34+
BoTorch uses `flake8` for linting. To run the linter locally, install
35+
`flake8` via `pip install flake8`, and then run
4636
```bash
47-
ufmt format .
37+
flake8 .
4838
```
4939
from the repository root.
5040

51-
We feel strongly that having a consistent code style and imports is important,
52-
so CI will fail on your PR if it does not pass ufmt muster (note: under the
53-
hood ufmt also checks black code style).
41+
42+
#### Docstring formatting
43+
44+
BoTorch uses [Google-style](https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html) docstrings.
45+
To make sure documentation is rendered correctly, we require that every
46+
`__init__` function contains an `Args:` block. We use the `flake8-docstrings`
47+
plugin to check this - install via `pip install flake8-docstrings` and
48+
run `flake8` as above to check.
5449

5550

5651
#### Type Hints
5752

58-
BoTorch is fully typed using python 3.7+
53+
BoTorch is fully typed using python 3.8+
5954
[type hints](https://www.python.org/dev/peps/pep-0484/).
6055
We expect any contributions to also use proper type annotations. While we
6156
currently do not enforce full consistency of these in our continuous integration
@@ -112,7 +107,7 @@ We actively welcome your pull requests.
112107
3. If you have changed APIs, update the documentation. Make sure the
113108
documentation builds.
114109
4. Ensure the test suite passes.
115-
5. Make sure your code passes both `black` and `flake8` formatting checks.
110+
5. Make sure your code passes both `ufmt` and `flake8` formatting checks.
116111
6. If you haven't already, complete the Contributor License Agreement ("CLA").
117112

118113

0 commit comments

Comments
 (0)