hikari.undefined#
Singleton used throughout the library to denote values that are not present.
Module Contents#
- hikari.undefined.count(*items)[source]#
Count the number of items that are provided that are
UNDEFINED
.
- hikari.undefined.UndefinedNoneOr[source]#
Type hint for a value that may be
undefined.UNDEFINED
, orNone
.UndefinedNoneOr[T]
is simply an alias forUndefinedOr[typing.Optional[T]]
, which would expand totyping.Union[UndefinedType, T, None]
.
- hikari.undefined.UndefinedOr[source]#
Type hint to mark a type as being semantically optional.
NOTE THAT THIS IS NOT THE SAME AS `typing.Optional` BY DEFINITION.
If you see a type with this marker, it may be
UNDEFINED
or the value it wraps. For example,UndefinedOr[float]
would mean the value could be afloat
, or the literalUNDEFINED
value.On the other hand,
typing.Optional[float]
would mean the value could be afloat
, or the literalNone
value.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 inedit
endpoints where the contents will only be changed if they are explicitly mentioned in the call. Editing a message content and setting it toNone
would be expected to clear the content, whereas setting it toUNDEFINED
would be expected to leave the value as it is without changing it.Consider
UndefinedOr[T]
semantically equivalent toundefined
versusnull
in JavaScript, orOptional
versusnull
in Java and C#.If in doubt, remember: