ruff
5bfffe1a - [ty] Remap Jupyter notebook cell indices in `ruff_db` (#19698)

Commit
263 days ago
[ty] Remap Jupyter notebook cell indices in `ruff_db` (#19698) ## Summary This PR remaps ranges in Jupyter notebooks from simple `row:column` indices in the concatenated source code to `cell:row:col` to match Ruff's output. This is probably not a likely change to land upstream in `annotate-snippets`, but I didn't see a good way around it. The remapping logic is taken nearly verbatim from here: https://github.com/astral-sh/ruff/blob/cd6bf1457d667dd17058e07fa4198dae4bfb75f6/crates/ruff_linter/src/message/text.rs#L212-L222 ## Test Plan New `full` rendering test for a notebook I was mainly focused on Ruff, but in local tests this also works for ty: ``` error[invalid-assignment]: Object of type `Literal[1]` is not assignable to `str` --> Untitled.ipynb:cell 1:3:1 | 1 | import math 2 | 3 | x: str = 1 | ^ | info: rule `invalid-assignment` is enabled by default error[invalid-assignment]: Object of type `Literal[1]` is not assignable to `str` --> Untitled.ipynb:cell 2:3:1 | 1 | import math 2 | 3 | x: str = 1 | ^ | info: rule `invalid-assignment` is enabled by default ``` This isn't a duplicate diagnostic, just an unimaginative example: ```py # cell 1 import math x: str = 1 # cell 2 import math x: str = 1 ```
Author
Parents
Loading