Type annotations with dependent name

Hello, I am writing a program like

T = TypeVar('T')
class A(Generic[T]):
  def func(self, a: T, b: T.E):

here I will only pass some special type as T to class A, which definitly own a class attribute E which is also a type. Can I implement correctly in python? Obviously, the former code is wrong since T is just a TypeVar, rather than type itself.

for example:

class X:
  E = int
class Y:
  E = float

these two type X and Y will be pass as T to class A.

If any one is familiar with c++, I just want to implement something like

template <typename T>
struct A {
  void func(T a, typename T::E b);

I try to pass generic argument to A.init

class A:
  def __init__(self, T):
    self.T = T
  def func(self, a: self.T, b: self.T.E):

but this seems an invalid annotations