Skip to content

Linting on Jupyter Notebook fails after reordering cells #12573

@michue-work

Description

@michue-work

Hello, today I activated Ruff for Jupyter Notebooks and noticed some strange behavior I didn't see with normal Python files:

After reordering the cells of a notebook, the editor window shows false-positives from Ruff linting.

MWE
pyproject.toml

[tool.ruff]
extend-include = [
    "*.ipynb",
]

ruff.ipynb (with --- denoting a new cell)

import random
---
f = random.random()
---
g = random.random()

After moving the third cell with g = ... to the second position, Ruff reports F401 on import random.

Environment
Operating System Windows_NT x64 10.0.19045
VS Code 1.91.1 (commit f1e16e1e6214d7c44d078b1f0607b2388f29d729)
Ruff extension v2024.36.0

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingserverRelated to the LSP server

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions