typing.get_type_hints
is another method that doesn’t involve accessing magic properties directly:
from typing import get_type_hints
class Person:
name: str
age: int
get_type_hints(Person)
# returns {'name': <class 'str'>, 'age': <class 'int'>}