Skip to content

Commit

Permalink
Make static type checkers aware the fact that all derived classes of …
Browse files Browse the repository at this point in the history
…`FiddleBaseParameterizable` have a dataclass-like semantics (ie having fields).

PiperOrigin-RevId: 573301464
  • Loading branch information
Flax Team committed Oct 13, 2023
1 parent fac0cef commit 7805111
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions flax/linen/kw_only_dataclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ def field(*, metadata=None, kw_only=dataclasses.MISSING, **kwargs):
return dataclasses.field(metadata=metadata, **kwargs)


# LINT.IfChange
@dataclass_transform(field_specifiers=(field,)) # type: ignore[literal-required]
def dataclass(cls=None, extra_fields=None, **kwargs):
"""Wrapper for dataclasses.dataclass that adds support for kw_only fields.
Expand Down

0 comments on commit 7805111

Please sign in to comment.