title: How do you annotate the type of an abstract class with mypy?
body: <p>I'm writing a library where I need a method that takes a (potentially) abstract type, and returns an instance of a concrete subtype of that type:</p>
  
  <pre><code># script.py
  from typing import Type
  from abc import ABC, abstractmethod
  
  
  class AbstractClass(ABC):
      @abstractmethod
      def abstract_method(self):
          pass
  
  T = TypeVar('T', bound=AbstractClass)
  
  def f(c: Type[T]) -&gt; T:
      # find concrete implementation of c based on
      # environment configuration
      ...
  
  
  f(AbstractClass)  # doesn't type check
  </code></pre>
  
  <p>Running <code>mypy script.py</code> yields: </p>
  
  <p><code>error: Only concrete class can be given where "Type[AbstractClass]" is expected</code></p>
  
  <p>I don't understand this error message and am having a hard time finding any documentation for it. Is there any way to annotate the function so that <code>mypy</code> will type check this?</p>
  
  <p>As a side note, PyCharm's type checker, which is what I use the most, type checks <code>f</code> with no errors.</p>