Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect --show-source for Jupyter Notebooks with continuous import blocks #5875

Closed
dhruvmanila opened this issue Jul 19, 2023 · 1 comment · Fixed by #5876
Closed

Incorrect --show-source for Jupyter Notebooks with continuous import blocks #5875

dhruvmanila opened this issue Jul 19, 2023 · 1 comment · Fixed by #5876
Assignees
Labels
bug Something isn't working core Related to core functionality

Comments

@dhruvmanila
Copy link
Member

Take the test case as an example where there are two cells with unsorted imports.

When run using the following command:

cargo run --bin ruff -- check --select=I001 --no-cache --isolated crates/ruff/resources/test/fixtures/jupyter/isort.ipynb --show-source

The output is a single diagnostic:

crates/ruff/resources/test/fixtures/jupyter/isort.ipynb:cell 1:1:1: I001 [*] Import block is un-sorted or un-formatted
  |
1 | / from pathlib import Path
2 | | import random
3 | | import math
4 | | from typing import Any
5 | | import collections
6 | | # Newline should be added here
  | |_^ I001
7 |   def foo():
8 |       pass
  |
  = help: Organize imports

Found 1 error.
[*] 1 potentially fixable with the --fix option.

While there are 2 import blocks (separated by a cell boundary). The fix produces the correct number which is 2:

$ cargo run --bin ruff -- check --select=I001 --no-cache --isolated crates/ruff/resources/test/fixtures/jupyter/isort.ipynb --fix       
    Finished dev [unoptimized + debuginfo] target(s) in 0.38s
     Running `target/debug/ruff check --select=I001 --no-cache --isolated crates/ruff/resources/test/fixtures/jupyter/isort.ipynb --fix`
Found 2 errors (2 fixed, 0 remaining).
@dhruvmanila dhruvmanila added bug Something isn't working core Related to core functionality labels Jul 19, 2023
@dhruvmanila
Copy link
Member Author

Oh, I think I found the problem. Should be an easy fix actually :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working core Related to core functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant