Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Should TypeAliasType check that it is parametrized correctly? #239

Closed
@adriangb

Description

@adriangb

The new TypeAliasType does not seem to check its generic parameters at all:

from typing import TypeVar
from typing_extensions import TypeAliasType

T = TypeVar('T')

Bad1 = TypeAliasType('Bad1', list[T])
Bad1[int]  # should error

Bad2 = TypeAliasType('Bad2', list[T], type_parameters=(T,))
Bad2[int, int]  # should error

This is not enforced for most built-in types it seems (list[int, int]) but it is for classes using Generic[T].

I suppose this is the same behavior in CPython but I'm bringing it up here for discussion.

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