(obj: Any, path: str)
| 3 | from typing import Union, Tuple, Any |
| 4 | |
| 5 | def getattr_recursive(obj: Any, path: str) -> Any: |
| 6 | parts = path.split('.') |
| 7 | for part in parts: |
| 8 | if part.isnumeric(): |
| 9 | obj = obj[int(part)] |
| 10 | else: |
| 11 | obj = getattr(obj, part) |
| 12 | return obj |
| 13 | |
| 14 | target_modules: list[str] = ["to_q", "to_k", "to_v", "query", "key", "value"] |
| 15 |