Parameters module
Note: this is a helper module that isn't directly related to the Tidi API.
tidi.parameters
Extends functionality of inspect.Parameter
to help work with typing.Annotated
function parameters.
AnnotatedParameter
Bases: Parameter
Subclass of inspect.Parameter
aimed for parameters with typing.Annotated
type.
Has extra properties that are useful when the type hint is typing.Annotated
.
Source code in src/tidi/parameters.py
annotated_metadata: tuple
property
A tuple of the extra annotations added via the typing.Annotated
hint.
base_type: t.Type
property
The real type of the typing.Annotated
parameter.
is_annotated_type: bool
property
True
if the origin type hint is typing.Annotated
, otherwise False
.
from_parameter(parameter)
classmethod
Builds a AnnotatedParameter
from a normal inspect.Parameter
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parameter |
Parameter
|
The normal |
required |
Returns:
Type | Description |
---|---|
AnnotatedParameter
|
the new |
Source code in src/tidi/parameters.py
AnnotatedParameters
Bases: list[AnnotatedParameter]
A list of AnnotatedParameter
instances.
Source code in src/tidi/parameters.py
from_func(func)
classmethod
Builds AnnotatedParameters
by inspecting a function's signature.