Skip to content

Commit 1e9eff3

Browse files
mmahroussfda-odoo
authored andcommitted
[IMP] update ruff
1 parent 5eaffcf commit 1e9eff3

File tree

5 files changed

+17
-13
lines changed

5 files changed

+17
-13
lines changed

server/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ clap = { version = "4.5.43", features = ["derive"] }
1616
glob = "0.3.2"
1717
regex = "1.11.1"
1818
ropey = "1.6.1"
19-
ruff_python_ast = { git = "https://github.com/astral-sh/ruff", tag = "0.12.7", version = "0.0.0" }
20-
ruff_python_parser = { git = "https://github.com/astral-sh/ruff", tag = "0.12.7", version = "0.0.0" }
21-
ruff_text_size = { git = "https://github.com/astral-sh/ruff", tag = "0.12.7", version = "0.0.0" }
19+
ruff_python_ast = { git = "https://github.com/astral-sh/ruff", tag = "0.14.2", version = "0.0.0" }
20+
ruff_python_parser = { git = "https://github.com/astral-sh/ruff", tag = "0.14.2", version = "0.0.0" }
21+
ruff_text_size = { git = "https://github.com/astral-sh/ruff", tag = "0.14.2", version = "0.0.0" }
2222
lsp-server = { git = "https://github.com/rust-lang/rust-analyzer", tag = "2025-08-04", version = "0.7.6" }
2323
serde = "1.0.219"
2424
serde_json = "1.0.142"

server/src/core/import_resolver.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,16 @@ fn resolve_import_stmt_hook(alias: &Alias, from_symbol: &Option<Rc<RefCell<Symbo
6060
*/
6161
pub fn manual_import(session: &mut SessionInfo, source_file_symbol: &Rc<RefCell<Symbol>>, from_stmt:Option<String>, name: &str, asname: Option<String>, level: u32, diagnostics: &mut Option<&mut Vec<Diagnostic>>) -> Vec<ImportResult> {
6262
let name_aliases = vec![Alias {
63-
name: Identifier { id: Name::new(name), range: TextRange::new(TextSize::new(0), TextSize::new(0)), node_index: AtomicNodeIndex::dummy() },
63+
name: Identifier { id: Name::new(name), range: TextRange::new(TextSize::new(0), TextSize::new(0)), node_index: AtomicNodeIndex::default() },
6464
asname: match asname {
65-
Some(asname_inner) => Some(Identifier { id: Name::new(asname_inner), range: TextRange::new(TextSize::new(0), TextSize::new(0)), node_index: AtomicNodeIndex::dummy() }),
65+
Some(asname_inner) => Some(Identifier { id: Name::new(asname_inner), range: TextRange::new(TextSize::new(0), TextSize::new(0)), node_index: AtomicNodeIndex::default() }),
6666
None => None,
6767
},
6868
range: TextRange::new(TextSize::new(0), TextSize::new(0)),
69-
node_index: AtomicNodeIndex::dummy()
69+
node_index: AtomicNodeIndex::default()
7070
}];
7171
let from_stmt = match from_stmt {
72-
Some(from_stmt_inner) => Some(Identifier { id: Name::new(from_stmt_inner), range: TextRange::new(TextSize::new(0), TextSize::new(0)), node_index: AtomicNodeIndex::dummy() }),
72+
Some(from_stmt_inner) => Some(Identifier { id: Name::new(from_stmt_inner), range: TextRange::new(TextSize::new(0), TextSize::new(0)), node_index: AtomicNodeIndex::default() }),
7373
None => None,
7474
};
7575
resolve_import_stmt(session, source_file_symbol, from_stmt.as_ref(), &name_aliases, level, diagnostics)

server/src/core/python_arch_builder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ impl PythonArchBuilder {
107107
file_info_ast.get_stmts().unwrap()
108108
} else {
109109
let ast_index = self.sym_stack[0].borrow().node_index().unwrap().load();
110-
if ast_index.as_u32() != u32::MAX {
110+
if ast_index.as_u32().is_some() {
111111
let func = file_info_ast.indexed_module.as_ref().unwrap().get_by_index(ast_index);
112112
match func {
113113
AnyRootNodeRef::Stmt(Stmt::FunctionDef(func_stmt)) => {
@@ -650,7 +650,7 @@ impl PythonArchBuilder {
650650
session, &func_def.name.id.to_string(), &func_def.range, &func_def.body.get(0).unwrap().range().start());
651651
let mut sym_bw = sym.borrow_mut();
652652

653-
sym_bw.node_index_mut().set(func_def.node_index.load().as_u32());
653+
sym_bw.node_index_mut().set(func_def.node_index.load());
654654

655655
let func_sym = sym_bw.as_func_mut();
656656
for decorator in func_def.decorator_list.iter() {

server/src/core/symbols/function_symbol.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ impl FunctionSymbol {
7474
is_static: false,
7575
is_property: false,
7676
diagnostics: HashMap::new(),
77-
node_index: AtomicNodeIndex::dummy(),
77+
node_index: AtomicNodeIndex::default(),
7878
doc_string: None,
7979
evaluations: vec![],
8080
arch_status: BuildStatus::PENDING,

server/src/features/node_index_ast.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ impl<'a> Visitor<'a> {
1919
T: HasNodeIndex + std::fmt::Debug,
2020
AnyRootNodeRef<'a>: From<&'a T>,
2121
{
22-
node.node_index().set(self.index);
22+
node.node_index().set(NodeIndex::from(self.index));
2323
self.nodes.push(AnyRootNodeRef::from(node));
2424
self.index += 1;
2525
}
@@ -233,8 +233,12 @@ impl IndexedModule {
233233

234234
/// Returns the node at the given index.
235235
pub fn get_by_index<'ast>(&'ast self, index: NodeIndex) -> AnyRootNodeRef<'ast> {
236+
let index = index
237+
.as_u32()
238+
.expect("attempted to access uninitialized `NodeIndex`");
239+
236240
// Note that this method restores the correct lifetime: the nodes are valid for as
237241
// long as the reference to `IndexedModule` is alive.
238-
self.index[index.as_usize()]
242+
self.index[index as usize]
239243
}
240-
}
244+
}

0 commit comments

Comments
 (0)