Skip to content

Nested TypeVar(bound=...) are not detected by reportInvalidTypeVarUse #2344

@twoertwein

Description

@twoertwein

Describe the bug
TypeVar(bound=...) are not detected by reportInvalidTypeVarUse when nested in Tuple/Type.

To Reproduce
I would expect that testE and testD create an error.

from typing import Tuple, Type, TypeVar

Bound = TypeVar("Bound", bound=int)
Unbound = TypeVar("Unbound")

def testA() -> Tuple[Unbound, ...]:  # error
    ...

def testB() -> Tuple[Type[Unbound], ...]:  # error
    ...

def testC() -> Unbound:  # error
    ...

def testD() -> Tuple[Bound, ...]:  # no error!
    ...

def testE() -> Tuple[Type[Bound], ...]:  # no error!
    ...

def testF() -> Bound:  # error
    ...

Additional context
https://github.com/pandas-dev/pandas/pull/43752/files#r716224377

Metadata

Metadata

Assignees

No one assigned

    Labels

    addressed in next versionIssue is fixed and will appear in next published version

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions