Ah, I see. The fact that B is generic doesn't even matter -- this would also not work:
class A:
class B: ...
def method[T](self, arg: B, arg2: T) -> T: ...
because this is effectively translated to something like this:
class A:
class B: ...
def _helper():
T = TypeVar("T")
def method(self, arg: B, arg2: T) -> T: ...
return method
method = _helper()
and the current scoping rules work in such a way that B cannot be seen inside _helper(). Rewriting B a A.B doesn't work either, since A doesn't appear in the global scope until after the class body has executed.
The only solution I can think of would be to define a new kind of scope that has the desired semantics: variable references will first search in that scope (so T is found) and then in its parent scope (so B is found), even if the parent is a class. After that it will follow the regular scoping rules: if the whole thing lives inside a function, that function's scope is visible, but no further class scopes are visible, and of course at the end we have the global and builtin scopes.