GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

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 #149083

New issue
Copy link
New issue
Copy link
Open
Open
Use PEP 661 (sentinels) in the standard library#149083
Copy link
Assignees
JelleZijlstra
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-refactorCode refactoring (with no changes in behavior)Code refactoring (with no changes in behavior)

Description

@JelleZijlstra
JelleZijlstra
opened on Apr 28, 2026
Issue body actions

Feature 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

  • gh-149083: Convert some private and simple sentinels to PEP 661 #149084
  • gh-149083: Convert dataclasses.MISSING and dataclasses.KW_ONLY to sentinels #149086
  • gh-149083: Make functools.Placeholder a sentinel #149088
  • gh-149083: Use sentinel in functools.rst docs #149176
  • gh-149083: Change several other docs examples to use sentinel() #149213
  • gh-149083: Convert _initial_missing for pure py reduce to sentinel #149536
  • gh-149083: use sentinel to fix _functools.reduce() signature #149591
  • [3.15] gh-149083: Convert _initial_missing for pure py reduce to sentinel (GH-149536) #149592
  • gh-149083: Use sentinel for urllib.parse._UNSPECIFIED #149612
  • gh-149083: Use sentinel for os.path.{ALLOW_MISSING,ALL_BUT_LAST} #149613
  • [3.15] gh-149083: use sentinel to fix _functools.reduce() signature (GH-149591) #149653
  • [3.15] gh-149083: Use sentinel for urllib.parse._UNSPECIFIED (GH-149612) #151017
  • gh-149083: Document that dataclasses.MISSING and KW_ONLY are sentinels #155919
  • [3.15] gh-149083: Document that dataclasses.MISSING and KW_ONLY are sentinels (GH-155919) #155927

Activity

  1. JelleZijlstra
    added
    type-featureA feature request or enhancementA feature request or enhancement
    on Apr 28, 2026
  2. JelleZijlstra
    self-assigned this
    on Apr 28, 2026
  3. JelleZijlstra commented on Apr 28, 2026

    @JelleZijlstra
    JelleZijlstra
    on Apr 28, 2026
    MemberAuthor
    More actions

    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.

  4. StanFromIreland
    added
    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
    type-refactorCode refactoring (with no changes in behavior)Code refactoring (with no changes in behavior)
    and removed
    type-featureA feature request or enhancementA feature request or enhancement
    on Apr 28, 2026
  5. JelleZijlstra
    added a commit that references this issue on Apr 30, 2026

    gh-149083: Convert dataclasses.MISSING and dataclasses.KW_ONLY to sen…

    1695221
  6. sobolevn
    added 3 commits that reference this issue on Apr 30, 2026

    gh-149083: Use `sentinel` in `functools.rst` docs (#149176)

    bf42481

    pythongh-149083: Change several other docs examples to use `sentinel()`

    9dd3492

    gh-149083: Change several other docs examples to use `sentinel()` (#1…

    690e0de
  7. sobolevn
    added 2 commits that reference this issue on May 9, 2026

    gh-149083: Convert `_initial_missing` for pure py `reduce` to `sentin…

    bc8cf07

    [3.15] gh-149083: Convert `_initial_missing` for pure py `reduce` to …

    915b6c1
  8. JelleZijlstra
    added a commit that references this issue on May 9, 2026

    pythongh-149083: Use sentinel for os.path.{ALLOW_MISSING,ALL_BUT_LAST}

    20b62f7
  9. serhiy-storchaka commented on May 9, 2026

    @serhiy-storchaka
    serhiy-storchaka
    on May 9, 2026
    Member
    More actions

    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.
  10. JelleZijlstra
    added 2 commits that reference this issue on May 10, 2026

    gh-149083: use sentinel to fix _functools.reduce() signature (#149591)

    c6fd7de

    [3.15] gh-149083: use sentinel to fix _functools.reduce() signature (G…

    73c80cb
  11. JelleZijlstra
    added 2 commits that reference this issue on Jun 6, 2026

    gh-149083: Use sentinel for urllib.parse._UNSPECIFIED (#149612)

    884ac3e

    [3.15] gh-149083: Use sentinel for urllib.parse._UNSPECIFIED (GH-149612…

    9352936
  12. philthompson10
    added a commit that references this issue on Jun 17, 2026

    pythongh-149083: Use sentinel for urllib.parse._UNSPECIFIED (python#1…

    e4308c5
  13. hugovk
    added 2 commits that reference this issue on Aug 17, 2026

    gh-149083: Document that dataclasses.MISSING and KW_ONLY are sentinels (

    e13c3d6

    [3.15] gh-149083: Document that dataclasses.MISSING and KW_ONLY are s…

    ac4e5d2
  14. picnixz
    added a commit that references this issue on Nov 1, 2026

    gh-149083: Make functools.Placeholder a sentinel (#149088)

    ee074d1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @JelleZijlstra
    JelleZijlstra

Labels

stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-refactorCode refactoring (with no changes in behavior)Code refactoring (with no changes in behavior)

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.