The documentation implies that it’s ok for __new__(cls, ...) to return an object of a type different than cls. It says in that case __init__() won’t be called. It’s not stated explicitly, but common sense or a simple test confirms that the resulting the object won’t have type cls.
Why is this seemingly strange behavior allowed? What’s the use case? It’s clearly intentional.
It can be useful when you create mock objects for unit testing.
You can change the
__new__method to return, in the certain cases, the the other object with the same interface, as original (for example simulating the original class instances’ behaviour), without modifications to the rest of code.