summary refs log tree commit diff
path: root/synapse/server.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2020-08-11 18:20:16 +0100
committerErik Johnston <erik@matrix.org>2020-08-11 18:20:45 +0100
commit8a3dac3c1970376f37c32b10edb3b9a98b116a3f (patch)
tree0e7e066a9f8ab7d9f0f70d1df54ae5cbac699603 /synapse/server.py
parentNewsfile (diff)
downloadsynapse-8a3dac3c1970376f37c32b10edb3b9a98b116a3f.tar.xz
Handle optional dependencies for Oidc and Saml
Diffstat (limited to '')
-rw-r--r--synapse/server.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/synapse/server.py b/synapse/server.py
index aec1ba408c..c78eb2fe46 100644
--- a/synapse/server.py
+++ b/synapse/server.py
@@ -25,7 +25,7 @@ import abc
 import functools
 import logging
 import os
-from typing import Any, Callable, Dict, List, Optional, TypeVar, cast
+from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional, TypeVar, cast
 
 import twisted
 from twisted.mail.smtp import sendmail
@@ -69,7 +69,6 @@ from synapse.handlers.events import EventHandler, EventStreamHandler
 from synapse.handlers.groups_local import GroupsLocalHandler, GroupsLocalWorkerHandler
 from synapse.handlers.initial_sync import InitialSyncHandler
 from synapse.handlers.message import EventCreationHandler, MessageHandler
-from synapse.handlers.oidc_handler import OidcHandler
 from synapse.handlers.pagination import PaginationHandler
 from synapse.handlers.password_policy import PasswordPolicyHandler
 from synapse.handlers.presence import PresenceHandler
@@ -85,7 +84,6 @@ from synapse.handlers.room import (
 from synapse.handlers.room_list import RoomListHandler
 from synapse.handlers.room_member import RoomMemberMasterHandler
 from synapse.handlers.room_member_worker import RoomMemberWorkerHandler
-from synapse.handlers.saml_handler import SamlHandler
 from synapse.handlers.set_password import SetPasswordHandler
 from synapse.handlers.stats import StatsHandler
 from synapse.handlers.sync import SyncHandler
@@ -120,6 +118,10 @@ from synapse.util.stringutils import random_string
 
 logger = logging.getLogger(__name__)
 
+if TYPE_CHECKING:
+    from synapse.handlers.oidc_handler import OidcHandler
+    from synapse.handlers.saml_handler import SamlHandler
+
 
 T = TypeVar("T", bound=Callable[..., Any])
 
@@ -603,12 +605,14 @@ class HomeServer(metaclass=abc.ABCMeta):
         return CasHandler(self)
 
     @cache_in_self
-    def get_saml_handler(self) -> SamlHandler:
+    def get_saml_handler(self) -> "SamlHandler":
+        from synapse.handlers.saml_handler import SamlHandler
 
         return SamlHandler(self)
 
     @cache_in_self
-    def get_oidc_handler(self) -> OidcHandler:
+    def get_oidc_handler(self) -> "OidcHandler":
+        from synapse.handlers.oidc_handler import OidcHandler
 
         return OidcHandler(self)