typing
typing copied to clipboard
Private identity objects are not singletons.
In the subsection describing singletons in unions, widely used object() example is described as a singleton, but it isn't one. It should be clearly stated that the problem for typing system is that this instance is not a singleton, that's why Enum is needed.
_empty = object() works with is check, because identity of _empty doesn't leak outside of module. There is nothing singleton about that. Typing spec can allow requiring _empty to be one, to allow use with is, but that should be clear it's the case.