Skip to content

Commit 41e538a

Browse files
authored
Provide example for exclusive linting or formatting Notebooks (#8461)
Reference screenshot: https://github.com/astral-sh/ruff/assets/67177269/eef5ab79-77e9-4ced-be7b-a61b7bb20ecd
1 parent dd2d8cb commit 41e538a

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

docs/configuration.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,28 @@ extend-include = ["*.ipynb"]
219219
This will prompt Ruff to discover Jupyter Notebook (`.ipynb`) files in any specified
220220
directories, then lint and format them accordingly.
221221

222+
If you'd prefer to either only lint or only format Jupyter Notebook files, you can use the
223+
section specific `exclude` option to do so. For example, the following would only lint Jupyter
224+
Notebook files and not format them:
225+
226+
```toml
227+
[tool.ruff]
228+
extend-include = ["*.ipynb"]
229+
230+
[tool.ruff.format]
231+
exclude = ["*.ipynb"]
232+
```
233+
234+
And, conversely, the following would only format Jupyter Notebook files and not lint them:
235+
236+
```toml
237+
[tool.ruff]
238+
extend-include = ["*.ipynb"]
239+
240+
[tool.ruff.lint]
241+
exclude = ["*.ipynb"]
242+
```
243+
222244
Alternatively, pass the notebook file(s) to `ruff` on the command-line directly. For example,
223245
`ruff check /path/to/notebook.ipynb` will always lint `notebook.ipynb`. Similarly,
224246
`ruff format /path/to/notebook.ipynb` will always format `notebook.ipynb`.

0 commit comments

Comments
 (0)