That's a very expensive sentinel though. Classes are notoriously heavy objects.
On Tue, Nov 24, 2020 at 7:17 PM David Foster email@example.com wrote:
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:
Not exactly direct, but may work.
-- David Foster | Seattle, WA, USA Contributor to TypedDict support for mypy _______________________________________________ Typing-sig mailing list -- firstname.lastname@example.org To unsubscribe send an email to email@example.com https://mail.python.org/mailman3/lists/typing-sig.python.org/ Member address: firstname.lastname@example.org