
28 May
2019
28 May
'19
3:22 p.m.
On Tue, 28 May 2019 at 04:37, Till till.varoquaux@gmail.com wrote:
I didn't implement any good helper function because I couldn't figure out the idiomatic way to traverse type hints at runtime. It would be very easy to add a "get_extras(t: typing.<Type>) -> Tuple[Any, ...]" function. Would that work?
This reminds me about something I wanted to do for Python 3.8: there is an idea to add couple public helpers for introspection of typing objects. For example `get_origin()` and `get_args()`. That would essentially just thin public wrappers around private `__origin__`/`__args__` API.
With such API one will be able to just write `if get_origin(typ) is Annotated: ...`
-- Ivan