title: How to add hint to a factory method?
body: <p>I'm looking for a way to annotate return type of a factory function.</p>
  
  <p>It returns random child of 'AlgorithmBase'.</p>
  
  <pre><code>class AlgorithmFactory:
      _algorithm_types = AlgorithmBase.__subclasses__()
  
      def select_random_algorithm(self) -&gt; AlgorithmBase:
          # Select random algorithm
          algorithm_class = self._random_generator.choice(AlgorithmFactory._algorithm_types)
          algorithm = algorithm_class()
          return algorithm
  </code></pre>
  
  <p>I get error from mypy:</p>
  
  <p>The error I'm getting is:</p>
  
  <pre><code>Cannot instantiate abstract class 'AlgorithmBase' with abstract attributes 'get_constraints' and 'satisfy_constraints'
  </code></pre>
  
  <p>There is no way to instantiate class 'AlgorithmBase' in this code, how to make mypy understand it?</p>
  
  <p>I want to avoid specifying actual sub-classes with 'Union' in return type. Any suggestions?</p>