Function
setattr_recursive
(obj: Any, path: str, value: Any)
Source from the content-addressed store, hash-verified
| 14 | target_modules: list[str] = ["to_q", "to_k", "to_v", "query", "key", "value"] |
| 15 | |
| 16 | def setattr_recursive(obj: Any, path: str, value: Any) -> None: |
| 17 | parts = path.split('.') |
| 18 | for part in parts[:-1]: |
| 19 | if part.isnumeric(): |
| 20 | obj = obj[int(part)] |
| 21 | else: |
| 22 | obj = getattr(obj, part) |
| 23 | setattr(obj, parts[-1], value) |
| 24 | |
| 25 | class DataProvider: |
| 26 | def __init__(self): |
Tested by
no test coverage detected