Skip to content

Commit 38ace4a

Browse files
committed
ignore init=False fields in dataclass_array_container
1 parent fc9172f commit 38ace4a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

arraycontext/container/dataclass.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,11 @@ def dataclass_array_container(cls: type) -> type:
5252
"dataclass cannot have string-based type annotations"
5353

5454
array_fields = [
55-
f for f in fields(cls) if is_array_container_type(f.type)]
55+
f for f in fields(cls)
56+
if f.init and is_array_container_type(f.type)]
5657
non_array_fields = [
57-
f for f in fields(cls) if not is_array_container_type(f.type)]
58+
f for f in fields(cls)
59+
if f.init and not is_array_container_type(f.type)]
5860

5961
if not array_fields:
6062
raise ValueError(f"'{cls}' must have fields with array container type "

0 commit comments

Comments
 (0)