Skip to content

Commit 7b212fc

Browse files
authored
chore: bump Ruff parser to 0.12.4 (#1217)
* chore: bump Ruff parser to 0.9.7 * chore: adapt to Ruff 0.9.7 * chore: bump Ruff parser to 0.11.8 * chore: adapt to Ruff 0.11.8 * chore: bump Ruff parser to 0.12.4 * refactor(imports): get line from `LineColumn`
1 parent 730d1fd commit 7b212fc

File tree

3 files changed

+187
-21
lines changed

3 files changed

+187
-21
lines changed

Cargo.lock

Lines changed: 177 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ pyo3 = { version = "=0.25.1", features = ["abi3-py39", "generate-import-lib"] }
1919
pyo3-log = "=0.12.4"
2020
rayon = "=1.10.0"
2121
regex = "=1.11.1"
22-
ruff_python_ast = { git = "https://github.com/astral-sh/ruff", tag = "0.9.3" }
23-
ruff_python_parser = { git = "https://github.com/astral-sh/ruff", tag = "0.9.3" }
24-
ruff_source_file = { git = "https://github.com/astral-sh/ruff", tag = "0.9.3" }
25-
ruff_text_size = { git = "https://github.com/astral-sh/ruff", tag = "0.9.3" }
22+
ruff_python_ast = { git = "https://github.com/astral-sh/ruff", tag = "0.12.4" }
23+
ruff_python_parser = { git = "https://github.com/astral-sh/ruff", tag = "0.12.4" }
24+
ruff_source_file = { git = "https://github.com/astral-sh/ruff", tag = "0.12.4" }
25+
ruff_text_size = { git = "https://github.com/astral-sh/ruff", tag = "0.12.4" }
2626
serde_json = "=1.0.141"
2727

2828
[profile.release]

src/imports/shared.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use pyo3::exceptions::PySyntaxError;
66
use pyo3::prelude::*;
77
use ruff_python_ast::visitor::Visitor;
88
use ruff_python_ast::{Mod, ModModule};
9-
use ruff_python_parser::{Mode, Parsed, parse};
9+
use ruff_python_parser::{Mode, ParseOptions, Parsed, parse};
1010
use ruff_source_file::LineIndex;
1111
use ruff_text_size::TextRange;
1212
use std::collections::HashMap;
@@ -22,8 +22,8 @@ pub struct ThreadResult {
2222

2323
/// Parses the content of a Python file into a parsed source code.
2424
pub fn parse_file_content(file_content: &str) -> PyResult<Parsed<Mod>> {
25-
let parsed =
26-
parse(file_content, Mode::Module).map_err(|e| PySyntaxError::new_err(e.to_string()))?;
25+
let parsed = parse(file_content, ParseOptions::from(Mode::Module))
26+
.map_err(|e| PySyntaxError::new_err(e.to_string()))?;
2727
Ok(parsed)
2828
}
2929

@@ -57,15 +57,11 @@ pub fn convert_imports_with_textranges_to_location_objects(
5757
let locations: Vec<Location> = ranges
5858
.iter()
5959
.map(|range| {
60-
let start_line = line_index.line_index(range.start()).get();
61-
let start_col = line_index
62-
.source_location(range.start(), source_code)
63-
.column
64-
.get();
60+
let line_column = line_index.line_column(range.start(), source_code);
6561
Location {
6662
file: file_path.to_owned(),
67-
line: Some(start_line),
68-
column: Some(start_col),
63+
line: Some(line_column.line.get()),
64+
column: Some(line_column.column.get()),
6965
}
7066
})
7167
.collect();

0 commit comments

Comments
 (0)