Singleton used throughout the library to denote values that are not present.
A sentinel singleton that denotes a missing or omitted value.
Type hint for a value that may be
UndefinedNoneOr[T]is simply an alias for
UndefinedOr[typing.Optional[T]], which would expand to
typing.Union[UndefinedType, T, None].
Type hint to mark a type as being semantically optional.
NOTE THAT THIS IS NOT THE SAME AS `typing.Optional` BY DEFINITION.
The reason for using this is in some places, there is a semantic difference between specifying something as being
None, i.e. “no value”, and having a default to specify that the value has just not been mentioned. The main example of this is in
editendpoints where the contents will only be changed if they are explicitly mentioned in the call. Editing a message content and setting it to
Nonewould be expected to clear the content, whereas setting it to
UNDEFINEDwould be expected to leave the value as it is without changing it.
UndefinedOr[T]semantically equivalent to
nullin Java and C#.
If in doubt, remember: