Skip to content

Regression with generic TypeVar inheritance #12633

Closed
@cdce8p

Description

@cdce8p

Bug Report
Regression added with #12590. Currently also part of the v0.950 release branch.
/CC: @JukkaL

To Reproduce

from dataclasses import dataclass
from typing import Any, Callable, Generic, TypeVar


T = TypeVar("T")

@dataclass
class Parent(Generic[T]):
    f: Callable[[T], Any]

@dataclass
class Child(Parent[T]): ...


class A: ...
def func(obj: A) -> bool: ...

reveal_type(Child[A](func).f)

Expected Behavior

test.py:18: note: Revealed type is "def (test.A) -> Any"

Actual Behavior

test.py:18: note: Revealed type is "def (T`1) -> Any"
test.py:18: error: Argument 1 to "Child" has incompatible type "Callable[[A], bool]"; expected "Callable[[T], Any]"

Your Environment

  • Mypy version used: mypy 0.960+dev.50213b520b131fc1dd037dfcc1938beba1f4e177

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions