[ty] Eagerly evaluate more constraints based on the raw AST (#19068)

This commit is contained in:
Alex Waygood 2025-07-01 11:17:22 +01:00 committed by GitHub
parent 7d468ee58a
commit c6fd11fe36
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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,