Skip to content

Commit b37ef10

Browse files
authored
Merge pull request #558 from facultyai/nox-format
Add format session to nox
2 parents c4fe1fa + 845405d commit b37ef10

File tree

2 files changed

+41
-14
lines changed

2 files changed

+41
-14
lines changed

.github/CONTRIBUTING.md

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ the preferred channel for [bug reports](#bug-reports), [feature requests](#featu
1717
and [submitting pull requests](#pull-requests), but please respect the following
1818
restrictions:
1919

20-
* Please **do not** use the issue tracker for personal support requests. Stack
20+
- Please **do not** use the issue tracker for personal support requests. Stack
2121
Overflow ([`plotly-dash`](https://stackoverflow.com/questions/tagged/plotly-dash) tag),
2222
or the [Plotly Community Forum](https://community.plot.ly) are better places to get help.
2323

24-
* Please **do not** derail or troll issues. Keep the discussion on topic and
24+
- Please **do not** derail or troll issues. Keep the discussion on topic and
2525
respect the opinions of others.
2626

2727
## Bug reports
@@ -52,7 +52,7 @@ miss out any of these details when filing a [new bug report][new-bug-report].
5252
## Feature requests
5353

5454
Feature requests are welcome. But take a moment to find out whether your idea
55-
fits with the scope and aims of the project. It's up to *you* to make a strong
55+
fits with the scope and aims of the project. It's up to _you_ to make a strong
5656
case to convince the project's developers of the merits of this feature. Please
5757
provide as much detail and context as possible. We have a feature request
5858
template you can use when filing a [new feature request][new-feature-request].
@@ -120,7 +120,7 @@ included in the project:
120120
```
121121

122122
7. [Open a Pull Request](https://help.github.com/articles/about-pull-requests/)
123-
with a clear title and description against the `main` branch.
123+
with a clear title and description against the `main` branch.
124124

125125
**IMPORTANT**: By submitting a patch, you agree to allow the project owners to
126126
license your work under the terms of the [Apache 2.0 License](../LICENSE).
@@ -129,15 +129,34 @@ license your work under the terms of the [Apache 2.0 License](../LICENSE).
129129

130130
### Python
131131

132-
Please use [black](https://github.com/python/black) with `--line-length 79` to
133-
format any Python code. To do so, simply run the following from the root of
134-
the repository
132+
We use [`nox`](https://nox.thea.codes/en/stable/) to test and line Python code.
135133

136134
```sh
137-
pip install black
138-
black --line-length 79 .
135+
pip install nox
139136
```
140137

138+
Code is linted using `black`, `flake8`, and `isort`. Run the linters with
139+
140+
```sh
141+
nox -s lint
142+
```
143+
144+
Many formatting issues can be fixed automatically by `black` and `isort`. Run
145+
them with
146+
147+
```sh
148+
nox -s format
149+
```
150+
151+
Finally you can run the Python tests locally for a particular version of Python
152+
with
153+
154+
```sh
155+
nox -s test-3.8
156+
```
157+
158+
and similarly for other versions.
159+
141160
### JS
142161

143162
Prettier to format JavaScript code as configured in `.prettierrc`. You can lint
@@ -155,27 +174,26 @@ npm run format
155174

156175
### Run tests
157176

158-
Run `npm run test` before committing to ensure your changes follow our coding
159-
standards and pass our tests.
177+
Run `npm run test` before committing to ensure your changes pass our tests.
160178

161179
## Building dash-bootstrap-components locally
162180

163181
To build _dash-bootstrap-components_ locally, first install the Python
164182
development dependencies
165183

166-
```
184+
```sh
167185
python -m pip install -r requirements-dev.txt
168186
```
169187

170188
Then install JavaScript dependencies
171189

172-
```
190+
```sh
173191
npm install
174192
```
175193

176194
You can now build Python, R and Julia packages with
177195

178-
```
196+
```sh
179197
npm run build
180198
```
181199

noxfile.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import nox
22

3+
nox.options.sessions = ["lint", "test"]
4+
35
SOURCES = [
46
"dash_bootstrap_components",
57
"docs",
@@ -17,6 +19,13 @@ def lint(session):
1719
session.run("isort", "--check", *SOURCES)
1820

1921

22+
@nox.session(name="format")
23+
def format_(session):
24+
session.install("black", "isort")
25+
session.run("black", *SOURCES)
26+
session.run("isort", *SOURCES)
27+
28+
2029
@nox.session(python=["2.7", "3.5", "3.6", "3.7", "3.8", "3.9"])
2130
def test(session):
2231
session.install("pytest")

0 commit comments

Comments
 (0)