diff options
-rw-r--r-- | synapse/handlers/sync.py | 2 | ||||
-rw-r--r-- | synapse/types.py | 12 |
2 files changed, 9 insertions, 5 deletions
diff --git a/synapse/handlers/sync.py b/synapse/handlers/sync.py index 025eb82434..ebe6fac388 100644 --- a/synapse/handlers/sync.py +++ b/synapse/handlers/sync.py @@ -1305,7 +1305,7 @@ class SyncHandler: return DeviceLists(changed=users_that_have_changed, left=newly_left_users) else: - return DeviceLists(changed=[], left=[]) + return DeviceLists() async def _generate_sync_entry_for_to_device( self, sync_result_builder: "SyncResultBuilder" diff --git a/synapse/types.py b/synapse/types.py index 7346498f61..0355b959f0 100644 --- a/synapse/types.py +++ b/synapse/types.py @@ -20,11 +20,11 @@ from typing import ( TYPE_CHECKING, Any, ClassVar, - Collection, Dict, Mapping, MutableMapping, Optional, + Set, Tuple, Type, TypeVar, @@ -759,9 +759,13 @@ class DeviceLists: changed: List of user_ids whose devices may have changed left: List of user_ids whose devices we no longer track """ - - changed: Collection[str] - left: Collection[str] + # We need to use a factory here, otherwise `set` is not evaluated at + # object instantiation, but instead at class definition instantiation. + # The latter happening only once, thus always giving you the same sets + # across multiple DeviceLists instances. + # Also see: don't define mutable default arguments. + changed: Set[str] = attr.ib(factory=set) + left: Set[str] = attr.ib(factory=set) def __bool__(self) -> bool: return bool(self.changed or self.left) |