Inconsistent constraint resolution for tuples.
Open
Nobody has claimed this yet.
bug
topic-pep-646
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
Adding the following test to ConstraintsSuite fails with assert set() == {1 <: B, 1 <: A}:
def test_wrapped_tuple_identical_results(self) -> None:
# test inferred constraints of tuple[T, ...] <: tuple[A, B]
# vs inferred constraints of tuple[*tuple[T, ...]] <: tuple[A, B]
fx = self.fx
t = Instance(fx.std_tuplei, [fx.t])
assert set(infer_constraints(
t,
TupleType([self.fx.a, self.fx.b], fallback=self.fx.std_tuple),
SUBTYPE_OF,
)) == set(infer_constraints(
TupleType([UnpackType(t)], fallback=self.fx.std_tuple),
TupleType([self.fx.a, self.fx.b], fallback=self.fx.std_tuple),
SUBTYPE_OF,
))
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in ConstraintsSuite with test_wrapped_tuple_identical_results and inspect infer_constraints for the two tuple forms shown. Reproduce the assertion, then make both calls infer identical constraints and rerun the focused ConstraintsSuite test to confirm it passes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100