Closed
Description
I wish this code would work:
from typing import Type
from abc import ABC, abstractmethod
class A(ABC):
@abstractmethod
def m(self) -> None: pass
def f(a: Type[A]) -> A:
return a() # E: Cannot instantiate abstract class 'A' with abstract attribute 'm'
The obvious intention is to pass f() a concrete subclass of A.
(UPDATE: My real-world use case is a bit more involved, in asyncio there are some classes that implement an elaborate ABC, and I'd like to just say SelectorEventLoop = ... # type: Type[AbstractEventLoop]
rather than having to write out the class definition with all 38 concrete method definitions.)