diff --git a/docs/configuration.md b/docs/configuration.md index 20ee6ba11a..3c95d5ca87 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -328,6 +328,24 @@ By default, Ruff will also skip any files that are omitted via `.ignore`, `.giti Files that are passed to `ruff` directly are always linted, regardless of the above criteria. For example, `ruff check /path/to/excluded/file.py` will always lint `file.py`. +## Jupyter Notebook discovery + +Ruff has built-in experimental support for linting [Jupyter Notebooks](https://jupyter.org/). + +To opt in to linting Jupyter Notebook (`.ipynb`) files, add the `*.ipynb` pattern to your +[`include`](settings.md#include) setting, like so: + +```toml +[tool.ruff] +include = ["*.py", "*.pyi", "**/pyproject.toml", "*.ipynb"] +``` + +This will prompt Ruff to discover Jupyter Notebook (`.ipynb`) files in any specified +directories, and lint them accordingly. + +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`. + ## Rule selection The set of enabled rules is controlled via the [`select`](settings.md#select) and diff --git a/docs/faq.md b/docs/faq.md index e0fe13380a..8d6e7b3652 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -309,7 +309,23 @@ src = ["../src", "../test"] ## Does Ruff support Jupyter Notebooks? -Ruff is integrated into [nbQA](https://github.com/nbQA-dev/nbQA), a tool for running linters and +Ruff has built-in experimental support for linting [Jupyter Notebooks](https://jupyter.org/). + +To opt in to linting Jupyter Notebook (`.ipynb`) files, add the `*.ipynb` pattern to your +[`include`](settings.md#include) setting, like so: + +```toml +[tool.ruff] +include = ["*.py", "*.pyi", "**/pyproject.toml", "*.ipynb"] +``` + +This will prompt Ruff to discover Jupyter Notebook (`.ipynb`) files in any specified +directories, and lint them accordingly. + +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`. + +Ruff also integrates with [nbQA](https://github.com/nbQA-dev/nbQA), a tool for running linters and code formatters over Jupyter Notebooks. After installing `ruff` and `nbqa`, you can run Ruff over a notebook like so: