From eb9152b919a4659822763a19ab279c58eefca699 Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Thu, 18 Mar 2021 18:21:36 +0000 Subject: [PATCH] Remove Literal as it's broken on py35-olddeps --- synapse/events/presence_router.py | 6 +----- synapse/handlers/presence.py | 6 ++++-- tests/events/test_presence_router.py | 6 +----- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/synapse/events/presence_router.py b/synapse/events/presence_router.py index cd22cd14905b..28099c6e1e06 100644 --- a/synapse/events/presence_router.py +++ b/synapse/events/presence_router.py @@ -15,8 +15,6 @@ from typing import TYPE_CHECKING, Dict, Iterable, Set, Union -from typing_extensions import Literal - from synapse.api.presence import UserPresenceState if TYPE_CHECKING: @@ -66,9 +64,7 @@ async def get_users_for_states( # Don't include any extra destinations for presence updates return {} - async def get_interested_users( - self, user_id: str - ) -> Union[Set[str], Literal["ALL"]]: + async def get_interested_users(self, user_id: str) -> Union[Set[str], str]: """ Retrieve a list of users that the provided user is interested in receiving the presence of. Optionally, the str "ALL" can be returned to mean that this user should receive all diff --git a/synapse/handlers/presence.py b/synapse/handlers/presence.py index 24d4b487cf19..b85bea2f99f5 100644 --- a/synapse/handlers/presence.py +++ b/synapse/handlers/presence.py @@ -38,7 +38,7 @@ ) from prometheus_client import Counter -from typing_extensions import ContextManager, Literal +from typing_extensions import ContextManager import synapse.metrics from synapse.api.constants import EventTypes, Membership, PresenceState @@ -1134,6 +1134,8 @@ async def get_new_events( return list(users_to_state.values()), max_token + assert not isinstance(users_interested_in, str) + # The set of users that we're interested in and that have had a presence update. # We'll actually pull the presence updates for these users at the end. interested_and_updated_users = ( @@ -1257,7 +1259,7 @@ async def _get_interested_in( user: UserID, explicit_room_id: Optional[str] = None, cache_context: Optional[_CacheContext] = None, - ) -> Union[Set[str], Literal["ALL"]]: + ) -> Union[Set[str], str]: """Returns the set of users that the given user should see presence updates for. diff --git a/tests/events/test_presence_router.py b/tests/events/test_presence_router.py index cba594509983..3e1fec845344 100644 --- a/tests/events/test_presence_router.py +++ b/tests/events/test_presence_router.py @@ -15,7 +15,6 @@ from typing import Dict, Iterable, List, Optional, Set, Union import attr -from typing_extensions import Literal from synapse.handlers.presence import UserPresenceState from synapse.module_api import ModuleApi @@ -47,10 +46,7 @@ async def get_users_for_states( } return users_to_state - async def get_interested_users( - self, user_id: str - ) -> Union[Set[str], Literal["ALL"]]: - print() + async def get_interested_users(self, user_id: str) -> Union[Set[str], str]: if user_id in self._config.users_who_should_receive_all_presence: return "ALL"