title: How do I correctly add type-hints to Mixin classes?
body: <p>Consider the following example. The example is contrived but illustrates the point in a runnable example:</p>
  
  <pre><code>class MultiplicatorMixin:
  
      def multiply(self, m: int) -&gt; int:
          return self.value * m
  
  
  class AdditionMixin:
  
      def add(self, b: int) -&gt; int:
          return self.value + b
  
  
  class MyClass(MultiplicatorMixin, AdditionMixin):
  
      def __init__(self, value: int) -&gt; None:
          self.value = value
  
  
  instance = MyClass(10)
  print(instance.add(2))
  print(instance.multiply(2))
  </code></pre>
  
  <p>When executed this will give the following output:</p>
  
  <pre><code>12
  20
  </code></pre>
  
  <p>The code works.</p>
  
  <p>But running <code>mypy</code> on it, yields the following errors:</p>
  
  <pre><code>example.py:4: error: "MultiplicatorMixin" has no attribute "value"
  example.py:10: error: "AdditionMixin" has no attribute "value"
  </code></pre>
  
  <p>I understand why mypy gives this result. But the mixin classes are never used by themselves. They are always used as additional superclasses.</p>
  
  <p>For context, this is a pattern which has been used in an existing application and I am in the process of adding type-hints. And in this case, the errors are false-positives. I am thinking about rewriting the part using the mixins as I don't particularly like it and the same could probably be done with reorganising the class hierarchy.</p>
  
  <p>But I still would like to know how something like this could be properly hinted.</p>