title: mypy: how to verify a type has multiple super classes
body: <p>I would like mypy to verify that a variable is subclassed from a certain base class and that it <em>also</em> has a specific mixin. Union only verifies that the value is of one type or another. I need to check that the value is both types.</p>
  
  <p>In the example, I'm making up a keyword "All" to demonstrate the behavior I'm looking for:</p>
  
  <pre><code>from typing import All
  
  class Base ( object ):
      pass
  class Mixin ( object ):
      pass
  
  def assert_all ( x ):
      # type: ( All[Base,Mixin] ) -&gt; None
      assert isinstance ( x, Base ) and isinstance ( x, Mixin )
  
  class Child ( Mixin, Base ):
      pass
  
  assert_all ( Child() )
  try:
      assert_all ( Base() ) # !!! mypy should complain here
  except AssertionError:
      pass
  else:
      raise AssertionError ( 'assert inside of assert_all() should have fired' )
  try:
      assert_all ( Mixin() ) # !!! mypy should complain here, too
  except AssertionError:
      pass
  else:
      raise AssertionError ( 'assert inside of assert_all() should have fired' )
  </code></pre>
  
  <p>In case it's helpful, the reason I need this is I have my own win32 wrapper implemented in Python. My Base class is the basic Window class. My required Mixin is ControlHost which adds specific window styles and functions to the Window class to manage owning children, things that a basic window doesn't need. When creating child controls, like a ComboBox for example, I want mypy to call me out if the parent window I feed it doesn't have both super classes.</p>
  
  <p>Also, I'm having an issue calling Window.<strong>init</strong>() from Control.<strong>init</strong>() because of a change of the parent's type. Here's abbreviated pseudo-code that illustrates the problem:</p>
  
  <pre><code>class Window:
      def __init__ ( self, parent, .... ):
          # type: ( Optional[Window], .... )
  
  class Control ( Window ):
      def __init__ ( self, parent, .... ):
          # type: ( Optional[ControlHost], .... )
  </code></pre>
  
  <p>My work-around looks like this, but it doesn't allow mypy to catch type infractions:</p>
  
  <pre><code>class Control ( Control_mixin, Window ):
      ....
  
      def __init__ ( self, parent=None ):
          # type: ( Optional[ControlHost] ) -&gt; None
          self.initStyle |= winapi.WS_CHILD|winapi.WS_CLIPSIBLINGS
          assert isinstance ( parent, Window )
          super ( Control, self ).__init__ ( cast ( Window, parent ) )
  </code></pre>