I recently ran across some Django code that has an interesting solution for typing a sentinel object: It uses a *type* object as a sentinel rather than just an `object()`:
# django/db/models/fields/__init__.py
class NOT_PROVIDED:
pass
class Field(RegisterLookupMixin):
def __init__(self, ..., default=NOT_PROVIDED, ...):
...
Presumably the type of the `default` parameter could then be written as:
Union[Type[NOT_PROVIDED], Any]
Not exactly direct, but may work.
--
David Foster | Seattle, WA, USA
Contributor to TypedDict support for mypy
_______________________________________________
Typing-sig mailing list -- typing-sig@python.org
To unsubscribe send an email to typing-sig-leave@python.org
https://mail.python.org/mailman3/lists/typing-sig.python.org/
Member address: guido@python.org