Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 18 additions & 17 deletions chex/_src/dataclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

from absl import logging
import jax
from typing import Any, Callable, Optional, Type, Union
from typing_extensions import dataclass_transform # pytype: disable=not-supported-yet


Expand Down Expand Up @@ -92,17 +93,17 @@ def new_init(self, *orig_args, **orig_kwargs):

@dataclass_transform()
def dataclass(
cls=None,
cls: Optional[Type[Any]] = None,
*,
init=True,
repr=True, # pylint: disable=redefined-builtin
eq=True,
order=False,
unsafe_hash=False,
frozen=False,
init: bool = True,
repr: bool = True, # pylint: disable=redefined-builtin
eq: bool = True,
order: bool = False,
unsafe_hash: bool = False,
frozen: bool = False,
kw_only: bool = False,
mappable_dataclass=True, # pylint: disable=redefined-outer-name
):
mappable_dataclass: bool = True, # pylint: disable=redefined-outer-name
) -> Union[Type[Any], Callable[[Type[Any]], Type[Any]]]:
"""JAX-friendly wrapper for :py:func:`dataclasses.dataclass`.

This wrapper class registers new dataclasses with JAX so that tree utils
Expand Down Expand Up @@ -148,14 +149,14 @@ class _Dataclass():

def __init__(
self,
init=True,
repr=True, # pylint: disable=redefined-builtin
eq=True,
order=False,
unsafe_hash=False,
frozen=False,
kw_only=False,
mappable_dataclass=True, # pylint: disable=redefined-outer-name
init: bool = True,
repr: bool = True, # pylint: disable=redefined-builtin
eq: bool = True,
order: bool = False,
unsafe_hash: bool = False,
frozen: bool = False,
kw_only: bool = False,
mappable_dataclass: bool = True, # pylint: disable=redefined-outer-name
):
self.init = init
self.repr = repr # pylint: disable=redefined-builtin
Expand Down