title: Get generic type of class at runtime with Python 3.6
body: <p>Following a solution described in this question: <a href="https://stackoverflow.com/questions/48572831/how-to-access-the-type-arguments-of-typing-generic">How to access the type arguments of typing.Generic?</a></p>
  <p>I have successfully solved a generic type at runtime in Python 3.8. However I can't seem to be able to access the <code>__args__</code> field described in the solution for Python 3.6. I'm not sure why, here's my code:</p>
  <pre class="lang-py prettyprint-override"><code>def get_generic_type_arg(cls):
      if py_version &gt;= (3, 8):
          t = cls.__orig_bases__[0]
          return get_args(t)[0]
      else:
          t = cls.__args__
          return None
  
  class EventContract:
      @classmethod
      def get_version(cls) -&gt; int:
          return int(cls.__name__[1:])
  
  
  RT = TypeVar('RT', bound=EventContract)
  
  
  class QueryContract(Generic[RT], EventContract):
      &quot;&quot;&quot; Base class for query contracts that are versioned. &quot;&quot;&quot;
  
      @classmethod  # Do not override this
      def get_response_class(cls) -&gt; Type[RT]:
          return get_generic_type_arg(cls)
  
      def build_result(self, *args, **kwargs):
          return self.get_response_class()(**kwargs)
  
  
  @dataclasses.dataclass
  class V1Response(EventContract):
      value: int
  
  
  @dataclasses.dataclass
  class V1(QueryContract[V1Response]):
      id: int
      name: str
  
  </code></pre>
  <p>When trying to call <code>get_generic_type</code> on <code>cls</code> I get an <code>AttributeError</code>. I also tried to fetch its base class using <code>t.__bases__[0]</code> which gives me the <code>QueryContract</code> with no generic arguments (<code>__args__</code> gives me another attribute error). I am calling the <code>get_response_class</code> method on <code>V1</code>. Any ideas ?</p>