title: Mypy errors in Generic class
body: <p>I slightly modified the <a href="https://mypy.readthedocs.io/en/stable/generics.html#defining-generic-classes" rel="nofollow noreferrer">documented mypy generic example</a> but got an error:</p>
  <pre class="lang-py prettyprint-override"><code>from typing import Generic, TypeVar, Union
  
  T = TypeVar(&quot;T&quot;, bound=Union[int, float])
  
  class Person(Generic[T]):
  
      def __init__(self, salary: T) -&gt; None:
          self.salary: T = salary
  
      def get_yearly_bonus(self, amount: T) -&gt; None:
          self.salary += amount
  
      def __str__(self) -&gt; str:
          return f&quot;Person(salary={self.salary})&quot;
  
  p = Person[int](9)
  p.get_yearly_bonus(6)
  print(p)
  </code></pre>
  <p>It seems mypy <em>fails to recognize</em> the fact that <code>self.salary</code> and <code>amount</code> <em>must</em>
  be of the <em>same</em> type.</p>
  <pre><code>$ mypy test.py 
  test.py:11: error: Incompatible types in assignment (expression has type &quot;float&quot;, variable has type &quot;T&quot;)
  test.py:11: error: Unsupported operand types for + (likely involving Union)
  Found 2 errors in 1 file (checked 1 source file)
  </code></pre>