Skip to content

Commit a8be098

Browse files
committed
[FIX] server: keep value AND annotation evalution to be sure to not loose value
Variable like _auto: bool = True was loosing the "True" value because annotation was prioritized on the detected value.
1 parent f72aaae commit a8be098

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

server/src/core/python_arch_eval.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ impl PythonArchEval {
460460
if !self.file_mode {
461461
deps.push(vec![]);
462462
}
463-
let ann_evaluations = assign.annotation.as_ref().map(|annotation| Evaluation::eval_from_ast(session, annotation, parent.clone(), &range.start(), &mut deps));
463+
let mut ann_evaluations = assign.annotation.as_ref().map(|annotation| Evaluation::eval_from_ast(session, annotation, parent.clone(), &range.start(), &mut deps));
464464
Symbol::insert_dependencies(&self.file, &mut deps, self.current_step);
465465
deps = vec![vec![], vec![]];
466466
if !self.file_mode {
@@ -483,7 +483,14 @@ impl PythonArchEval {
483483
take_value = ann_evaluations.is_none();
484484
}
485485
}
486-
let (eval, diags) = if take_value {value_evaluations.unwrap()} else {ann_evaluations.unwrap()};
486+
let (eval, diags) = if take_value {
487+
value_evaluations.unwrap()
488+
} else {
489+
if value_evaluations.is_some() {
490+
ann_evaluations.as_mut().unwrap().0.extend(value_evaluations.unwrap().0);
491+
}
492+
ann_evaluations.unwrap()
493+
};
487494
variable_rc.borrow_mut().evaluations_mut().unwrap().extend(eval);
488495
self.diagnostics.extend(diags);
489496
let mut dep_to_add = vec![];

0 commit comments

Comments
 (0)