Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test isinstance
  • Loading branch information
JelleZijlstra committed May 10, 2026
commit 190b7c5d504e015e47f98f2d190ac99c0d9a102a
20 changes: 20 additions & 0 deletions test-data/unit/check-sentinels.test
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,23 @@ def func(x: int | MISSING = MISSING) -> None:
assert_type(x, MISSING)

[builtins fixtures/sentinel.pyi]

[case testIsinstanceSentinel]
# flags: --python-version 3.15
from typing import assert_type
from typing_extensions import Sentinel

BUILTIN = sentinel("BUILTIN")
TYPEXT = Sentinel("TYPEXT")

def func(x: int | BUILTIN | TYPEXT) -> None:
if isinstance(x, sentinel):
assert_type(x, BUILTIN)
else:
assert_type(x, int | TYPEXT)
if isinstance(x, Sentinel):
assert_type(x, TYPEXT)
else:
assert_type(x, int)

[builtins fixtures/sentinel.pyi]
3 changes: 3 additions & 0 deletions test-data/unit/fixtures/sentinel.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ class sentinel:
def __init__(self, name: str, /) -> None: ...

class dict: pass
class tuple: pass

def isinstance(x: object, t: type) -> bool: pass
Loading