biqqles/dataclassy

Error with dataclass with InitVar variable

Closed this issue · 1 comments

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'

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