patch_object - AG2
patch_object
autogen.import_utils.patch_object
def patch_object(
o: T,
*,
missing_modules: dict[str, str],
dep_target: str,
fail_if_not_patchable: bool = True,
except_for: Iterable[str] | None = None,
) -> T:
patcher = PatchObject.create(o, missing_modules=missing_modules, dep_target=dep_target)
if fail_if_not_patchable and patcher is None:
raise ValueError(f"Cannot patch object of type {type(o)}")
except_for = except_for if except_for is not None else []
except_for = [except_for] if isinstance(except_for, str) else except_for
return patcher.patch(except_for=except_for) if patcher else o
Source code in autogen/import_utils.py
<br>411<br>412<br>413<br>414<br>415<br>416<br>417<br>418<br>419<br>420<br>421<br>422<br>423<br>424<br>425<br>426<br> |
``` def patch_object( o: T, *, missing_modules: dict[str, str], dep_target: str, fail_if_not_patchable: bool = True, except_for: str |