From d013bf92133e58abc1902a2b98d1e380cdbe10d1 Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Wed, 17 Mar 2021 16:35:14 +0000 Subject: [PATCH] Import Literal from typing_extensions instead We can't import it from typing until Py3.8. --- synapse/events/presence_router.py | 4 +++- synapse/handlers/presence.py | 3 +-- tests/events/test_presence_router.py | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/synapse/events/presence_router.py b/synapse/events/presence_router.py index 9942a5508351..a8e4f676da98 100644 --- a/synapse/events/presence_router.py +++ b/synapse/events/presence_router.py @@ -13,7 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -from typing import TYPE_CHECKING, Dict, Iterable, Literal, Set, Union +from typing import TYPE_CHECKING, Dict, Iterable, Set, Union + +from typing_extensions import Literal from synapse.handlers.presence import UserPresenceState diff --git a/synapse/handlers/presence.py b/synapse/handlers/presence.py index ac45e056bd3f..e43cf64d85a4 100644 --- a/synapse/handlers/presence.py +++ b/synapse/handlers/presence.py @@ -31,7 +31,6 @@ FrozenSet, Iterable, List, - Literal, Optional, Set, Tuple, @@ -39,7 +38,7 @@ ) from prometheus_client import Counter -from typing_extensions import ContextManager +from typing_extensions import ContextManager, Literal import synapse.metrics from synapse.api.constants import EventTypes, Membership, PresenceState diff --git a/tests/events/test_presence_router.py b/tests/events/test_presence_router.py index b434db018eb1..9ff0800d7747 100644 --- a/tests/events/test_presence_router.py +++ b/tests/events/test_presence_router.py @@ -12,9 +12,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -from typing import Dict, Iterable, List, Literal, Optional, Set, Union +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