diff options
author | David Robertson <davidr@element.io> | 2021-11-12 15:50:54 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-12 15:50:54 +0000 |
commit | 4c96ce396e900a94af66ec070af925881b6e1e24 (patch) | |
tree | 446920e10d66c2ace553a68541ed64e0fbd543e1 /tests/rest/client | |
parent | Generalize the disallowed_untyped_defs in mypy.ini (#11322) (diff) | |
download | synapse-4c96ce396e900a94af66ec070af925881b6e1e24.tar.xz |
Misc typing fixes for `tests`, part 1 of N (#11323)
* Annotate HomeserverTestCase.servlets * Correct annotation of federation_auth_origin * Use AnyStr custom_headers instead of a Union This allows (str, str) and (bytes, bytes). This disallows (str, bytes) and (bytes, str) * DomainSpecificString.SIGIL is a ClassVar
Diffstat (limited to 'tests/rest/client')
-rw-r--r-- | tests/rest/client/utils.py | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/tests/rest/client/utils.py b/tests/rest/client/utils.py index ec0979850b..7cf782e2d6 100644 --- a/tests/rest/client/utils.py +++ b/tests/rest/client/utils.py @@ -19,7 +19,17 @@ import json import re import time import urllib.parse -from typing import Any, Dict, Iterable, Mapping, MutableMapping, Optional, Tuple, Union +from typing import ( + Any, + AnyStr, + Dict, + Iterable, + Mapping, + MutableMapping, + Optional, + Tuple, + Union, +) from unittest.mock import patch import attr @@ -53,9 +63,7 @@ class RestHelper: tok: Optional[str] = None, expect_code: int = 200, extra_content: Optional[Dict] = None, - custom_headers: Optional[ - Iterable[Tuple[Union[bytes, str], Union[bytes, str]]] - ] = None, + custom_headers: Optional[Iterable[Tuple[AnyStr, AnyStr]]] = None, ) -> str: """ Create a room. @@ -227,9 +235,7 @@ class RestHelper: txn_id=None, tok=None, expect_code=200, - custom_headers: Optional[ - Iterable[Tuple[Union[bytes, str], Union[bytes, str]]] - ] = None, + custom_headers: Optional[Iterable[Tuple[AnyStr, AnyStr]]] = None, ): if body is None: body = "body_text_here" @@ -418,7 +424,7 @@ class RestHelper: path, content=image_data, access_token=tok, - custom_headers=[(b"Content-Length", str(image_length))], + custom_headers=[("Content-Length", str(image_length))], ) assert channel.code == expect_code, "Expected: %d, got: %d, resp: %r" % ( |