Skip to content

Commit 7f6a170

Browse files
authored
[ty] Move bound APIs to constraint owners (#28094)
The ParamSpec work in #28028 needs missing bounds to depend on the type variable being constrained. Ordinary TypeVars use `Never` and `object`; a bare ParamSpec needs the bottom and top parameter lists. `Constraint` knows which type variable is being constrained, but `ConstraintBounds` and `ConstraintBound` currently supply defaults without that context, leaving ParamSpec callers to interpret missing endpoints separately. An omitted bound also differs from explicitly supplied inference evidence, even when both have the same effective endpoint. For example, an absent upper bound and an explicit `object` bound must remain distinguishable during inference. Callers need access to both stored bounds and effective endpoints without losing the `Validity`/`Evidence` distinction. This PR moves construction and bound queries onto `Constraint` and `PathBound`, which already carry the type variable, and makes the lower-level storage types private. `Constraint` exposes separate stored and effective bound accessors while retaining provenance. Constraint consumers preserve stored endpoints during propagation, substitution, traversal, and display, while comparisons use effective endpoints where needed. `PathBound` exposes lower-bound evidence and a cheap single-upper-bound query that does not expand factored intersections. This PR prepares for #28028 without changing existing endpoint defaults, canonicalization, traversal, or aggregation semantics. It does not add ParamSpec endpoint semantics. Existing test assertions and snapshots are unchanged.
1 parent 53a9448 commit 7f6a170

7 files changed

Lines changed: 466 additions & 330 deletions

File tree

‎crates/ty_python_semantic/src/types/call/bind.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6206,7 +6206,7 @@ impl<'a, 'db> ArgumentTypeChecker<'a, 'db> {
62066206
let preferred_ty = preferred_type_mappings.get(&typevar.identity(db)).copied();
62076207

62086208
if let Some(bounds) = bounds {
6209-
let lower = bounds.evidence_lower?;
6209+
let lower = bounds.evidence_lower()?;
62106210
if preferred_ty.is_none_or(|ty| !lower.is_assignable_to(db, self.env, ty)) {
62116211
return maybe_promote(typevar, bounds);
62126212
}

0 commit comments

Comments
 (0)