pytorch
d5bda292 - [JIT] Tweak annotation extraction for py3.10 (#81334)

Commit
2 years ago
[JIT] Tweak annotation extraction for py3.10 (#81334) The way Python-3.10+ deals with annotations has changed, see https://docs.python.org/3/howto/annotations.html#accessing-the-annotations-dict-of-an-object-in-python-3-10-and-newer In particular, derived classes would not inherit parent annotations as following example clearly demonstrates: ``` class Base: a: int = 3 b: str = 'abc' class Derived(Base): pass print(Derived.__annotations__) ``` if executed by 3.10 runtime, it will return an empty dict, while older ones return annotations of the base class Fix that by implementing this difference in `get_annotations` function I wonder if in general, we should do it even for older versions of Python runtime Pull Request resolved: https://github.com/pytorch/pytorch/pull/81334 Approved by: https://github.com/suo
Author
Committer
Parents
Loading