GeezerVison is showing github.com — Use PEP 661 (sentinels) in the standard library · Issue #149083 · python/cpython
Use PEP 661 (sentinels) in the standard library #149083DescriptionFeature or enhancement
Proposal:
I just merged support for PEP-661, which adds the new sentinel() builtin. Let's use it in the standard library so we can simplify some code and stress-test the feature.
We'll have to be careful to preserve compatibility with features such as repr() and boolean values.
Has this already been discussed elsewhere?
No response given
Links to previous discussion of this feature:
No response
Linked PRs
ActivityJelleZijlstra commented on Apr 28, 2026 I have a local patch converting typing.NoDefault to a sentinel: 1ce5c13
However, it breaks two tests in test_typing:
======================================================================
ERROR: test_constructor (test.test_typing.NoDefaultTests.test_constructor)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/jelle/py/cpython/Lib/test/test_typing.py", line 11104, in test_constructor
self.assertIs(NoDefault, type(NoDefault)())
~~~~~~~~~~~~~~~^^
TypeError: sentinel expected 1 argument, got 0
======================================================================
FAIL: test_repr (test.test_typing.NoDefaultTests.test_repr)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/jelle/py/cpython/Lib/test/test_typing.py", line 11109, in test_repr
self.assertEqual(repr(NoDefault), 'typing.NoDefault')
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 'NoDefault' != 'typing.NoDefault'
- NoDefault
+ typing.NoDefault
We can perhaps live with those behavior changes but I think I'll leave this one be. added a commit that references this issue on Apr 30, 2026gh-149083: Convert dataclasses.MISSING and dataclasses.KW_ONLY to sen… added 2 commits that reference this issue on May 9, 2026gh-149083: Convert `_initial_missing` for pure py `reduce` to `sentin… serhiy-storchaka commented on May 9, 2026 There are two, or even three, types of sentinels.
- Intended to be used by the user, like dataclasses.KW_ONLY or os.path.ALL_BUT_LAST. Their repr should refer to the name by which they are accessible. Pickleability is also a good bonus.
- Intended to be used as placeholders for default argument values. They should not be accessible by user. Their repr can be
<not specified> or something like. They are not intended to be pickled either.
- For internal use. The same as the previous case, but usually users should not see them at all.
added 2 commits that reference this issue on Aug 17, 2026gh-149083: Document that dataclasses.MISSING and KW_ONLY are sentinels (
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|