From c1510c97b56060b7ab470b11264ed10dad445e14 Mon Sep 17 00:00:00 2001
From: Brendan Abolivier <babolivier@matrix.org>
Date: Mon, 25 Oct 2021 18:45:19 +0200
Subject: [PATCH] Fix cyclic import in the module API (#11180)

Introduced in #10548

See https://github.com/matrix-org/synapse-email-account-validity/runs/3979337154?check_suite_focus=true for an example of a module's CI choking over this issue.
---
 changelog.d/11180.feature | 1 +
 synapse/handlers/auth.py  | 6 ++++--
 2 files changed, 5 insertions(+), 2 deletions(-)
 create mode 100644 changelog.d/11180.feature

diff --git a/changelog.d/11180.feature b/changelog.d/11180.feature
new file mode 100644
index 000000000000..82c40bf1b222
--- /dev/null
+++ b/changelog.d/11180.feature
@@ -0,0 +1 @@
+Port the Password Auth Providers module interface to the new generic interface.
diff --git a/synapse/handlers/auth.py b/synapse/handlers/auth.py
index ebe75a9e9b22..d508d7d32ab1 100644
--- a/synapse/handlers/auth.py
+++ b/synapse/handlers/auth.py
@@ -62,7 +62,6 @@
 from synapse.http.site import SynapseRequest
 from synapse.logging.context import defer_to_thread
 from synapse.metrics.background_process_metrics import run_as_background_process
-from synapse.module_api import ModuleApi
 from synapse.storage.roommember import ProfileInfo
 from synapse.types import JsonDict, Requester, UserID
 from synapse.util import stringutils as stringutils
@@ -73,6 +72,7 @@
 from synapse.util.threepids import canonicalise_email
 
 if TYPE_CHECKING:
+    from synapse.module_api import ModuleApi
     from synapse.rest.client.login import LoginResponse
     from synapse.server import HomeServer
 
@@ -1818,7 +1818,9 @@ def load_legacy_password_auth_providers(hs: "HomeServer") -> None:
 
 
 def load_single_legacy_password_auth_provider(
-    module: Type, config: JsonDict, api: ModuleApi
+    module: Type,
+    config: JsonDict,
+    api: "ModuleApi",
 ) -> None:
     try:
         provider = module(config=config, account_handler=api)