Skip to content

TypeVarTuple.__typing_prepare_subst__ does not work as intented #96385

Description

@sobolevn

Right now there's an uncovered branch in TypeVarTuple.__typing_prepare_subst__:

Снимок экрана 2022-08-29 в 15 16 14

And it looks like there's a bug in it, these two lines:

        for param in enumerate(params[typevartuple_index + 1:]):
            if isinstance(param, TypeVarTuple):

This if's body will never be executed, because enumerate always returns tuple[int, T], it is never TypeVarTuple.

So, I think that we need to remove enumerate() call here and add a test like:

>>> from typing import Generic, TypeVarTuple
>>> V = TypeVarTuple('V')
>>> T = TypeVarTuple('T')
>>> class My(Generic[*T]): pass
... 
>>> My[*T, *V][*V]
TypeError: More than one TypeVarTuple parameter in __main__.My[*T, *V]

I will send a PR 😉

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions