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
I'm trying to annotate simple class factory, but constantly getting "Invalid base class" error. Only annotating the result of factory() call with Any return type removes errors, but there is an interesting thing at line 26.
Revealed type for class A is a function that returns A instance, but you can't inherit from real function.
So, two questions:
how to annotate factory to return something that is "valid base class"?
may be mypy should distinguish type instance and class instance "constructor"?
fromtypingimportAnyclassA:
passdeffactory() ->Any:
returnAbase=factory() # type: Any# removing forced Any leads to invalid base class errorreveal_type(base)
# factory.py:15: error: Revealed type is 'Any'classB(base):
passvar=Areveal_type(var)
# factory.py:26: error: Revealed type is 'def () -> factory.A'classC(var):
pass
The text was updated successfully, but these errors were encountered:
Found dynamic base classes in unsupported features, so my questions are now about these features only. Without dynamic base classes, all annotations look reasonable.
I'm trying to annotate simple class factory, but constantly getting "Invalid base class" error. Only annotating the result of
factory()
call withAny
return type removes errors, but there is an interesting thing at line 26.Revealed type for
class A
is a function that returnsA
instance, but you can't inherit from real function.So, two questions:
factory
to return something that is "valid base class"?type
instance and class instance "constructor"?The text was updated successfully, but these errors were encountered: