MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / constructor_copy

Function constructor_copy

lib/sqlalchemy/util/langhelpers.py:1478–1489  ·  view source on GitHub ↗

Instantiate cls using the __dict__ of obj as constructor arguments. Uses inspect to match the named arguments of ``cls``.

(obj: _T, cls: Type[_T], *args: Any, **kw: Any)

Source from the content-addressed store, hash-verified

1476
1477
1478def constructor_copy(obj: _T, cls: Type[_T], *args: Any, **kw: Any) -> _T:
1479 """Instantiate cls using the __dict__ of obj as constructor arguments.
1480
1481 Uses inspect to match the named arguments of ``cls``.
1482
1483 """
1484
1485 names = get_cls_kwargs(cls)
1486 kw.update(
1487 (k, obj.__dict__[k]) for k in names.difference(kw) if k in obj.__dict__
1488 )
1489 return cls(*args, **kw)
1490
1491
1492def counter() -> Callable[[], int]:

Callers

nothing calls this directly

Calls 3

get_cls_kwargsFunction · 0.85
updateMethod · 0.45
differenceMethod · 0.45

Tested by

no test coverage detected