Skip to content

Bug: TypeVar default don't work in runtime #639

@IvanKirpichnikov

Description

@IvanKirpichnikov

MRE:

from typing import Generic

from typing_extensions import TypeVar

G = TypeVar("G")
T = TypeVar("T", default=int)

class MRE(Generic[G, T]): ...

MRE[int]

Error:

TypeError: Too few arguments for <class '__main__.MRE'>; actual 1, expected 2

Expected behavior:

Working code is as of 3.13.

Note.

When using typing_extensions, the same error occurs.

Intended solution

Implement your own Generic class, which will be used until version 3.13.


With your permission, I would like to provide a Pull Request to fix this bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions