Get metadata from an annotated type.
(obj: Any, match: type[T])
| 64 | |
| 65 | |
| 66 | def get_meta(obj: Any, match: type[T]) -> T | None: |
| 67 | """Get metadata from an annotated type.""" |
| 68 | if is_initvar(obj): |
| 69 | return get_meta(obj.type, match) |
| 70 | if not is_annotated(obj): |
| 71 | return None |
| 72 | return next( |
| 73 | (arg for arg in reversed(typing.get_args(obj)) if isinstance(arg, match)), |
| 74 | None, |
| 75 | ) |
| 76 | |
| 77 | |
| 78 | def get_doc(obj: Any) -> str | None: |
no test coverage detected