Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It kind of works, you just have to use `typing.get_annotations(func)` instead of `func.__annotations__`. Although if you aren't importing the types used in your annotations that isn't going to work... I would guess that's rare in practice.


If you define a class inside another class or a function, get_annotations() will never be able to resolve it and just return a string, which is not very useful.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: