24 Nov
2020
24 Nov
'20
8:30 p.m.
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