microsoft / pyright

Static Type Checker for Python
Other
13.12k stars 1.4k forks source link

is_dataclass always evaluates to false with TypeVars #8686

Closed peku33 closed 2 days ago

peku33 commented 1 month ago

dataclasses.is_dataclass seems to always evaluate to false for generic types.

Environment data

Code Snippet

from dataclasses import is_dataclass
from typing import TypeVar

T = TypeVar("T")

def test_fn(type_: type[T]) -> T:
    assert is_dataclass(type_)

    print("this is marked as unreachable")

    raise NotImplementedError()
erictraut commented 1 month ago

Could someone from the pylance team please transfer this to the pyright project, since it's a core type checker issue? Thanks!

peku33 commented 2 weeks ago

It looks like this has been fixed in #8738

erictraut commented 2 weeks ago

This still needs to be fixed.

erictraut commented 2 days ago

This is addressed in pyright 1.1.380.