microsoft / pyright

Static Type Checker for Python
Other
13.37k stars 1.46k forks source link

Missing default values in synthesized `__init__` signature of dataclasses #8781

Closed Viicos closed 2 months ago

Viicos commented 2 months ago

Since pyright 1.1.372, the default values of dataclasses is lost in the generated __init__ signature:

Code sample in pyright playground

from dataclasses import dataclass, field

@dataclass
class A:
  a: int = 2
  b: int = field(default=2)

A()

image

In pyright 1.1.371:

image

erictraut commented 2 months ago

This is addressed in pyright 1.1.377.