-
Notifications
You must be signed in to change notification settings - Fork 2k
Closed
Labels
notebookRelated to (Jupyter) notebooksRelated to (Jupyter) notebooksruleImplementing or modifying a lint ruleImplementing or modifying a lint rule
Description
The new rules introduced in ruff v0.2.2 via #9266 are causing the ruff linter to make conflicting changes in notebook cells that the formatter is then trying to fix.
Here is an example notebook which reproduces the bug:

ruff config:
[tool.ruff]
extend-include = ["*.ipynb"]
[tool.ruff.lint]
select = [
"E",
]
If you run the commands in this succession and look at the diffs you will notice that the linter adds two lines at the end of:
- Cell 3 (the one just printing out the variable
some_computation). This is ruleE302in action - Cell 4 (after the function definition). This is rule
E305in action.
The commands I ran:
ruff check --force-exclude --preview --fix test.ipynbruff format --force-exclude --preview test.ipynb
(The --force-exclude is because I discovered this bug through pre-commit and I was trying to mimic the pre-commit behaviour)
This behaviour happens from v0.2.2 upwards (I've also tested v0.3.0) as long as the preview flag is on.
Let me know if the MRE needs more explanation.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
notebookRelated to (Jupyter) notebooksRelated to (Jupyter) notebooksruleImplementing or modifying a lint ruleImplementing or modifying a lint rule