4 ms·
Adding that will break every single runtime typechecking module. Which is why in the end it was never included in python proper. If you don't do runtime typech
by guappa 3y ago
Adding that will break every single runtime typechecking module. Which is why in the end it was never included in python proper.
If you don't do runtime typechecking in the entire program, sure.
- durumu 3y agoIt 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.
- guappa 3y agoIf 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.