mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-02 06:42:02 +00:00
Implement autofix for C413 (#661)
This commit is contained in:
parent
f572acab30
commit
f40609f524
10 changed files with 194 additions and 15 deletions
25
ruff_dev/src/print_cst.rs
Normal file
25
ruff_dev/src/print_cst.rs
Normal file
|
@ -0,0 +1,25 @@
|
|||
//! Print the LibCST CST for a given Python file.
|
||||
|
||||
use std::fs;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use anyhow::Result;
|
||||
use clap::Args;
|
||||
|
||||
#[derive(Args)]
|
||||
pub struct Cli {
|
||||
/// Python file for which to generate the CST.
|
||||
#[arg(required = true)]
|
||||
file: PathBuf,
|
||||
}
|
||||
|
||||
pub fn main(cli: &Cli) -> Result<()> {
|
||||
let contents = fs::read_to_string(&cli.file)?;
|
||||
match libcst_native::parse_module(&contents, None) {
|
||||
Ok(python_cst) => {
|
||||
println!("{:#?}", python_cst);
|
||||
Ok(())
|
||||
}
|
||||
Err(_) => Err(anyhow::anyhow!("Failed to parse CST")),
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue