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

Commit

Permalink
Work around cyclic import error
Browse files Browse the repository at this point in the history
  • Loading branch information
reivilibre committed Oct 13, 2021
1 parent 4044442 commit fae38e7
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions tests/rest/client/test_third_party_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,27 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import threading
from typing import Dict
from typing import TYPE_CHECKING, Dict
from unittest.mock import Mock

from synapse.api.constants import EventTypes
from synapse.events import EventBase
from synapse.events.third_party_rules import load_legacy_third_party_event_rules
from synapse.module_api import ModuleApi
from synapse.rest import admin
from synapse.rest.client import login, room
from synapse.types import Requester, StateMap
from synapse.util.frozenutils import unfreeze

from tests import unittest

if TYPE_CHECKING:
from synapse.module_api import ModuleApi

thread_local = threading.local()


class LegacyThirdPartyRulesTestModule:
def __init__(self, config: Dict, module_api: ModuleApi):
def __init__(self, config: Dict, module_api: "ModuleApi"):
# keep a record of the "current" rules module, so that the test can patch
# it if desired.
thread_local.rules_module = self
Expand All @@ -50,7 +52,7 @@ def parse_config(config):


class LegacyDenyNewRooms(LegacyThirdPartyRulesTestModule):
def __init__(self, config: Dict, module_api: ModuleApi):
def __init__(self, config: Dict, module_api: "ModuleApi"):
super().__init__(config, module_api)

def on_create_room(
Expand All @@ -60,7 +62,7 @@ def on_create_room(


class LegacyChangeEvents(LegacyThirdPartyRulesTestModule):
def __init__(self, config: Dict, module_api: ModuleApi):
def __init__(self, config: Dict, module_api: "ModuleApi"):
super().__init__(config, module_api)

async def check_event_allowed(self, event: EventBase, state: StateMap[EventBase]):
Expand Down

0 comments on commit fae38e7

Please sign in to comment.