mirror of https://github.com/astral-sh/ruff
Provide example for exclusive linting or formatting Notebooks (#8461)
Reference screenshot: https://github.com/astral-sh/ruff/assets/67177269/eef5ab79-77e9-4ced-be7b-a61b7bb20ecd
This commit is contained in:
parent
dd2d8cb579
commit
41e538a748
|
|
@ -219,6 +219,28 @@ extend-include = ["*.ipynb"]
|
|||
This will prompt Ruff to discover Jupyter Notebook (`.ipynb`) files in any specified
|
||||
directories, then lint and format them accordingly.
|
||||
|
||||
If you'd prefer to either only lint or only format Jupyter Notebook files, you can use the
|
||||
section specific `exclude` option to do so. For example, the following would only lint Jupyter
|
||||
Notebook files and not format them:
|
||||
|
||||
```toml
|
||||
[tool.ruff]
|
||||
extend-include = ["*.ipynb"]
|
||||
|
||||
[tool.ruff.format]
|
||||
exclude = ["*.ipynb"]
|
||||
```
|
||||
|
||||
And, conversely, the following would only format Jupyter Notebook files and not lint them:
|
||||
|
||||
```toml
|
||||
[tool.ruff]
|
||||
extend-include = ["*.ipynb"]
|
||||
|
||||
[tool.ruff.lint]
|
||||
exclude = ["*.ipynb"]
|
||||
```
|
||||
|
||||
Alternatively, pass the notebook file(s) to `ruff` on the command-line directly. For example,
|
||||
`ruff check /path/to/notebook.ipynb` will always lint `notebook.ipynb`. Similarly,
|
||||
`ruff format /path/to/notebook.ipynb` will always format `notebook.ipynb`.
|
||||
|
|
|
|||
Loading…
Reference in New Issue