Skip to content

User generic with TypeVarTuple does not check for minimal type of arguments #99382

@serhiy-storchaka

Description

@serhiy-storchaka

The following code:

from typing import *
T = TypeVar('T')
T2 = TypeVar('T2')
Ts = TypeVarTuple('Ts')
class A(Generic[T, T2, *Ts]):
    x: List[T]
    y: List[T2]
    z: Tuple[*Ts]

A[int]

is executed without errors. It is expected to get an error because A requires at least two arguments.

Without TypeVarTuple you get helpful errors.

class B(Generic[T, T2]):
    pass

B[int]
B[int, str, bytes]
TypeError: Too few arguments for <class '__main__.B'>; actual 1, expected 2
TypeError: Too many arguments for <class '__main__.B'>; actual 3, expected 2

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.11only security fixes3.12only security fixestopic-typingtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy