title: Classmethods on generic classes
body: <p>I try to call a classmethod on a generic class:</p>
  <pre class="lang-py prettyprint-override"><code>from typing import List, Union, TypeVar, Generic
  from enum import IntEnum
  
  class Gender(IntEnum):
      MALE = 1
      FEMALE = 2
      DIVERS = 3
  
  
  T = TypeVar('T')
  
  class EnumAggregate(Generic[T]):
      def __init__(self, value: Union[int, str, List[T]]) -&gt; None:
          if value == '':
              raise ValueError(f'Parameter &quot;value&quot; cannot be empty!')
  
          if isinstance(value, list):
              self._value = ''.join([str(x.value) for x in value])
          else:
              self._value = str(value)
  
      def __contains__(self, item: T) -&gt; bool:
          return item in self.to_list
  
      @property
      def to_list(self) -&gt; List[T]:
          return [T(int(character)) for character in self._value]
  
      @property
      def value(self) -&gt; str:
          return self._value
  
      @classmethod
      def all(cls) -&gt; str:
          return ''.join([str(x.value) for x in T])
  
  Genders = EnumAggregate[Gender]
  </code></pre>
  <p>But if I call</p>
  <pre class="lang-py prettyprint-override"><code>Genders.all()
  </code></pre>
  <p>I get the error <code>TypeError: 'TypeVar' object is not iterable</code>. So the TypeVar <code>T</code> isn't properly matched with the Enum <code>Gender</code>.</p>
  <p>How can I fix this? The expected behavior would be</p>
  <pre class="lang-py prettyprint-override"><code>&gt;&gt;&gt; Genders.all()
  '123'
  </code></pre>
  <p>Any ideas? Or is this impossible?</p>