MCPcopy
hub / github.com/python-attrs/attrs / __setstate__

Method __setstate__

src/attr/_make.py:2637–2652  ·  view source on GitHub ↗

Play nice with pickle.

(self, state)

Source from the content-addressed store, hash-verified

2635 )
2636
2637 def __setstate__(self, state):
2638 """
2639 Play nice with pickle.
2640 """
2641 if len(state) < len(self.__slots__):
2642 # Pre-26.1.0 pickle without alias_is_default -- infer it
2643 # heuristically.
2644 state_dict = dict(zip(self.__slots__, state))
2645 alias_is_default = state_dict.get(
2646 "alias"
2647 ) is None or state_dict.get("alias") == _default_init_alias_for(
2648 state_dict["name"]
2649 )
2650 state = (*state, alias_is_default)
2651
2652 self._setattrs(zip(self.__slots__, state))
2653
2654 def _setattrs(self, name_values_pairs):
2655 bound_setattr = _OBJ_SETATTR.__get__(self)

Callers

nothing calls this directly

Calls 2

_setattrsMethod · 0.95
_default_init_alias_forFunction · 0.85

Tested by

no test coverage detected