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

This commit is contained in:
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 return default
@overload
def parse_bytes_from_args(
args: Dict[bytes, List[bytes]],
name: str,
default: Optional[bytes] = None,
) -> Optional[bytes]:
...
@overload @overload
def parse_bytes_from_args( def parse_bytes_from_args(
args: Dict[bytes, List[bytes]], args: Dict[bytes, List[bytes]],
name: str, name: str,
default: Literal[None] = None, default: Literal[None] = None,
required: Literal[True] = True, *,
required: Literal[True],
) -> bytes: ) -> bytes:
... ...
@ -197,7 +207,12 @@ def parse_string(
""" """
args = request.args # type: Dict[bytes, List[bytes]] # type: ignore args = request.args # type: Dict[bytes, List[bytes]] # type: ignore
return parse_string_from_args( 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]], args: Dict[bytes, List[bytes]],
name: str, name: str,
default: Optional[List[str]] = None, 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, allowed_values: Optional[Iterable[str]] = None,
encoding: str = "ascii", encoding: str = "ascii",
) -> List[str]: ) -> List[str]:
@ -239,6 +267,7 @@ def parse_strings_from_args(
args: Dict[bytes, List[bytes]], args: Dict[bytes, List[bytes]],
name: str, name: str,
default: Optional[List[str]] = None, default: Optional[List[str]] = None,
*,
required: bool = False, required: bool = False,
allowed_values: Optional[Iterable[str]] = None, allowed_values: Optional[Iterable[str]] = None,
encoding: str = "ascii", encoding: str = "ascii",
@ -299,7 +328,20 @@ def parse_string_from_args(
args: Dict[bytes, List[bytes]], args: Dict[bytes, List[bytes]],
name: str, name: str,
default: Optional[str] = None, 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, allowed_values: Optional[Iterable[str]] = None,
encoding: str = "ascii", encoding: str = "ascii",
) -> str: ) -> str: