You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to inherit from a dataclass with an optional id in the parent, however, I am seeing TypeError: non-default argument 'value' follows default argument. This is the minimal code to reproduce.
from typing import Optional
import chex
@chex.dataclass
class Base:
idx: Optional[int] = None
@chex.dataclass
class Derived(Base):
value: int
Sorry, I see this has been fixed in a later version when the following modification is made to the code:
from typing import Optional
import chex
@chex.dataclass(kw_only=True)
class Base:
idx: Optional[int] = None
@chex.dataclass
class Derived(Base):
value: int
However, would it be worth making this the default behaviour as chex.dataclass objects are all kw_only by default?
I'm trying to inherit from a dataclass with an optional id in the parent, however, I am seeing
TypeError: non-default argument 'value' follows default argument
. This is the minimal code to reproduce.This is an issue with the
dataclasses
library rather thanchex.dataclasses
, however, according to https://stackoverflow.com/questions/51575931/class-inheritance-in-python-3-7-dataclasses#answer-69822584, it is possible to fix by settingkw_only=True
.The text was updated successfully, but these errors were encountered: