Skip to content
Snippets Groups Projects
Verified Commit d8194ef6 authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Fix typing

parent b9b30782
No related branches found
No related tags found
1 merge request!2Resolve "Review tasks"
Pipeline #55929 canceled
import re
from typing import Any, Dict, List, Optional, Union
from typing import Any, Optional, Union
from django.db import models
from django.db.models import Q
......@@ -124,9 +124,9 @@ class MatrixRoom(ExtensiblePolymorphicModel):
self,
name,
alias,
invite: Optional[List[str]] = None,
invite: Optional[list[str]] = None,
creation_content: Optional[dict] = None,
) -> Dict[str, Any]:
) -> dict[str, Any]:
from .util.matrix import do_matrix_request
body = {"preset": "private_chat", "name": name, "room_alias_name": alias}
......@@ -142,7 +142,7 @@ class MatrixRoom(ExtensiblePolymorphicModel):
return r
@property
def power_levels(self) -> Dict[str, int]:
def power_levels(self) -> dict[str, int]:
"""Return the power levels for this room."""
from .util.matrix import do_matrix_request
......@@ -154,7 +154,7 @@ class MatrixRoom(ExtensiblePolymorphicModel):
return user_levels
@property
def members(self) -> List[str]:
def members(self) -> list[str]:
from .util.matrix import do_matrix_request
r = do_matrix_request(
......@@ -162,7 +162,7 @@ class MatrixRoom(ExtensiblePolymorphicModel):
)
return [m["state_key"] for m in r["chunk"]]
def _invite(self, profile: MatrixProfile) -> Dict[str, Any]:
def _invite(self, profile: MatrixProfile) -> dict[str, Any]:
"""Invite a user to this room."""
from .util.matrix import do_matrix_request
......@@ -173,7 +173,7 @@ class MatrixRoom(ExtensiblePolymorphicModel):
)
return r
def _set_power_levels(self, power_levels: Dict[str, int]) -> Dict[str, Any]:
def _set_power_levels(self, power_levels: dict[str, int]) -> dict[str, Any]:
"""Set the power levels for this room."""
r = do_matrix_request(
"PUT",
......@@ -270,16 +270,16 @@ class MatrixSpace(MatrixRoom):
self,
name,
alias,
invite: Optional[List[str]] = None,
invite: Optional[list[str]] = None,
creation_content: Optional[dict] = None,
) -> Dict[str, Any]:
) -> dict[str, Any]:
if not creation_content:
creation_content = {}
creation_content["type"] = "m.space"
return super()._create_room(name, alias, invite, creation_content)
@property
def child_spaces(self) -> List[str]:
def child_spaces(self) -> list[str]:
"""Get all child spaces of this space."""
from .util.matrix import do_matrix_request
......
import time
from json import JSONDecodeError
from typing import Any, Dict, Optional
from typing import Any, Optional
from urllib.parse import urljoin
import requests
......@@ -24,7 +24,7 @@ def get_headers():
}
def do_matrix_request(method: str, url: str, body: Optional[dict] = None) -> Dict[str, Any]:
def do_matrix_request(method: str, url: str, body: Optional[dict] = None) -> dict[str, Any]:
"""Do a HTTP request to the Matrix Client Server API."""
while True:
res = requests.request(method=method, url=build_url(url), headers=get_headers(), json=body)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment