Reputation: 595
If I have the following:
def alert(self, text: str, color: str) -> str:
Can I get somehow the specified type of my arguments?
I tried using func.__code__.co_varnames
& inspect.getargspec(func)
without good results.
Upvotes: 1
Views: 78
Reputation: 451
blue_note's answer won't work with __future__.annotations
, introduced in python 3.7, use typing.get_type_hints instead.
Upvotes: 1
Reputation: 29061
The alert.__annotations__
has a dict with the types.
The key return
describes the return value. All other keys are the names of the arguments.
Upvotes: 1