Fix up types for the typing handler. (#9638)

By splitting this to two separate methods the callers know
what methods they can expect on the handler.
This commit is contained in:
Patrick Cloke 2021-03-17 11:30:21 -04:00 committed by GitHub
parent 73dbce5523
commit cc324d53fe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 14 deletions

View file

@ -417,9 +417,18 @@ class HomeServer(metaclass=abc.ABCMeta):
return PresenceHandler(self)
@cache_in_self
def get_typing_handler(self):
def get_typing_writer_handler(self) -> TypingWriterHandler:
if self.config.worker.writers.typing == self.get_instance_name():
return TypingWriterHandler(self)
else:
raise Exception("Workers cannot write typing")
@cache_in_self
def get_typing_handler(self) -> FollowerTypingHandler:
if self.config.worker.writers.typing == self.get_instance_name():
# Use get_typing_writer_handler to ensure that we use the same
# cached version.
return self.get_typing_writer_handler()
else:
return FollowerTypingHandler(self)