summary refs log tree commit diff
path: root/synapse/http
diff options
context:
space:
mode:
authorPatrick Cloke <clokep@users.noreply.github.com>2021-07-21 09:47:56 -0400
committerGitHub <noreply@github.com>2021-07-21 09:47:56 -0400
commit5db118626bebb9ce3913758282787d47cd8f375e (patch)
tree9515e33f8e3a319f2e76ca88094654d946304979 /synapse/http
parentSwitch to `chunk` events so we can auth via power_levels (MSC2716) (#10432) (diff)
downloadsynapse-5db118626bebb9ce3913758282787d47cd8f375e.tar.xz
Add a return type to parse_string. (#10438)
And set the required attribute in a few places which will error if
a parameter is not provided.
Diffstat (limited to 'synapse/http')
-rw-r--r--synapse/http/servlet.py38
1 files changed, 37 insertions, 1 deletions
diff --git a/synapse/http/servlet.py b/synapse/http/servlet.py
index 04560fb589..cf45b6623b 100644
--- a/synapse/http/servlet.py
+++ b/synapse/http/servlet.py
@@ -172,6 +172,42 @@ def parse_bytes_from_args(
     return default
 
 
+@overload
+def parse_string(
+    request: Request,
+    name: str,
+    default: str,
+    *,
+    allowed_values: Optional[Iterable[str]] = None,
+    encoding: str = "ascii",
+) -> str:
+    ...
+
+
+@overload
+def parse_string(
+    request: Request,
+    name: str,
+    *,
+    required: Literal[True],
+    allowed_values: Optional[Iterable[str]] = None,
+    encoding: str = "ascii",
+) -> str:
+    ...
+
+
+@overload
+def parse_string(
+    request: Request,
+    name: str,
+    *,
+    required: bool = False,
+    allowed_values: Optional[Iterable[str]] = None,
+    encoding: str = "ascii",
+) -> Optional[str]:
+    ...
+
+
 def parse_string(
     request: Request,
     name: str,
@@ -179,7 +215,7 @@ def parse_string(
     required: bool = False,
     allowed_values: Optional[Iterable[str]] = None,
     encoding: str = "ascii",
-):
+) -> Optional[str]:
     """
     Parse a string parameter from the request query string.