Skip to content

Commit f73a0aa

Browse files
authored
PEP 681: Add support for kwargs (#2504)
1 parent 7e537ba commit f73a0aa

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

pep-0681.rst

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ customization of default behaviors:
221221
order_default: bool = False,
222222
kw_only_default: bool = False,
223223
field_specifiers: tuple[type | Callable[..., Any], ...] = (),
224+
**kwargs: Any,
224225
) -> Callable[[_T], _T]: ...
225226
226227
* ``eq_default`` indicates whether the ``eq`` parameter is assumed to
@@ -245,6 +246,11 @@ customization of default behaviors:
245246
function (``field``) that instantiates this class, so if we were
246247
describing the stdlib dataclass behavior, we would provide the
247248
tuple argument ``(dataclasses.Field, dataclasses.field)``.
249+
* ``kwargs`` allows arbitrary additional keyword args to be passed to
250+
``dataclass_transform``. This gives type checkers the freedom to
251+
support experimental parameters without needing to wait for changes
252+
in ``typing.py``. Type checkers should report errors for any
253+
unrecognized parameters.
248254

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

467473
At runtime, the ``dataclass_transform`` decorator's only effect is to
468-
set a string attribute named ``__dataclass_transform__`` on the
469-
decorated function or class to support introspection. The value of the
470-
attribute should be a dict mapping the names of the
471-
``dataclass_transform`` parameters to their values.
474+
set an attribute named ``__dataclass_transform__`` on the decorated
475+
function or class to support introspection. The value of the attribute
476+
should be a dict mapping the names of the ``dataclass_transform``
477+
parameters to their values.
472478

473479
For example:
474480

@@ -479,6 +485,7 @@ For example:
479485
"order_default": False,
480486
"kw_only_default": False,
481487
"field_specifiers": (),
488+
"kwargs": {}
482489
}
483490
484491

0 commit comments

Comments
 (0)