(
cls, param: inspect.Parameter, allow_types: tuple[type[Param], ...]
)
| 204 | @classmethod |
| 205 | @override |
| 206 | def _check_param( |
| 207 | cls, param: inspect.Parameter, allow_types: tuple[type[Param], ...] |
| 208 | ) -> Self | None: |
| 209 | type_annotation, depends_inner = param.annotation, None |
| 210 | # extract type annotation and dependency from Annotated |
| 211 | if get_origin(param.annotation) is Annotated: |
| 212 | type_annotation, *extra_args = get_args(param.annotation) |
| 213 | depends_inner = next( |
| 214 | (x for x in reversed(extra_args) if isinstance(x, DependsInner)), None |
| 215 | ) |
| 216 | |
| 217 | # param default value takes higher priority |
| 218 | depends_inner = ( |
| 219 | param.default if isinstance(param.default, DependsInner) else depends_inner |
| 220 | ) |
| 221 | # not a dependent |
| 222 | if depends_inner is None: |
| 223 | return |
| 224 | |
| 225 | dependency: T_Handler |
| 226 | # sub dependency is not specified, use type annotation |
| 227 | if depends_inner.dependency is None: |
| 228 | assert type_annotation is not inspect.Signature.empty, ( |
| 229 | "Dependency cannot be empty" |
| 230 | ) |
| 231 | dependency = type_annotation |
| 232 | else: |
| 233 | dependency = depends_inner.dependency |
| 234 | # parse sub dependency |
| 235 | sub_dependent = Dependent[Any].parse( |
| 236 | call=dependency, |
| 237 | allow_types=allow_types, |
| 238 | ) |
| 239 | |
| 240 | return cls._from_field( |
| 241 | sub_dependent, depends_inner.use_cache, depends_inner.validate |
| 242 | ) |
| 243 | |
| 244 | @classmethod |
| 245 | @override |
nothing calls this directly
no test coverage detected