(
call: _DependentCallable[R], allow_types: tuple[type[Param], ...]
)
| 118 | |
| 119 | @staticmethod |
| 120 | def parse_params( |
| 121 | call: _DependentCallable[R], allow_types: tuple[type[Param], ...] |
| 122 | ) -> tuple[ModelField, ...]: |
| 123 | fields: list[ModelField] = [] |
| 124 | params = get_typed_signature(call).parameters.values() |
| 125 | |
| 126 | for param in params: |
| 127 | if isinstance(param.default, Param): |
| 128 | field_info = param.default |
| 129 | else: |
| 130 | for allow_type in allow_types: |
| 131 | if field_info := allow_type._check_param(param, allow_types): |
| 132 | break |
| 133 | else: |
| 134 | raise ValueError( |
| 135 | f"Unknown parameter {param.name} " |
| 136 | f"for function {call} with type {param.annotation}" |
| 137 | ) |
| 138 | |
| 139 | annotation: Any = Any |
| 140 | if param.annotation is not param.empty: |
| 141 | annotation = param.annotation |
| 142 | |
| 143 | fields.append( |
| 144 | ModelField.construct( |
| 145 | name=param.name, annotation=annotation, field_info=field_info |
| 146 | ) |
| 147 | ) |
| 148 | |
| 149 | return tuple(fields) |
| 150 | |
| 151 | @staticmethod |
| 152 | def parse_parameterless( |
no test coverage detected