MCPcopy
hub / github.com/pydantic/pydantic / __copy__

Method __copy__

pydantic/root_model.py:98–106  ·  view source on GitHub ↗

Returns a shallow copy of the model.

(self)

Source from the content-addressed store, hash-verified

96 _object_setattr(self, '__dict__', state['__dict__'])
97
98 def __copy__(self) -> Self:
99 """Returns a shallow copy of the model."""
100 cls = type(self)
101 m = cls.__new__(cls)
102 new_dict = copy(self.__dict__)
103 new_dict['root'] = copy(self.__dict__['root'])
104 _object_setattr(m, '__dict__', new_dict)
105 _object_setattr(m, '__pydantic_fields_set__', copy(self.__pydantic_fields_set__))
106 return m
107
108 def __deepcopy__(self, memo: dict[int, Any] | None = None) -> Self:
109 """Returns a deep copy of the model."""

Callers

nothing calls this directly

Calls 1

__new__Method · 0.45

Tested by

no test coverage detected