@@ -46,7 +46,7 @@ directly specified in the ``InventoryItem`` definition shown above.
46
46
Module contents
47
47
---------------
48
48
49
- .. decorator :: dataclass(*, init=True, repr=True, eq=True, order=False, unsafe_hash=False, frozen=False, match_args=True, kw_only=False, slots=False)
49
+ .. decorator :: dataclass(*, init=True, repr=True, eq=True, order=False, unsafe_hash=False, frozen=False, match_args=True, kw_only=False, slots=False, weakref_slot=False )
50
50
51
51
This function is a :term: `decorator ` that is used to add generated
52
52
:term: `special method `\s to classes, as described below.
@@ -79,7 +79,7 @@ Module contents
79
79
class C:
80
80
...
81
81
82
- @dataclass(init=True, repr=True, eq=True, order=False, unsafe_hash=False, frozen=False, match_args=True, kw_only=False, slots=False)
82
+ @dataclass(init=True, repr=True, eq=True, order=False, unsafe_hash=False, frozen=False, match_args=True, kw_only=False, slots=False, weakref_slot=False )
83
83
class C:
84
84
...
85
85
@@ -198,6 +198,13 @@ Module contents
198
198
base class ``__slots__ `` may be any iterable, but *not * an iterator.
199
199
200
200
201
+ - ``weakref_slot ``: If true (the default is ``False ``), add a slot
202
+ named "__weakref__", which is required to make an instance
203
+ weakref-able. It is an error to specify ``weakref_slot=True ``
204
+ without also specifying ``slots=True ``.
205
+
206
+ .. versionadded :: 3.11
207
+
201
208
``field ``\s may optionally specify a default value, using normal
202
209
Python syntax::
203
210
@@ -381,7 +388,7 @@ Module contents
381
388
:func: `astuple ` raises :exc: `TypeError ` if ``obj `` is not a dataclass
382
389
instance.
383
390
384
- .. function :: make_dataclass(cls_name, fields, *, bases=(), namespace=None, init=True, repr=True, eq=True, order=False, unsafe_hash=False, frozen=False, match_args=True, kw_only=False, slots=False)
391
+ .. function :: make_dataclass(cls_name, fields, *, bases=(), namespace=None, init=True, repr=True, eq=True, order=False, unsafe_hash=False, frozen=False, match_args=True, kw_only=False, slots=False, weakref_slot=False )
385
392
386
393
Creates a new dataclass with name ``cls_name ``, fields as defined
387
394
in ``fields ``, base classes as given in ``bases ``, and initialized
@@ -390,8 +397,8 @@ Module contents
390
397
or ``(name, type, Field) ``. If just ``name `` is supplied,
391
398
``typing.Any `` is used for ``type ``. The values of ``init ``,
392
399
``repr ``, ``eq ``, ``order ``, ``unsafe_hash ``, ``frozen ``,
393
- ``match_args ``, ``kw_only ``, and ``slots `` have the same meaning as
394
- they do in :func: `dataclass `.
400
+ ``match_args ``, ``kw_only ``, ``slots ``, and `` weakref_slot `` have
401
+ the same meaning as they do in :func: `dataclass `.
395
402
396
403
This function is not strictly required, because any Python
397
404
mechanism for creating a new class with ``__annotations__ `` can
0 commit comments