Add additional types to the federation transport server. (#10213)

anoa/admin_room_account_data
Patrick Cloke 2021-06-28 07:36:41 -04:00 committed by GitHub
parent 717f73c411
commit 0555d7b0dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 521 additions and 118 deletions

1
changelog.d/10213.misc Normal file
View File

@ -0,0 +1 @@
Add type hints to the federation servlets.

File diff suppressed because it is too large Load Diff

View File

@ -109,12 +109,22 @@ def parse_boolean_from_args(args, name, default=None, required=False):
return default
@overload
def parse_bytes_from_args(
args: Dict[bytes, List[bytes]],
name: str,
default: Optional[bytes] = None,
) -> Optional[bytes]:
...
@overload
def parse_bytes_from_args(
args: Dict[bytes, List[bytes]],
name: str,
default: Literal[None] = None,
required: Literal[True] = True,
*,
required: Literal[True],
) -> bytes:
...
@ -197,7 +207,12 @@ def parse_string(
"""
args = request.args # type: Dict[bytes, List[bytes]] # type: ignore
return parse_string_from_args(
args, name, default, required, allowed_values, encoding
args,
name,
default,
required=required,
allowed_values=allowed_values,
encoding=encoding,
)
@ -227,7 +242,20 @@ def parse_strings_from_args(
args: Dict[bytes, List[bytes]],
name: str,
default: Optional[List[str]] = None,
required: Literal[True] = True,
*,
allowed_values: Optional[Iterable[str]] = None,
encoding: str = "ascii",
) -> Optional[List[str]]:
...
@overload
def parse_strings_from_args(
args: Dict[bytes, List[bytes]],
name: str,
default: Optional[List[str]] = None,
*,
required: Literal[True],
allowed_values: Optional[Iterable[str]] = None,
encoding: str = "ascii",
) -> List[str]:
@ -239,6 +267,7 @@ def parse_strings_from_args(
args: Dict[bytes, List[bytes]],
name: str,
default: Optional[List[str]] = None,
*,
required: bool = False,
allowed_values: Optional[Iterable[str]] = None,
encoding: str = "ascii",
@ -299,7 +328,20 @@ def parse_string_from_args(
args: Dict[bytes, List[bytes]],
name: str,
default: Optional[str] = None,
required: Literal[True] = True,
*,
allowed_values: Optional[Iterable[str]] = None,
encoding: str = "ascii",
) -> Optional[str]:
...
@overload
def parse_string_from_args(
args: Dict[bytes, List[bytes]],
name: str,
default: Optional[str] = None,
*,
required: Literal[True],
allowed_values: Optional[Iterable[str]] = None,
encoding: str = "ascii",
) -> str: