Build ``__copy__`` with ``__ffi_shallow_copy__`` resolved at install time.
(type_info: TypeInfo, shallow_copy_fn: Function | None)
| 164 | |
| 165 | |
| 166 | def _make_copy(type_info: TypeInfo, shallow_copy_fn: Function | None) -> Callable[..., Any]: |
| 167 | """Build ``__copy__`` with ``__ffi_shallow_copy__`` resolved at install time.""" |
| 168 | if shallow_copy_fn is not None: |
| 169 | |
| 170 | def __copy__(self: Any) -> Any: |
| 171 | return shallow_copy_fn(self) |
| 172 | |
| 173 | else: |
| 174 | |
| 175 | def __copy__(self: Any) -> Any: |
| 176 | raise TypeError( |
| 177 | f"Type `{type(self).__name__}` does not support copy. " |
| 178 | f"The underlying C++ type is not copy-constructible." |
| 179 | ) |
| 180 | |
| 181 | return __copy__ |
| 182 | |
| 183 | |
| 184 | def _make_deepcopy(_type_info: TypeInfo) -> Callable[..., Any]: |
no outgoing calls
no test coverage detected