Remove parser dependency from ruff-python-ast (#6096)

This commit is contained in:
Micha Reiser 2023-07-26 17:47:22 +02:00 committed by GitHub
parent 99127243f4
commit 2cf00fee96
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
658 changed files with 1714 additions and 1546 deletions

View file

@ -21,10 +21,13 @@ arbitrary = { version = "1.3.0", features = ["derive"] }
libfuzzer-sys = { git = "https://github.com/rust-fuzz/libfuzzer", default-features = false }
ruff = { path = "../crates/ruff" }
ruff_python_ast = { path = "../crates/ruff_python_ast" }
ruff_python_codegen = { path = "../crates/ruff_python_codegen" }
ruff_python_formatter = { path = "../crates/ruff_python_formatter" }
ruff_source_file = { path = "../crates/ruff_source_file" }
similar = { version = "2.2.1" }
rustpython-parser = { git = "https://github.com/astral-sh/RustPython-Parser.git", rev = "593b46be5e0336fe01917f8ef400bd12d81df8c1" }
rustpython-ast = { git = "https://github.com/astral-sh/RustPython-Parser.git", rev = "593b46be5e0336fe01917f8ef400bd12d81df8c1" }
# Prevent this from interfering with workspaces
[workspace]

View file

@ -4,11 +4,13 @@
#![no_main]
use libfuzzer_sys::{fuzz_target, Corpus};
use ruff_python_ast::source_code::round_trip;
use ruff_python_codegen::round_trip;
use similar::TextDiff;
fn do_fuzz(case: &[u8]) -> Corpus {
let Ok(code) = std::str::from_utf8(case) else { return Corpus::Reject; };
let Ok(code) = std::str::from_utf8(case) else {
return Corpus::Reject;
};
// round trip it once to get a formatted version
if let Ok(first) = round_trip(code, "fuzzed-source.py") {

View file

@ -4,12 +4,15 @@
#![no_main]
use libfuzzer_sys::{fuzz_target, Corpus};
use ruff_python_ast::source_code::{Generator, Locator, Stylist};
use rustpython_parser::ast::Suite;
use ruff_python_codegen::{Generator, Stylist};
use ruff_source_file::Locator;
use rustpython_ast::Suite;
use rustpython_parser::{lexer, Mode, Parse, ParseError};
fn do_fuzz(case: &[u8]) -> Corpus {
let Ok(code) = std::str::from_utf8(case) else { return Corpus::Reject; };
let Ok(code) = std::str::from_utf8(case) else {
return Corpus::Reject;
};
// just round-trip it once to trigger both parse and unparse
let locator = Locator::new(code);