Skip to content

Commit

Permalink
Add frozen_default parameter on dataclass_transform (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
debonte committed Dec 3, 2022
1 parent 0ea104b commit 57226b4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/test_typing_extensions.py
Expand Up @@ -3009,6 +3009,7 @@ class CustomerModel:
"eq_default": True,
"order_default": False,
"kw_only_default": True,
"frozen_default": False,
"field_specifiers": (),
"kwargs": {},
}
Expand Down Expand Up @@ -3039,6 +3040,7 @@ class CustomerModel(Decorated, frozen=True):
"eq_default": True,
"order_default": True,
"kw_only_default": False,
"frozen_default": False,
"field_specifiers": (),
"kwargs": {"make_everything_awesome": True},
}
Expand Down Expand Up @@ -3070,6 +3072,7 @@ class CustomerModel(ModelBase, init=False):
"eq_default": True,
"order_default": True,
"kw_only_default": False,
"frozen_default": False,
"field_specifiers": (Field,),
"kwargs": {},
}
Expand Down
4 changes: 4 additions & 0 deletions src/typing_extensions.py
Expand Up @@ -2006,6 +2006,7 @@ def dataclass_transform(
eq_default: bool = True,
order_default: bool = False,
kw_only_default: bool = False,
frozen_default: bool = False,
field_specifiers: typing.Tuple[
typing.Union[typing.Type[typing.Any], typing.Callable[..., typing.Any]],
...
Expand Down Expand Up @@ -2062,6 +2063,8 @@ class CustomerModel(ModelBase):
assumed to be True or False if it is omitted by the caller.
- ``kw_only_default`` indicates whether the ``kw_only`` parameter is
assumed to be True or False if it is omitted by the caller.
- ``frozen_default`` indicates whether the ``frozen`` parameter is
assumed to be True or False if it is omitted by the caller.
- ``field_specifiers`` specifies a static list of supported classes
or functions that describe fields, similar to ``dataclasses.field()``.
Expand All @@ -2076,6 +2079,7 @@ def decorator(cls_or_fn):
"eq_default": eq_default,
"order_default": order_default,
"kw_only_default": kw_only_default,
"frozen_default": frozen_default,
"field_specifiers": field_specifiers,
"kwargs": kwargs,
}
Expand Down

0 comments on commit 57226b4

Please sign in to comment.