I want to get annotations in functions or methods of a class. If the hintings types are written in source code, I can get the types by getting the attribute __annotations__.
def hoge(n: int): ...
print(hoge.__annotations__)
But I don’t know how to get types written in stub files (.pyi).
def fuga(n: int): ...
def fuga(n): ...
print(fuga.__annotations__)
Is there any cool method?
source
share