Skip to content

sentinel: subclassing restriction not documented #149119

@StelarDream

Description

@StelarDream

Documentation

Trying class MySentinel(sentinel): ... raises:

TypeError: type 'sentinel' is not an acceptable base type

This restriction is intentional, PEP 661 specifies it via __init_subclass__, but the 3.15 docs for sentinel don't mention it.

Suggested addition: a short note mentioning that sentinel cannot be subclassed, and that Enum is the recommended approach when you need multiple related sentinels or behavioral customisation.

Context: raised in the PEP 661 discussion thread, where @JelleZijlstra confirmed this was worth documenting.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dir

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions