Parameter
Parameter ¶
Parameter(name: str, kind: ParameterKind, annotation: TypeAnnotation = EMPTY, default: RuntimeValue = EMPTY, description: str | None = None, infer_type: bool = True, **legacy_kwargs: TypeAnnotation)
A Parameter instance contains information about a function or method parameter, including its name, type, default
value, and description.
Initialize a Parameter instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of the parameter. |
required |
kind
|
ParameterKind
|
The kind of the parameter (e.g. POSITIONAL_ONLY, VAR_POSITIONAL). |
required |
annotation
|
object
|
The type annotation of the parameter. |
EMPTY
|
default
|
object
|
The default value of the parameter. |
EMPTY
|
description
|
str | None
|
The description of the parameter. |
None
|
infer_type
|
bool
|
Infer the type of the parameter based on its default value. |
True
|
**legacy_kwargs
|
object
|
Backward-compatible keyword support for |
{}
|
Source code in objinspect/parameter.py
get_infered_type ¶
as_str ¶
Return a string representation of the parameter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
color
|
bool
|
Whether to colorize the output. |
True
|
theme
|
ParameterStrTheme
|
Color theme to use. Default will be used if None. |
None
|
Source code in objinspect/parameter.py
from_inspect_param
classmethod
¶
Create a Parameter instance from an inspect.Parameter object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
param
|
Parameter
|
The inspect.Parameter to convert. |
required |
description
|
str | None
|
Optional description for the parameter. |
None
|