Repository navigation
Commit 7f6a170
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
- constraints
- infer
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6206 | 6206 | | |
6207 | 6207 | | |
6208 | 6208 | | |
6209 | | - | |
| 6209 | + | |
6210 | 6210 | | |
6211 | 6211 | | |
6212 | 6212 | | |
| |||
0 commit comments