title: Mypy: type annotation for map with abstract classes as values
body: <p>I'm working on a framework with various storage backends. Those backends all implement an abstract base class. The backend classes are stored in a mapping from the backend name to the class implementing that backend.</p>
  
  <p>We want to be able to perform type checking with <a href="http://mypy-lang.org/" rel="noreferrer">mypy</a>, and annotate as follows:</p>
  
  <pre><code>#!python
  import abc
  import typing
  
  
  class A(metaclass=abc.ABCMeta):  # The abstract base class
      def __init__(self, name: str) -&gt; None:
          self.name = name
  
      @abc.abstractmethod
      def get_name(self):
          pass
  
  
  class B(A):  # Some non-abstract backend
      def get_name(self):
          return f'B: {self.name}'
  
  
  class C(A):  # Another non-abstract backend
      def get_name(self):
          return f'C: {self.name}'
  
  
  backends: typing.Mapping[str, typing.Type[A]] = {
      'backend-b': B,
      'backend-c': C,
  }
  
  
  if __name__ == '__main__':
      backend_cls = backends['backend-c']
      # The following line causes an error with mypy:
      instance = backend_cls('demo-name')
      print(f'Name is: {instance.get_name()}')
  </code></pre>
  
  <p>Running mypy-0.501 gives this error:</p>
  
  <p><code>typingtest.py:32: error: Cannot instantiate abstract class 'A' with abstract attribute 'get_name'</code></p>
  
  <p><strong>My question:</strong> How can we annotate the mapping <code>backends</code> such that mypy understands it only contains non-abstract subclasses of <code>A</code>?</p>