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)
| 1476 | |
| 1477 | |
| 1478 | def 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 | |
| 1492 | def counter() -> Callable[[], int]: |
nothing calls this directly
no test coverage detected