title: typed python: using the classes' own type inside class definition
body: <p>The following code does not work as expected. Apparently, I cannot use the classes' own type inside class definition:</p>
  
  <pre><code>class Foo:
      def __init__(self, key :str) -&gt; None:
          self.key = key
  
      def __eq__(self, other :Foo) -&gt; bool:
          return self.key == other.key
  
  print('should be true: ', Foo('abc') == Foo('abc'))
  print('should be false: ', Foo('abc') == Foo('def'))
  </code></pre>
  
  <p>The result of running it is:</p>
  
  <pre><code>Traceback (most recent call last):
    File "class_own_type.py", line 1, in &lt;module&gt;
      class Foo:
    File "class_own_type.py", line 5, in Foo
      def __eq__(self, other :Foo) -&gt; bool:
  NameError: name 'Foo' is not defined
  </code></pre>
  
  <p>Also, checking the code with <code>mypy</code> returns:</p>
  
  <pre><code>class_own_type.py:5: error: Argument 1 of "__eq__" incompatible with supertype "object"
  </code></pre>
  
  <p>How can I correct this code to be valid, both for Python and for <code>mypy</code>?</p>