Let's say I have something like the following:
import inspect
from collections.abc import Callable # Using Python 3.10+
from typing import get_type_hints
def foo(arg: Callable[..., int]) -> None:
pass
type_hints = get_type_hints(foo)["arg"]
annotation = inspect.signature(foo).parameters["arg"].annotation
# How can one get the return type `int` from either of these?
I can figure out how to get to the Callable
type hint. From there, how can one inspect the return type of the Callable
?
Aucun commentaire:
Enregistrer un commentaire