introspection
Class info¶
🛈 DocStrings¶
Annotation introspection that survives lazily evaluated annotations (PEP 649).
Since Python 3.14 annotations are evaluated on access. Names that a module imports only
under if TYPE_CHECKING: then raise NameError when a signature or the type hints of a
user callable are read. The helpers here resolve whatever can be resolved and let only
the unresolvable parts degrade to Any (list[Missing] becomes list[Any]).
get_resolved_hints
¶
Evaluated type hints of a function or class.
Like typing.get_type_hints, but names that can't be resolved (e.g. imports under
TYPE_CHECKING) don't spoil the others: only the unresolvable parts become Any.
Source code in src/schemez/introspection.py
get_signature
¶
inspect.signature, with unresolvable annotation names degraded to Any.
Evaluates the annotations normally first, so nothing changes for callables whose
annotations resolve. Errors unrelated to annotations (e.g. ValueError for
callables without a signature) are raised as usual.
Source code in src/schemez/introspection.py
resolve_annotation
¶
Resolve forward references inside an annotation, degrading missing names to Any.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
annotation
|
Any
|
An annotation as returned in |
required |
owner
|
Any
|
The object the annotation belongs to (function or class), used for the namespace when the forward reference doesn't carry its own owner. |
None
|