From 41e538a748331d323eabd27cc66cd36996bacbe9 Mon Sep 17 00:00:00 2001 From: Dhruv Manilawala Date: Fri, 3 Nov 2023 16:56:20 +0530 Subject: [PATCH] Provide example for exclusive linting or formatting Notebooks (#8461) Reference screenshot: https://github.com/astral-sh/ruff/assets/67177269/eef5ab79-77e9-4ced-be7b-a61b7bb20ecd --- docs/configuration.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/docs/configuration.md b/docs/configuration.md index 6fe954c38f..68de7de259 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -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`.