When implementing this proposed change in pyright, I ran into a problem that I hadn’t anticipated. The problem is with object.__new__
and object.__init__
. Both of these methods are defined in the typeshed stubs to take zero parameters.
Consider the following code. This should not generate any type errors, and it doesn’t today in pyright. But with the new MRO linearization algorithm, whereby Any
is placed in the MRO after object
, this now generates an error.
from typing import Any
class Class1(Any):
def __init__(self, x: int):
# This should not generate an error.
super(Class1, self).__init__(x, 1, 2, 3)
I’m not sure what to do about this. It may require us to rethink the proposed spec change — or make it more complex and specify special-case behavior for __init__
and __new__
.
Another option is to put this entire topic on hold for now. As I’ve said above, I don’t have any evidence that this issues is causing pain for mypy or pyright users. We could just leave it unspecified for now and leave the existing behaviors in place.