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
from __future__ importannotationsclassA:
def__new__(cls) ->B:
returnB()
classB(A):
passclassC(A):
passvar1=A()
reveal_type(var1) # Revealed type is "B", as exceptedvar2=C()
reveal_type(var2) # Revealed type is "C", should be "B" (pyright reports "B")
I suspect this is due to the fact that __new__ should return a subclass of the class being defined according to mypy. I think it is a reasonable idea (see #1020 (comment)) to allow arbitrary types to be allowed, altough this might not be considered a good practice. A use case can be found here (the linked PR above is trying to implement stubs for this).
The text was updated successfully, but these errors were encountered:
Bug Report
Noticed this behavior while working on typeddjango/djangorestframework-stubs#315, it seems that mypy isn't inferring the correct type in the following example:
I suspect this is due to the fact that
__new__
should return a subclass of the class being defined according to mypy. I think it is a reasonable idea (see #1020 (comment)) to allow arbitrary types to be allowed, altough this might not be considered a good practice. A use case can be found here (the linked PR above is trying to implement stubs for this).The text was updated successfully, but these errors were encountered: