'How to check TypeVar's Type at runtime

I have a generic class Graph[Generic[T], object].
My question, is there any function which returns type passed as generic to the class Graph

>>> g = Graph[int]()
>>> magic_func(g)
<class 'int'>


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source