summary refs log tree commit diff
diff options
context:
space:
mode:
authorH. Shay <hillerys@element.io>2022-01-04 10:23:16 -0800
committerH. Shay <hillerys@element.io>2022-01-04 10:23:16 -0800
commit56d599e5ac35a397b43cf4b7e0d50d9e7d3a6223 (patch)
tree325dae21ac4d69b1406c06b28ea667cd4c5db811
parentFix AssertionErrors after purging events (#11642) (diff)
downloadsynapse-56d599e5ac35a397b43cf4b7e0d50d9e7d3a6223.tar.xz
run pyupgrade on synapse/_scripts and synapse/api
-rw-r--r--synapse/_scripts/register_new_matrix_user.py4
-rw-r--r--synapse/api/auth.py2
-rw-r--r--synapse/api/errors.py8
-rw-r--r--synapse/api/filtering.py4
-rw-r--r--synapse/api/urls.py2
5 files changed, 10 insertions, 10 deletions
diff --git a/synapse/_scripts/register_new_matrix_user.py b/synapse/_scripts/register_new_matrix_user.py
index 4ffe6a1ef3..cd8c9f176f 100644
--- a/synapse/_scripts/register_new_matrix_user.py
+++ b/synapse/_scripts/register_new_matrix_user.py
@@ -38,7 +38,7 @@ def request_registration(
     exit: Callable[[int], None] = sys.exit,
 ) -> None:
 
-    url = "%s/_synapse/admin/v1/register" % (server_location.rstrip("/"),)
+    url = "{}/_synapse/admin/v1/register".format(server_location.rstrip("/"))
 
     # Get the nonce
     r = requests.get(url, verify=False)
@@ -108,7 +108,7 @@ def register_new_user(
             default_user = None
 
         if default_user:
-            user = input("New user localpart [%s]: " % (default_user,))
+            user = input(f"New user localpart [{default_user}]: ")
             if not user:
                 user = default_user
         else:
diff --git a/synapse/api/auth.py b/synapse/api/auth.py
index 4a32d430bd..4057cf07a3 100644
--- a/synapse/api/auth.py
+++ b/synapse/api/auth.py
@@ -122,7 +122,7 @@ class Auth:
                 if not forgot:
                     return member
 
-        raise AuthError(403, "User %s not in room %s" % (user_id, room_id))
+        raise AuthError(403, f"User {user_id} not in room {room_id}")
 
     async def get_user_by_req(
         self,
diff --git a/synapse/api/errors.py b/synapse/api/errors.py
index 85302163da..723a9fc024 100644
--- a/synapse/api/errors.py
+++ b/synapse/api/errors.py
@@ -117,7 +117,7 @@ class RedirectException(CodeMessageException):
             location: the URI to redirect to
             http_code: the HTTP response code
         """
-        msg = "Redirect to %s" % (location.decode("utf-8"),)
+        msg = "Redirect to {}".format(location.decode("utf-8"))
         super().__init__(code=http_code, msg=msg)
         self.location = location
 
@@ -237,7 +237,7 @@ class FederationDeniedError(SynapseError):
 
         super().__init__(
             code=403,
-            msg="Federation denied with %s." % (self.destination,),
+            msg=f"Federation denied with {self.destination}.",
             errcode=Codes.FORBIDDEN,
         )
 
@@ -518,14 +518,14 @@ class FederationError(RuntimeError):
         source: Optional[str] = None,
     ):
         if level not in ["FATAL", "ERROR", "WARN"]:
-            raise ValueError("Level is not valid: %s" % (level,))
+            raise ValueError(f"Level is not valid: {level}")
         self.level = level
         self.code = code
         self.reason = reason
         self.affected = affected
         self.source = source
 
-        msg = "%s %s: %s" % (level, code, reason)
+        msg = f"{level} {code}: {reason}"
         super().__init__(msg)
 
     def get_dict(self) -> "JsonDict":
diff --git a/synapse/api/filtering.py b/synapse/api/filtering.py
index d087c816db..a1fb034909 100644
--- a/synapse/api/filtering.py
+++ b/synapse/api/filtering.py
@@ -218,7 +218,7 @@ class FilterCollection:
         self.event_format = filter_json.get("event_format", "client")
 
     def __repr__(self) -> str:
-        return "<FilterCollection %s>" % (json.dumps(self._filter_json),)
+        return "<FilterCollection {}>".format(json.dumps(self._filter_json))
 
     def get_filter_json(self) -> JsonDict:
         return self._filter_json
@@ -418,7 +418,7 @@ class Filter:
 
         for name, match_func in field_matchers.items():
             # If the event matches one of the disallowed values, reject it.
-            not_name = "not_%s" % (name,)
+            not_name = f"not_{name}"
             disallowed_values = getattr(self, not_name)
             if any(map(match_func, disallowed_values)):
                 return False
diff --git a/synapse/api/urls.py b/synapse/api/urls.py
index f9f9467dc1..a666a5145f 100644
--- a/synapse/api/urls.py
+++ b/synapse/api/urls.py
@@ -55,7 +55,7 @@ class ConsentURIBuilder:
         mac = hmac.new(
             key=self._hmac_secret, msg=user_id.encode("ascii"), digestmod=sha256
         ).hexdigest()
-        consent_uri = "%s_matrix/consent?%s" % (
+        consent_uri = "{}_matrix/consent?{}".format(
             self._public_baseurl,
             urlencode({"u": user_id, "h": mac}),
         )