title: Typing inheritence for class properties in Python
body: <p>First, please take a look at the following code:</p>
  <pre class="lang-py prettyprint-override"><code>from typing import Type
  
  
  class C:
      @staticmethod
      def c_fun():
          return 23
  
  
  class C1(C):
      @staticmethod
      def c1_fun():
          return 42
  
  
  class M:
      def __init__(self, c: Type[C]):
          self.c = c()
  
  
  class M1(M):
      def __init__(self, c: Type[C1]):
          super().__init__(c=c)
          # self.c = c()
  
      def m1_fun(self):
          print(self.c.c1_fun())
  
      def show_type(self):
          print(type(self.c))
  
  
  M1(c=C1).m1_fun()  # Output: 42
  M1(c=C1).show_type()  # Output: &lt;class '__main__.C1'&gt;
  </code></pre>
  <p>The code compiles and works as intended without any errors. However, the Python linter in PyCharm displays the following warning when referring to <code>self.c.c1_fun()</code> in M1.m1_fun():</p>
  <p><code>Unresolved attribute reference 'c1_fun' for class 'C'</code></p>
  <p>although it seems to resolve during compilation. To ensure the typing of <code>self.c</code>, I print it out, and it seems to be C1 during compilation as intended.</p>
  <p>When I uncomment <code>self.c = c()</code> in M1.__init__() the linter warning disappears - but I would like to avoid repetitiveness, as it is already done in the constructor of class M.</p>
  <p>My questions:</p>
  <ol>
  <li>Am I doing anything wrong, as the PyCharm linter proclaims?</li>
  <li>Is there any good practice to do it without repetition of assignments?</li>
  </ol>
  <p><strong>Edit:</strong>
  I found a <a href="https://stackoverflow.com/questions/62167179/how-do-i-annotate-the-type-of-a-parameter-of-an-abstractmethod-when-the-paramet">similar question</a> - it seems like that using Generic is the way to go (as it was done in the chosen answer for the current post).</p>