Skip to content

Commit

Permalink
PEP 681: Add support for kwargs (#2504)
Browse files Browse the repository at this point in the history
debonte authored Apr 6, 2022
1 parent 7e537ba commit f73a0aa
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions pep-0681.rst
Original file line number Diff line number Diff line change
@@ -221,6 +221,7 @@ customization of default behaviors:
order_default: bool = False,
kw_only_default: bool = False,
field_specifiers: tuple[type | Callable[..., Any], ...] = (),
**kwargs: Any,
) -> Callable[[_T], _T]: ...
* ``eq_default`` indicates whether the ``eq`` parameter is assumed to
@@ -245,6 +246,11 @@ customization of default behaviors:
function (``field``) that instantiates this class, so if we were
describing the stdlib dataclass behavior, we would provide the
tuple argument ``(dataclasses.Field, dataclasses.field)``.
* ``kwargs`` allows arbitrary additional keyword args to be passed to
``dataclass_transform``. This gives type checkers the freedom to
support experimental parameters without needing to wait for changes
in ``typing.py``. Type checkers should report errors for any
unrecognized parameters.

In the future, we may add additional parameters to
``dataclass_transform`` as needed to support common behaviors in user
@@ -465,10 +471,10 @@ Runtime behavior
----------------

At runtime, the ``dataclass_transform`` decorator's only effect is to
set a string attribute named ``__dataclass_transform__`` on the
decorated function or class to support introspection. The value of the
attribute should be a dict mapping the names of the
``dataclass_transform`` parameters to their values.
set an attribute named ``__dataclass_transform__`` on the decorated
function or class to support introspection. The value of the attribute
should be a dict mapping the names of the ``dataclass_transform``
parameters to their values.

For example:

@@ -479,6 +485,7 @@ For example:
"order_default": False,
"kw_only_default": False,
"field_specifiers": (),
"kwargs": {}
}

0 comments on commit f73a0aa

Please sign in to comment.