Skip to content

don't discard "unused" typevars from generic context of simplified generic type alias #1846

@cmp0xff

Description

@cmp0xff

Summary

Summary

Hi, the following code snippet causes invalid-type-arguments in current ty, see the playground:

from collections.abc import Hashable, Sequence
from typing import TypeAlias, TypeVar

HashableT = TypeVar("HashableT", bound=Hashable)

VType: TypeAlias = Hashable | Sequence[HashableT]

def foo(p: VType[Hashable]) -> None: ...   # Too many type arguments: expected 0, got 1 (invalid-type-arguments) [Ln 8, Col 18]

It passes the check of mypy and pyright.

The issue arose from pandas-dev/pandas-stubs#1537.

Version

5dc0079e7

Version

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    genericsBugs or features relating to ty's generics implementationtype aliases

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions