def foo(x: int = 3, y: MyType = None) -> float: ... class MyType: ... foo_y_annotation = foo.__annotations__['y']