Skip to content

Commit e13c3d6

Browse files
fregataaclaude
andauthored
gh-149083: Document that dataclasses.MISSING and KW_ONLY are sentinels (#155919)
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 7a845ce commit e13c3d6

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

Doc/library/dataclasses.rst

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,8 @@ Module contents
262262
c = C()
263263
c.mylist += [1, 2, 3]
264264

265-
As shown above, the :const:`MISSING` value is a sentinel object used to
266-
detect if some parameters are provided by the user. This sentinel is
265+
As shown above, the :const:`MISSING` value is a :class:`sentinel` object
266+
used to detect if some parameters are provided by the user. This sentinel is
267267
used because ``None`` is a valid value for some parameters with
268268
a distinct meaning. No code should directly use the :const:`MISSING` value.
269269

@@ -528,11 +528,14 @@ Module contents
528528

529529
.. data:: MISSING
530530

531-
A sentinel value signifying a missing default or default_factory.
531+
A :class:`sentinel` object signifying a missing default or *default_factory*.
532+
533+
.. versionchanged:: 3.15
534+
:const:`!MISSING` is now a :class:`sentinel` object.
532535

533536
.. data:: KW_ONLY
534537

535-
A sentinel value used as a type annotation. Any fields after a
538+
A :class:`sentinel` object used as a type annotation. Any fields after a
536539
pseudo-field with the type of :const:`!KW_ONLY` are marked as
537540
keyword-only fields. Note that a pseudo-field of type
538541
:const:`!KW_ONLY` is otherwise completely ignored. This includes the
@@ -557,6 +560,9 @@ Module contents
557560

558561
.. versionadded:: 3.10
559562

563+
.. versionchanged:: 3.15
564+
:const:`!KW_ONLY` is now a :class:`sentinel` object.
565+
560566
.. exception:: FrozenInstanceError
561567

562568
Raised when an implicitly defined :meth:`~object.__setattr__` or

0 commit comments

Comments
 (0)