-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Description
#1843/#2853 added support for instantiating variables with an abstract type, under the assumption that it will always be applied to a concrete subclass. However, this doesn't seem to work in all cases:
Given
class Base(ABC):
@abstractmethod
def m(self) -> None:
pass
class A(Base):
def m(self) -> None:
pass
class B(Base):
def m(self) -> None:
passThen
var: Type[Base]
if "foo" == "bar":
var = A
elif "foo" == "baz":
var = B
else:
raise RuntimeError()
var() # error: Cannot instantiate abstract class 'Base' with abstract attribute 'm'As far as I understand it the last line shouldn't result in an error.
If I remove class B (and the corresponding elif) I don't get an error. Interestingly, if I remove the whole if block I also don't get an error.
This is with version 0.670.
Metadata
Metadata
Assignees
Labels
No labels