Skip to content

Panic when Jupyter notebook contains only a single empty code cell #4556

@dhruvmanila

Description

@dhruvmanila

Jupyter notebook content (1 empty code cell):

Command:

$ cargo run --all-features --bin ruff -- check --select=ALL /path/to/notebook.ipynb

Output:

    Finished dev [unoptimized + debuginfo] target(s) in 0.37s
     Running `target/debug/ruff check --select=ALL /Users/dhruv/playground/python/ruff_test.ipynb`
warning: `one-blank-line-before-class` (D203) and `no-blank-line-before-class` (D211) are incompatible. Ignoring `one-blank-line-before-class`.
warning: `multi-line-summary-first-line` (D212) and `multi-line-summary-second-line` (D213) are incompatible. Ignoring `multi-line-summary-second-line`.
warning: Detected debug build without --no-cache.

error: `ruff` crashed. This indicates a bug in `ruff`. If you could open an issue at:

https://github.com/charliermarsh/ruff/issues/new?title=%5BPanic%5D

quoting the executed command, along with the relevant file contents and `pyproject.toml` settings, we'd be very appreciative!

thread 'main' panicked at 'index out of bounds: the len is 1 but the index is 1', crates/ruff/src/message/text.rs:73:32
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
/Users/dhruv/playground/python/ruff_test.ipynb:%                                                                                                                                                

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions