Content-Length: 281884 | pFad | https://github.com/python/cpython/issues/96385

CE `TypeVarTuple.__typing_prepare_subst__` does not work as intented · Issue #96385 · python/cpython · GitHub
Skip to content

TypeVarTuple.__typing_prepare_subst__ does not work as intented #96385

@sobolevn

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 😉

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions









    ApplySandwichStrip

    pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


    --- a PPN by Garber Painting Akron. With Image Size Reduction included!

    Fetched URL: https://github.com/python/cpython/issues/96385

    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy