Produce an empty collection for an un-initialized attribute
(
self, state: InstanceState[Any], dict_: _InstanceDict
)
| 1852 | del dict_[self.key] |
| 1853 | |
| 1854 | def _default_value( |
| 1855 | self, state: InstanceState[Any], dict_: _InstanceDict |
| 1856 | ) -> _AdaptedCollectionProtocol: |
| 1857 | """Produce an empty collection for an un-initialized attribute""" |
| 1858 | |
| 1859 | assert self.key not in dict_, ( |
| 1860 | "_default_value should only be invoked for an " |
| 1861 | "uninitialized or expired attribute" |
| 1862 | ) |
| 1863 | |
| 1864 | if self.key in state._empty_collections: |
| 1865 | return state._empty_collections[self.key] |
| 1866 | |
| 1867 | adapter, user_data = self._initialize_collection(state) |
| 1868 | adapter._set_empty(user_data) |
| 1869 | return user_data |
| 1870 | |
| 1871 | def _initialize_collection( |
| 1872 | self, state: InstanceState[Any] |
no test coverage detected