Skip to content

Sentinel instance is not assignable to Sentinel type #11529

Description

@sobolevn

When I write:

from typing_extensions import Sentinel 

X = Sentinel("X")

def inspect_sentinel(arg: Sentinel) -> None:
    ...

inspect_sentinel(arg=X)

I get:

Argument of type "X" cannot be assigned to parameter "arg" of type "Sentinel" in function "inspect_sentinel"
  "X" is not assignable to "Sentinel"  (reportArgumentType)

But, X is an instance of a Sentinel type. It should be possible to pass any sentinel where Sentinel type is expected. For example: for type inspection, as I do here.

Playground: https://pyright-play.net/?strict=true&locale=en&code=GYJw9gtgBALgngBwJYDsDmB9ApgDxllAZyTCKiQgTBBigGUCZUsAbKAKHYA0oBeexsxYAKAERdRASk4ATLMHJEEWAMYwMhQSlbCAhiDQAuASibaWkqAFoAfFABypLIfZQ3UAHRfOqQsrUaWjr6aLxckkA

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions