Create ruff_notebook crate (#7039)

## Summary

This PR moves `ruff/jupyter` into its own `ruff_notebook` crate. Beyond
the move itself, there were a few challenges:

1. `ruff_notebook` relies on the source map abstraction. I've moved the
source map into `ruff_diagnostics`, since it doesn't have any
dependencies on its own and is used alongside diagnostics.
2. `ruff_notebook` has a couple tests for end-to-end linting and
autofixing. I had to leave these tests in `ruff` itself.
3. We had code in `ruff/jupyter` that relied on Python lexing, in order
to provide a more targeted error message in the event that a user saves
a `.py` file with a `.ipynb` extension. I removed this in order to avoid
a dependency on the parser, it felt like it wasn't worth retaining just
for that dependency.

## Test Plan

`cargo test`
This commit is contained in:
Charlie Marsh
2023-09-01 14:56:44 +01:00
committed by GitHub
parent 08e246764f
commit afcd00da56
48 changed files with 274 additions and 253 deletions

24
Cargo.lock generated
View File

@@ -2088,6 +2088,7 @@ dependencies = [
"ruff_diagnostics",
"ruff_index",
"ruff_macros",
"ruff_notebook",
"ruff_python_ast",
"ruff_python_codegen",
"ruff_python_index",
@@ -2103,7 +2104,6 @@ dependencies = [
"semver",
"serde",
"serde_json",
"serde_with",
"similar",
"smallvec",
"strum",
@@ -2115,7 +2115,6 @@ dependencies = [
"typed-arena",
"unicode-width",
"unicode_names2",
"uuid",
"wsl",
]
@@ -2185,6 +2184,7 @@ dependencies = [
"ruff_diagnostics",
"ruff_formatter",
"ruff_macros",
"ruff_notebook",
"ruff_python_ast",
"ruff_python_formatter",
"ruff_python_stdlib",
@@ -2227,6 +2227,7 @@ dependencies = [
"ruff_cli",
"ruff_diagnostics",
"ruff_formatter",
"ruff_notebook",
"ruff_python_ast",
"ruff_python_codegen",
"ruff_python_formatter",
@@ -2292,6 +2293,25 @@ dependencies = [
"syn 2.0.29",
]
[[package]]
name = "ruff_notebook"
version = "0.0.0"
dependencies = [
"anyhow",
"insta",
"itertools",
"once_cell",
"ruff_diagnostics",
"ruff_source_file",
"ruff_text_size",
"serde",
"serde_json",
"serde_with",
"test-case",
"thiserror",
"uuid",
]
[[package]]
name = "ruff_python_ast"
version = "0.0.0"