Repository navigation
[ty] Restrict range implications from gradual equivalence - #29577
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as outdated.
This comment was marked as outdated.
Two-way assignability to a gradual type does not fix a type variable to that type. Require a static equivalence bound before deriving either a lower or upper bound, preserving valid alternatives while rejecting incompatible conjunctions.
ff680f8 to
90a1525
Compare
Analysis results for
|
| Project | Base | PR | Change |
|---|---|---|---|
| flake8 | 38.01 MiB | 38.01 MiB | unchanged |
| trio | 92.73 MiB | 92.73 MiB | −244 B |
| sphinx | 172.56 MiB | 172.56 MiB | −936 B |
| prefect | 479.35 MiB | 479.34 MiB | −10.19 KiB |
The small net reductions primarily come from for_constraint_pair_inner. Totals retain the report's rounding; units are binary.
Memory workflow · Detailed comparison
Typing conformance
No diagnostic changes. Precision and recall both remain 98.24%, with 134/146 files fully passing on both sides. The suite is python/typing at d06c5dd6, targeting Python 3.12.
Conformance workflow · Comparison report
Ecosystem
No diagnostic changes across 163 projects. No added or removed projects, failed projects, or flaky exit-status changes were reported.
Independently regenerated the diagnostic comparison, statistics, and timing reports from all four CI shards using the workflow's pinned analyzer and dependencies. They match the CI reports; the check for new abnormal exits also passed.
Ecosystem workflow · Full diagnostic and timing reports
The measurements and suite executions above were performed in CI. Artifact checksums, run provenance, and memory/conformance report agreement with the job logs were verified manually. Those two workflows retain rendered comparisons rather than raw measurement/diagnostic JSON, so their computations were not independently repeated locally.
Fix false
invalid-argument-typeerrors when inferring constrained type variables from callbacks that return an invariant generic with a gradual type argument. A callback returningBox[Any]can satisfyCallable[[], T | Box[T]]whenTis constrained tostrorbytes.The solver treated equivalence to a gradual type as exact substitution, allowing a valid union alternative to imply an incompatible bound. Require a static equivalence bound before deriving either lower- or upper-bound implications, including when gradual types are nested inside a bound.
Prerequisite to avoid regressions in #29236.