biqqles / dataclassy

A fast and flexible reimplementation of data classes
https://pypi.org/project/dataclassy
Mozilla Public License 2.0
82 stars 9 forks source link

Error with dataclass with InitVar variable #59

Closed mbraakhekke closed 2 years ago

mbraakhekke commented 2 years ago

The following example raises a TypeError when using dataclassy.dataclass, while it works fine with dataclasses.dataclass.

from dataclassy import dataclass
from dataclasses import InitVar
from typing import Any

@dataclass
class Foo:

    initvar: InitVar[Any]

    def __post_init__(self, initvar):
        pass

foo = Foo(initvar = "foo") # TypeError: Foo.__post_init__() missing 1 required positional argument: 'initvar'
mbraakhekke commented 2 years ago

OK, I see now in the documentation that init-only variables are handled in a different way from dataclasses.