Skip to content

Sentinel values are not assignable to Sentinel #5696

Open

Description

@synnks

Describe the Bug

I use a typing_extensions.Sentinel value as the MISSING default for optional fields, and annotate those fields with a generic alias like T | Sentinel, so one alias works for any sentinel.
Pyrefly rejects the MISSING default on every such field.

from typing_extensions import Sentinel

MISSING = Sentinel("MISSING")

value: Sentinel = MISSING
# error: `MISSING` is not assignable to `sentinel`

def f(value: int | Sentinel = MISSING) -> None: ...
# error: Default `MISSING` is not assignable to parameter `value` with type `int | sentinel`

I expected both lines to be accepted:

  • isinstance(MISSING, Sentinel) is True at runtime
  • the type MISSING contains only that one sentinel object.

Different sentinels should stay incompatible, though: assigning OTHER to a variable annotated MISSING should still be an error.

Sandbox Link

https://pyrefly.org/sandbox/?project=v2.I6LIjE-tKEnNA3kJnvmDU_NKMvNSc0Cx4esZHOzp5w50HUxUI0YJKhijBI4waEKGyQOVwuRhSR6W1oERCEzomAoRCUlBT08P7H20wFdWCIAIKED9ASx2gLGWXgos3IBOB-pRBpqbqpBRUlJQbKWvD9OeX5Sun5qnn5KfXKyPokNfAZTOEssSM8FFJqpxCvngxFIMNBZ7rJsSFevqkEhXxxfn6qAoB6rAG40A

(Only applicable for extension issues) IDE Information

No response

Activity

  1. synnks commented on Nov 19, 2026

    @synnks
    Author

    #claim

  2. github-actions commented on Nov 19, 2026

    @github-actions

    @synnks you've claimed this issue — it's now assigned to you. Thanks for picking it up! 🎉

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions