Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Remove Literal as it's broken on py35-olddeps
Browse files Browse the repository at this point in the history
  • Loading branch information
anoadragon453 committed Mar 19, 2021
1 parent 918fef1 commit eb9152b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
6 changes: 1 addition & 5 deletions synapse/events/presence_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions synapse/handlers/presence.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 = (
Expand Down Expand Up @@ -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.
Expand Down
6 changes: 1 addition & 5 deletions tests/events/test_presence_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"

Expand Down

0 comments on commit eb9152b

Please sign in to comment.