mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-03 01:04:49 -04:00
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.
This commit is contained in:
parent
2d89c66b88
commit
5db118626b
13 changed files with 86 additions and 45 deletions
|
@ -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.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue