(
self,
state: InstanceState[Any],
dict_: _InstanceDict,
value: Any,
initiator: Optional[AttributeEventToken] = None,
passive: PassiveFlag = PassiveFlag.PASSIVE_OFF,
check_old: Any = None,
pop: bool = False,
_adapt: bool = True,
)
| 298 | return state.committed_state[self.key] # type: ignore[no-any-return] |
| 299 | |
| 300 | def set( |
| 301 | self, |
| 302 | state: InstanceState[Any], |
| 303 | dict_: _InstanceDict, |
| 304 | value: Any, |
| 305 | initiator: Optional[AttributeEventToken] = None, |
| 306 | passive: PassiveFlag = PassiveFlag.PASSIVE_OFF, |
| 307 | check_old: Any = None, |
| 308 | pop: bool = False, |
| 309 | _adapt: bool = True, |
| 310 | ) -> None: |
| 311 | if initiator and initiator.parent_token is self.parent_token: |
| 312 | return |
| 313 | |
| 314 | if pop and value is None: |
| 315 | return |
| 316 | |
| 317 | iterable = value |
| 318 | new_values = list(iterable) |
| 319 | if state.has_identity: |
| 320 | if not self._supports_dynamic_iteration: |
| 321 | raise exc.InvalidRequestError( |
| 322 | f'Collection "{self}" does not support implicit ' |
| 323 | "iteration; collection replacement operations " |
| 324 | "can't be used" |
| 325 | ) |
| 326 | old_collection = util.IdentitySet( |
| 327 | self.get(state, dict_, passive=passive) |
| 328 | ) |
| 329 | |
| 330 | collection_history = self._modified_event(state, dict_) |
| 331 | if not state.has_identity: |
| 332 | old_collection = collection_history.added_items |
| 333 | else: |
| 334 | old_collection = old_collection.union( |
| 335 | collection_history.added_items |
| 336 | ) |
| 337 | |
| 338 | constants = old_collection.intersection(new_values) |
| 339 | additions = util.IdentitySet(new_values).difference(constants) |
| 340 | removals = old_collection.difference(constants) |
| 341 | |
| 342 | for member in new_values: |
| 343 | if member in additions: |
| 344 | self.fire_append_event( |
| 345 | state, |
| 346 | dict_, |
| 347 | member, |
| 348 | None, |
| 349 | collection_history=collection_history, |
| 350 | ) |
| 351 | |
| 352 | for member in removals: |
| 353 | self.fire_remove_event( |
| 354 | state, |
| 355 | dict_, |
| 356 | member, |
| 357 | None, |
nothing calls this directly
no test coverage detected