title: mypy complains about extended base class' attribute type
body: <p>I have two base classes <code>A</code> and <code>B</code> that are defined like this:</p>
  
  <pre><code>class A(object):
      def common_function(self):
          pass
  class B(object):
      def __init__(self, a: A):
          self.a = a
      def another_common_function(self):
          pass
  </code></pre>
  
  <p>Class <code>A</code> holds some management information, whereas class <code>B</code> holds some other information, which is based on the information contained in class <code>A</code>, and therefore it knows about it's instance of <code>A</code>.</p>
  
  <p>I also have two derived classes <code>dA</code> and <code>dB</code> that are defined like this:</p>
  
  <pre><code>class dA(A):
      def __init__(self, t: B):
          self.t = t
  class dB(B):
      def __init__(self, a: dA):
          super(A, self).__init__(a)
  </code></pre>
  
  <p>These classes (among others (<code>dA1</code>, <code>dB1</code>, <code>dA2</code>, <code>dB2</code>) ... that are similarly designed) are used for some special operation and therefore they need to store some more information, e.g. the t from the example for this pair of classes, other classes have different stuff to store.</p>
  
  <p>The problem is, that mypy complains about the usage of <code>dB.a.t</code>:</p>
  
  <pre><code>class dB(B):
      def __init__(self, a: dA):
          super(A, self).__init__(a)
      def do(self):
          if self.a.t is None:
              print("something")
  </code></pre>
  
  <blockquote>
    <p>test.py: error: "A" has no attribute "t"</p>
  </blockquote>
  
  <p>The complain is actually right. <code>A</code> doesn't have an attribute <code>t</code>. I also told mypy that <code>B.a</code> is of type <code>A</code>, but in this particular case I use <code>dB.a</code> as of type <code>dA</code>, which actually has a t, but I explicitly told mypy otherwise.</p>
  
  <p>The questions are:</p>
  
  <ol>
  <li>Is this a violation of Liskov principle?</li>
  <li>If not 1, is there a way to tell mypy that in this particular case <code>dB.a</code> is of type <code>dA</code>? Do I need to use a TypeVar?</li>
  <li>If 1, is there a way to restructure the classes to not violate the Liskov principle as well as have the type checker be able to recognize the correct types?</li>
  </ol>
  
  <p>I found the question <a href="https://stackoverflow.com/questions/51191061/mypy-base-class-has-no-attribute-x-how-to-type-hint-in-base-class">mypy: base class has no attribute x, how to type hint in base class</a>, however, the solution to extend the base class is not feasible, as this would make <code>t</code> available in all derived classes, not only <code>dA</code> (what somehow smells bad).</p>