typespecs.typing module#
- class typespecs.typing.HasAnnotations(*args, **kwargs)[source]#
Bases:
ProtocolType hint for any object with annotations.
- typespecs.typing.get_annotation(obj: Any, /, *, recursive: bool = False) Any[source]#
Return metadata-stripped annotation of given object.
- Parameters:
obj – Object to inspect.
recursive – Whether to recursively strip all metadata.
- Returns:
Metadata-stripped annotation of the object.
- typespecs.typing.get_annotations(obj: Any, /) dict[str, Any][source]#
Return all annotations of given object.
Prior to Python 3.14, this is identical to
typing_extensions.get_annotations. For Python 3.14 and later, it falls back to the object’s class if__annotations__is missing.- Parameters:
obj – Object to inspect.
- Returns:
Dictionary of all annotations of the object.
- typespecs.typing.get_metadata(obj: Any, /) list[Any][source]#
Return all metadata of given object.
- Parameters:
obj – Object to inspect.
- Returns:
List of all metadata of the object.
- typespecs.typing.get_subannotations(obj: Any, /) list[Any][source]#
Return all sub-annotations of given object.
- Parameters:
obj – Object to inspect.
- Returns:
List of all sub-annotations of the object.