google-deepmind / google-deepmind/chex

post_init error in inherited dataclass

Open
#212 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
957
Forks
74
Avg merge
21h 10m
Merged PRs (30d)
1

Description

When inheriting one dataclass from another, Chex's dataclass does not allow a super() call to be made. This is something you can do in Python's base dataclass module.

A minimum working example is

```python
from chex import dataclass as dataclass

@dataclass
class ChexBase:
a : int

def __post_init__(self):
self.b = self.a + 1

@dataclass
class ChexSub(ChexBase):
a: int

def __post_init__(self):
super().__post_init__()
self.c = self.a + 2

temp = ChexSub(a = 1)
temp.b
```

Importing `dataclass` from dataclasses runs without error and returns 2, as expected.

Environment
- Chex version 0.1.5
- Ubuntu 20.04
- Python 3.9

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.