title: How to have inherited type hints in python?
body: <p>So my problem is That when I have a class of type <code>A</code> that does things and I use those functions as a <code>subclass(B)</code> they are still typed for class <code>A</code> and do not accept my class <code>B</code> object as arguments or as function signature.</p>
  
  <p>My problem simplified:</p>
  
  <pre><code>from typing import TypeVar, Generic, Callable
  
  T = TypeVar('T')
  
  
  class Signal(Generic[T]):
      def connect(self, connector: Callable[[T], None]) -&gt; None:
          pass
  
      def emit(self, payload: T):
          pass
  
  
  class A:
      def __init__(self) -&gt; None:
          self.signal = Signal[A]()
  
      def do(self) -&gt; None:
          self.signal.emit(self)
  
  def handle_b(b: "B") -&gt; None:
      print(b.something)
  
  class B(A):
      def __init__(self) -&gt; None:
          super().__init__()
          self.signal.connect(handle_b)
  
      @property
      def something(self) -&gt; int:
          return 42
  </code></pre>
  
  <p>I can provide the complete signal class as well but that just distracts from the problem. This leaves me with one error in mypy:</p>
  
  <blockquote>
  <pre><code>error: Argument 1 to "connect" of "Signal" has incompatible type Callable[[B], None]; expected Callable[[A], None]
  </code></pre>
  </blockquote>
  
  <p>Since the signal handling is implemented in <code>A</code> the subclass <code>B</code> can't expect <code>B</code> type objects to be returned even though it clearly should be fine...</p>