Am 08.06.21 um 17:44 schrieb Jelle Zijlstra:
Looking at your PEP, I think it would be more user-friendly if the sentinel can be used directly as a type annotation, something like this:
SENTINEL = sentinel("SENTINEL")
def print_exception(*, value=Exception | SENTINEL) -> None: ...
This would be similar to how None works, and it would make the type annotation more concise than when we use Literal. +1 2. What should the process be, in terms of what the PEP defines and what is later implemented in mypy and similar tools? My preference would be that the PEP specifies how this new feature interacts with typing, either by allowing sentinels as types directly (my proposal above) or by saying that PEP 586 is amended to allow sentinels in Literal.
+1 Sorry for just +1'ing, but Jelle formulated the thoughts I had. Type checkers will need to special case sentinels anyway, so using Literal[] seems to be just unnecessary noise. - Sebastian