mirror of
https://mau.dev/maunium/synapse.git
synced 2024-11-16 06:51:46 +01:00
Merge remote-tracking branch 'origin/develop' into rav/federation_client_async
This commit is contained in:
commit
5ef91b96f1
7 changed files with 382 additions and 345 deletions
1
changelog.d/6821.misc
Normal file
1
changelog.d/6821.misc
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Add type hints to `SyncHandler`.
|
1
changelog.d/6836.misc
Normal file
1
changelog.d/6836.misc
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Fix stacktraces when using `ObservableDeferred` and async/await.
|
|
@ -189,8 +189,14 @@ class EventBase(object):
|
||||||
redacts = _event_dict_property("redacts", None)
|
redacts = _event_dict_property("redacts", None)
|
||||||
room_id = _event_dict_property("room_id")
|
room_id = _event_dict_property("room_id")
|
||||||
sender = _event_dict_property("sender")
|
sender = _event_dict_property("sender")
|
||||||
|
state_key = _event_dict_property("state_key")
|
||||||
|
type = _event_dict_property("type")
|
||||||
user_id = _event_dict_property("sender")
|
user_id = _event_dict_property("sender")
|
||||||
|
|
||||||
|
@property
|
||||||
|
def event_id(self) -> str:
|
||||||
|
raise NotImplementedError()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def membership(self):
|
def membership(self):
|
||||||
return self.content["membership"]
|
return self.content["membership"]
|
||||||
|
@ -281,10 +287,7 @@ class FrozenEvent(EventBase):
|
||||||
else:
|
else:
|
||||||
frozen_dict = event_dict
|
frozen_dict = event_dict
|
||||||
|
|
||||||
self.event_id = event_dict["event_id"]
|
self._event_id = event_dict["event_id"]
|
||||||
self.type = event_dict["type"]
|
|
||||||
if "state_key" in event_dict:
|
|
||||||
self.state_key = event_dict["state_key"]
|
|
||||||
|
|
||||||
super(FrozenEvent, self).__init__(
|
super(FrozenEvent, self).__init__(
|
||||||
frozen_dict,
|
frozen_dict,
|
||||||
|
@ -294,6 +297,10 @@ class FrozenEvent(EventBase):
|
||||||
rejected_reason=rejected_reason,
|
rejected_reason=rejected_reason,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def event_id(self) -> str:
|
||||||
|
return self._event_id
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.__repr__()
|
return self.__repr__()
|
||||||
|
|
||||||
|
@ -332,9 +339,6 @@ class FrozenEventV2(EventBase):
|
||||||
frozen_dict = event_dict
|
frozen_dict = event_dict
|
||||||
|
|
||||||
self._event_id = None
|
self._event_id = None
|
||||||
self.type = event_dict["type"]
|
|
||||||
if "state_key" in event_dict:
|
|
||||||
self.state_key = event_dict["state_key"]
|
|
||||||
|
|
||||||
super(FrozenEventV2, self).__init__(
|
super(FrozenEventV2, self).__init__(
|
||||||
frozen_dict,
|
frozen_dict,
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -73,6 +73,10 @@ class ObservableDeferred(object):
|
||||||
def errback(f):
|
def errback(f):
|
||||||
object.__setattr__(self, "_result", (False, f))
|
object.__setattr__(self, "_result", (False, f))
|
||||||
while self._observers:
|
while self._observers:
|
||||||
|
# This is a little bit of magic to correctly propagate stack
|
||||||
|
# traces when we `await` on one of the observer deferreds.
|
||||||
|
f.value.__failure__ = f
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# TODO: Handle errors here.
|
# TODO: Handle errors here.
|
||||||
self._observers.pop().errback(f)
|
self._observers.pop().errback(f)
|
||||||
|
|
|
@ -238,8 +238,11 @@ class RedactionTestCase(unittest.HomeserverTestCase):
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def build(self, prev_event_ids):
|
def build(self, prev_event_ids):
|
||||||
built_event = yield self._base_builder.build(prev_event_ids)
|
built_event = yield self._base_builder.build(prev_event_ids)
|
||||||
built_event.event_id = self._event_id
|
|
||||||
|
built_event._event_id = self._event_id
|
||||||
built_event._event_dict["event_id"] = self._event_id
|
built_event._event_dict["event_id"] = self._event_id
|
||||||
|
assert built_event.event_id == self._event_id
|
||||||
|
|
||||||
return built_event
|
return built_event
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
1
tox.ini
1
tox.ini
|
@ -180,6 +180,7 @@ commands = mypy \
|
||||||
synapse/api \
|
synapse/api \
|
||||||
synapse/config/ \
|
synapse/config/ \
|
||||||
synapse/federation/transport \
|
synapse/federation/transport \
|
||||||
|
synapse/handlers/sync.py \
|
||||||
synapse/handlers/ui_auth \
|
synapse/handlers/ui_auth \
|
||||||
synapse/logging/ \
|
synapse/logging/ \
|
||||||
synapse/module_api \
|
synapse/module_api \
|
||||||
|
|
Loading…
Reference in a new issue