Skip to content

Inconsistent constraint resolution for tuples. #19860

@randolf-scholz

Description

@randolf-scholz

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrongtopic-pep-646PEP 646 (TypeVarTuple, Unpack)

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions