pyright icon indicating copy to clipboard operation
pyright copied to clipboard

is_dataclass always evaluates to false with TypeVars

Open peku33 opened this issue 1 year ago • 1 comments

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

Environment data

  • Language Server version: 2024.8.1
  • OS and version: darwin arm64
  • Python version (and distribution if applicable, e.g. Anaconda): 3.11.9
  • python.analysis.indexing: true
  • python.analysis.typeCheckingMode: strict

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()

peku33 avatar Aug 07 '24 09:08 peku33

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

erictraut avatar Aug 07 '24 14:08 erictraut

It looks like this has been fixed in #8738

peku33 avatar Aug 26 '24 16:08 peku33

This still needs to be fixed.

erictraut avatar Aug 26 '24 16:08 erictraut

This is addressed in pyright 1.1.380.

erictraut avatar Sep 10 '24 22:09 erictraut