From c6fd11fe3694646c7b5667e37dfc67b114e2f50a Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Tue, 1 Jul 2025 11:17:22 +0100 Subject: [PATCH] [ty] Eagerly evaluate more constraints based on the raw AST (#19068) --- crates/ty_python_semantic/src/semantic_index/builder.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/ty_python_semantic/src/semantic_index/builder.rs b/crates/ty_python_semantic/src/semantic_index/builder.rs index 68e6a6847f..48b06ac56d 100644 --- a/crates/ty_python_semantic/src/semantic_index/builder.rs +++ b/crates/ty_python_semantic/src/semantic_index/builder.rs @@ -550,6 +550,12 @@ impl<'db, 'ast> SemanticIndexBuilder<'db, 'ast> { match node { ast::Expr::BooleanLiteral(ast::ExprBooleanLiteral { value, .. }) => Some(*value), ast::Expr::Name(ast::ExprName { id, .. }) if id == "TYPE_CHECKING" => Some(true), + ast::Expr::NumberLiteral(ast::ExprNumberLiteral { + value: ast::Number::Int(n), + .. + }) => Some(*n != 0), + ast::Expr::EllipsisLiteral(_) => Some(true), + ast::Expr::NoneLiteral(_) => Some(false), ast::Expr::UnaryOp(ast::ExprUnaryOp { op: ast::UnaryOp::Not, operand,