You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Well, maybe there should be a better error message, but calling
self.class() to construct an instance is very problematic. A
subclass constructor might have a different signature that is
unknowable when you are checking the base class. So unless in your
world you have a strong rule that subclass constructors must conform
to a certain signature, this should be flagged IMO. (OTOH a way to
declare that you do have such a rule might be useful -- maybe as an
annotation on init()?)
Yeah, that's the reason why this doesn't work right now. Having an __init__ annotation would be a reasonable way to getting to work. Maybe provide a decorator in typing that could be used for this:
from typing import whatever
class A:
@whatever
def __init__(self, x: int) -> None: ...
class B(A):
def __init__(self) -> None: ... # error!
Mypy is OK with accessing
self.__class__
but notself.__class__(...)
Reproducer:
Error:
The text was updated successfully, but these errors were encountered: