diff --git a/Cargo.lock b/Cargo.lock index b3d2df84d6..8afabb6e94 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2102,7 +2102,6 @@ dependencies = [ "insta", "is-macro", "itertools", - "log", "memchr", "num-bigint", "num-traits", @@ -2210,7 +2209,7 @@ dependencies = [ [[package]] name = "ruff_text_size" version = "0.0.0" -source = "git+https://github.com/astral-sh/RustPython-Parser.git?rev=5ef4ccd6322a8b7c5e8ead0ae3c89426d7be7d72#5ef4ccd6322a8b7c5e8ead0ae3c89426d7be7d72" +source = "git+https://github.com/astral-sh/RustPython-Parser.git?rev=593b46be5e0336fe01917f8ef400bd12d81df8c1#593b46be5e0336fe01917f8ef400bd12d81df8c1" dependencies = [ "schemars", "serde", @@ -2312,7 +2311,7 @@ dependencies = [ [[package]] name = "rustpython-ast" version = "0.2.0" -source = "git+https://github.com/astral-sh/RustPython-Parser.git?rev=5ef4ccd6322a8b7c5e8ead0ae3c89426d7be7d72#5ef4ccd6322a8b7c5e8ead0ae3c89426d7be7d72" +source = "git+https://github.com/astral-sh/RustPython-Parser.git?rev=593b46be5e0336fe01917f8ef400bd12d81df8c1#593b46be5e0336fe01917f8ef400bd12d81df8c1" dependencies = [ "is-macro", "num-bigint", @@ -2323,7 +2322,7 @@ dependencies = [ [[package]] name = "rustpython-format" version = "0.2.0" -source = "git+https://github.com/astral-sh/RustPython-Parser.git?rev=5ef4ccd6322a8b7c5e8ead0ae3c89426d7be7d72#5ef4ccd6322a8b7c5e8ead0ae3c89426d7be7d72" +source = "git+https://github.com/astral-sh/RustPython-Parser.git?rev=593b46be5e0336fe01917f8ef400bd12d81df8c1#593b46be5e0336fe01917f8ef400bd12d81df8c1" dependencies = [ "bitflags 2.3.3", "itertools", @@ -2335,7 +2334,7 @@ dependencies = [ [[package]] name = "rustpython-literal" version = "0.2.0" -source = "git+https://github.com/astral-sh/RustPython-Parser.git?rev=5ef4ccd6322a8b7c5e8ead0ae3c89426d7be7d72#5ef4ccd6322a8b7c5e8ead0ae3c89426d7be7d72" +source = "git+https://github.com/astral-sh/RustPython-Parser.git?rev=593b46be5e0336fe01917f8ef400bd12d81df8c1#593b46be5e0336fe01917f8ef400bd12d81df8c1" dependencies = [ "hexf-parse", "is-macro", @@ -2347,20 +2346,18 @@ dependencies = [ [[package]] name = "rustpython-parser" version = "0.2.0" -source = "git+https://github.com/astral-sh/RustPython-Parser.git?rev=5ef4ccd6322a8b7c5e8ead0ae3c89426d7be7d72#5ef4ccd6322a8b7c5e8ead0ae3c89426d7be7d72" +source = "git+https://github.com/astral-sh/RustPython-Parser.git?rev=593b46be5e0336fe01917f8ef400bd12d81df8c1#593b46be5e0336fe01917f8ef400bd12d81df8c1" dependencies = [ "anyhow", "is-macro", "itertools", "lalrpop-util", - "log", "num-bigint", "num-traits", - "phf", - "phf_codegen", "rustc-hash", "rustpython-ast", "rustpython-parser-core", + "static_assertions", "tiny-keccak", "unic-emoji-char", "unic-ucd-ident", @@ -2370,10 +2367,9 @@ dependencies = [ [[package]] name = "rustpython-parser-core" version = "0.2.0" -source = "git+https://github.com/astral-sh/RustPython-Parser.git?rev=5ef4ccd6322a8b7c5e8ead0ae3c89426d7be7d72#5ef4ccd6322a8b7c5e8ead0ae3c89426d7be7d72" +source = "git+https://github.com/astral-sh/RustPython-Parser.git?rev=593b46be5e0336fe01917f8ef400bd12d81df8c1#593b46be5e0336fe01917f8ef400bd12d81df8c1" dependencies = [ "is-macro", - "memchr", "ruff_text_size", ] diff --git a/Cargo.toml b/Cargo.toml index 6b3a8b40e4..807e2394c6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -51,11 +51,11 @@ wsl = { version = "0.1.0" } # v1.0.1 libcst = { git = "https://github.com/Instagram/LibCST.git", rev = "3cacca1a1029f05707e50703b49fe3dd860aa839", default-features = false } -ruff_text_size = { git = "https://github.com/astral-sh/RustPython-Parser.git", rev = "5ef4ccd6322a8b7c5e8ead0ae3c89426d7be7d72" } -rustpython-ast = { git = "https://github.com/astral-sh/RustPython-Parser.git", rev = "5ef4ccd6322a8b7c5e8ead0ae3c89426d7be7d72" , default-features = false, features = ["num-bigint"]} -rustpython-format = { git = "https://github.com/astral-sh/RustPython-Parser.git", rev = "5ef4ccd6322a8b7c5e8ead0ae3c89426d7be7d72", default-features = false, features = ["num-bigint"] } -rustpython-literal = { git = "https://github.com/astral-sh/RustPython-Parser.git", rev = "5ef4ccd6322a8b7c5e8ead0ae3c89426d7be7d72", default-features = false } -rustpython-parser = { git = "https://github.com/astral-sh/RustPython-Parser.git", rev = "5ef4ccd6322a8b7c5e8ead0ae3c89426d7be7d72" , default-features = false, features = ["full-lexer", "num-bigint"] } +ruff_text_size = { git = "https://github.com/astral-sh/RustPython-Parser.git", rev = "593b46be5e0336fe01917f8ef400bd12d81df8c1" } +rustpython-ast = { git = "https://github.com/astral-sh/RustPython-Parser.git", rev = "593b46be5e0336fe01917f8ef400bd12d81df8c1" } +rustpython-format = { git = "https://github.com/astral-sh/RustPython-Parser.git", rev = "593b46be5e0336fe01917f8ef400bd12d81df8c1" } +rustpython-literal = { git = "https://github.com/astral-sh/RustPython-Parser.git", rev = "593b46be5e0336fe01917f8ef400bd12d81df8c1" } +rustpython-parser = { git = "https://github.com/astral-sh/RustPython-Parser.git", rev = "593b46be5e0336fe01917f8ef400bd12d81df8c1" } [profile.release] lto = "fat" diff --git a/crates/ruff/resources/test/fixtures/jupyter/not_json.ipynb b/crates/ruff/resources/test/fixtures/jupyter/not_json.ipynb index 45ed561e01..f9350b41c2 100644 --- a/crates/ruff/resources/test/fixtures/jupyter/not_json.ipynb +++ b/crates/ruff/resources/test/fixtures/jupyter/not_json.ipynb @@ -1 +1 @@ -broken "§=($/=(") +broken "§=($/=() diff --git a/crates/ruff/src/jupyter/notebook.rs b/crates/ruff/src/jupyter/notebook.rs index 76f39ce757..8e5e2a6b39 100644 --- a/crates/ruff/src/jupyter/notebook.rs +++ b/crates/ruff/src/jupyter/notebook.rs @@ -12,6 +12,8 @@ use serde_json::error::Category; use ruff_diagnostics::Diagnostic; use ruff_python_trivia::{NewlineWithTrailingNewline, UniversalNewlineIterator}; use ruff_text_size::{TextRange, TextSize}; +use rustpython_parser::lexer::lex; +use rustpython_parser::Mode; use crate::autofix::source_map::{SourceMap, SourceMarker}; use crate::jupyter::index::JupyterIndex; @@ -158,10 +160,7 @@ impl Notebook { ) })?; // Check if tokenizing was successful and the file is non-empty - if (ruff_rustpython::tokenize(&contents)) - .last() - .map_or(true, Result::is_err) - { + if lex(&contents, Mode::Module).any(|result| result.is_err()) { Diagnostic::new( SyntaxError { message: format!( diff --git a/crates/ruff_python_ast/Cargo.toml b/crates/ruff_python_ast/Cargo.toml index c5bba682a5..110b198aea 100644 --- a/crates/ruff_python_ast/Cargo.toml +++ b/crates/ruff_python_ast/Cargo.toml @@ -20,7 +20,6 @@ anyhow = { workspace = true } bitflags = { workspace = true } is-macro = { workspace = true } itertools = { workspace = true } -log = { workspace = true } memchr = { workspace = true } num-bigint = { workspace = true } num-traits = { workspace = true } diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index 1936cac5dc..62708af4ec 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -24,7 +24,7 @@ ruff_python_ast = { path = "../crates/ruff_python_ast" } ruff_python_formatter = { path = "../crates/ruff_python_formatter" } similar = { version = "2.2.1" } -rustpython-parser = { git = "https://github.com/astral-sh/RustPython-Parser.git", rev = "5ef4ccd6322a8b7c5e8ead0ae3c89426d7be7d72" , default-features = false, features = ["full-lexer", "num-bigint"] } +rustpython-parser = { git = "https://github.com/astral-sh/RustPython-Parser.git", rev = "593b46be5e0336fe01917f8ef400bd12d81df8c1" } # Prevent this from interfering with workspaces [workspace] diff --git a/fuzz/init-fuzzer.sh b/fuzz/init-fuzzer.sh old mode 100644 new mode 100755