Bump mypy-zope & mypy. (#16188)

This commit is contained in:
Patrick Cloke 2023-08-29 10:38:56 -04:00 committed by GitHub
parent 001fc7bd19
commit 9ec3da06da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
39 changed files with 177 additions and 158 deletions

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

@ -0,0 +1 @@
Improve type hints.

66
poetry.lock generated
View File

@ -1445,43 +1445,43 @@ files = [
[[package]] [[package]]
name = "mypy" name = "mypy"
version = "1.0.1" version = "1.4.1"
description = "Optional static typing for Python" description = "Optional static typing for Python"
optional = false optional = false
python-versions = ">=3.7" python-versions = ">=3.7"
files = [ files = [
{file = "mypy-1.0.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:71a808334d3f41ef011faa5a5cd8153606df5fc0b56de5b2e89566c8093a0c9a"}, {file = "mypy-1.4.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:566e72b0cd6598503e48ea610e0052d1b8168e60a46e0bfd34b3acf2d57f96a8"},
{file = "mypy-1.0.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:920169f0184215eef19294fa86ea49ffd4635dedfdea2b57e45cb4ee85d5ccaf"}, {file = "mypy-1.4.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:ca637024ca67ab24a7fd6f65d280572c3794665eaf5edcc7e90a866544076878"},
{file = "mypy-1.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:27a0f74a298769d9fdc8498fcb4f2beb86f0564bcdb1a37b58cbbe78e55cf8c0"}, {file = "mypy-1.4.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0dde1d180cd84f0624c5dcaaa89c89775550a675aff96b5848de78fb11adabcd"},
{file = "mypy-1.0.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:65b122a993d9c81ea0bfde7689b3365318a88bde952e4dfa1b3a8b4ac05d168b"}, {file = "mypy-1.4.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:8c4d8e89aa7de683e2056a581ce63c46a0c41e31bd2b6d34144e2c80f5ea53dc"},
{file = "mypy-1.0.1-cp310-cp310-win_amd64.whl", hash = "sha256:5deb252fd42a77add936b463033a59b8e48eb2eaec2976d76b6878d031933fe4"}, {file = "mypy-1.4.1-cp310-cp310-win_amd64.whl", hash = "sha256:bfdca17c36ae01a21274a3c387a63aa1aafe72bff976522886869ef131b937f1"},
{file = "mypy-1.0.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:2013226d17f20468f34feddd6aae4635a55f79626549099354ce641bc7d40262"}, {file = "mypy-1.4.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:7549fbf655e5825d787bbc9ecf6028731973f78088fbca3a1f4145c39ef09462"},
{file = "mypy-1.0.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:48525aec92b47baed9b3380371ab8ab6e63a5aab317347dfe9e55e02aaad22e8"}, {file = "mypy-1.4.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:98324ec3ecf12296e6422939e54763faedbfcc502ea4a4c38502082711867258"},
{file = "mypy-1.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c96b8a0c019fe29040d520d9257d8c8f122a7343a8307bf8d6d4a43f5c5bfcc8"}, {file = "mypy-1.4.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:141dedfdbfe8a04142881ff30ce6e6653c9685b354876b12e4fe6c78598b45e2"},
{file = "mypy-1.0.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:448de661536d270ce04f2d7dddaa49b2fdba6e3bd8a83212164d4174ff43aa65"}, {file = "mypy-1.4.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:8207b7105829eca6f3d774f64a904190bb2231de91b8b186d21ffd98005f14a7"},
{file = "mypy-1.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:d42a98e76070a365a1d1c220fcac8aa4ada12ae0db679cb4d910fabefc88b994"}, {file = "mypy-1.4.1-cp311-cp311-win_amd64.whl", hash = "sha256:16f0db5b641ba159eff72cff08edc3875f2b62b2fa2bc24f68c1e7a4e8232d01"},
{file = "mypy-1.0.1-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:e64f48c6176e243ad015e995de05af7f22bbe370dbb5b32bd6988438ec873919"}, {file = "mypy-1.4.1-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:470c969bb3f9a9efcedbadcd19a74ffb34a25f8e6b0e02dae7c0e71f8372f97b"},
{file = "mypy-1.0.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5fdd63e4f50e3538617887e9aee91855368d9fc1dea30da743837b0df7373bc4"}, {file = "mypy-1.4.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e5952d2d18b79f7dc25e62e014fe5a23eb1a3d2bc66318df8988a01b1a037c5b"},
{file = "mypy-1.0.1-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:dbeb24514c4acbc78d205f85dd0e800f34062efcc1f4a4857c57e4b4b8712bff"}, {file = "mypy-1.4.1-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:190b6bab0302cec4e9e6767d3eb66085aef2a1cc98fe04936d8a42ed2ba77bb7"},
{file = "mypy-1.0.1-cp37-cp37m-win_amd64.whl", hash = "sha256:a2948c40a7dd46c1c33765718936669dc1f628f134013b02ff5ac6c7ef6942bf"}, {file = "mypy-1.4.1-cp37-cp37m-win_amd64.whl", hash = "sha256:9d40652cc4fe33871ad3338581dca3297ff5f2213d0df345bcfbde5162abf0c9"},
{file = "mypy-1.0.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:5bc8d6bd3b274dd3846597855d96d38d947aedba18776aa998a8d46fabdaed76"}, {file = "mypy-1.4.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:01fd2e9f85622d981fd9063bfaef1aed6e336eaacca00892cd2d82801ab7c042"},
{file = "mypy-1.0.1-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:17455cda53eeee0a4adb6371a21dd3dbf465897de82843751cf822605d152c8c"}, {file = "mypy-1.4.1-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:2460a58faeea905aeb1b9b36f5065f2dc9a9c6e4c992a6499a2360c6c74ceca3"},
{file = "mypy-1.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e831662208055b006eef68392a768ff83596035ffd6d846786578ba1714ba8f6"}, {file = "mypy-1.4.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a2746d69a8196698146a3dbe29104f9eb6a2a4d8a27878d92169a6c0b74435b6"},
{file = "mypy-1.0.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:e60d0b09f62ae97a94605c3f73fd952395286cf3e3b9e7b97f60b01ddfbbda88"}, {file = "mypy-1.4.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:ae704dcfaa180ff7c4cfbad23e74321a2b774f92ca77fd94ce1049175a21c97f"},
{file = "mypy-1.0.1-cp38-cp38-win_amd64.whl", hash = "sha256:0af4f0e20706aadf4e6f8f8dc5ab739089146b83fd53cb4a7e0e850ef3de0bb6"}, {file = "mypy-1.4.1-cp38-cp38-win_amd64.whl", hash = "sha256:43d24f6437925ce50139a310a64b2ab048cb2d3694c84c71c3f2a1626d8101dc"},
{file = "mypy-1.0.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:24189f23dc66f83b839bd1cce2dfc356020dfc9a8bae03978477b15be61b062e"}, {file = "mypy-1.4.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:c482e1246726616088532b5e964e39765b6d1520791348e6c9dc3af25b233828"},
{file = "mypy-1.0.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:93a85495fb13dc484251b4c1fd7a5ac370cd0d812bbfc3b39c1bafefe95275d5"}, {file = "mypy-1.4.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:43b592511672017f5b1a483527fd2684347fdffc041c9ef53428c8dc530f79a3"},
{file = "mypy-1.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5f546ac34093c6ce33f6278f7c88f0f147a4849386d3bf3ae193702f4fe31407"}, {file = "mypy-1.4.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:34a9239d5b3502c17f07fd7c0b2ae6b7dd7d7f6af35fbb5072c6208e76295816"},
{file = "mypy-1.0.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:c6c2ccb7af7154673c591189c3687b013122c5a891bb5651eca3db8e6c6c55bd"}, {file = "mypy-1.4.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:5703097c4936bbb9e9bce41478c8d08edd2865e177dc4c52be759f81ee4dd26c"},
{file = "mypy-1.0.1-cp39-cp39-win_amd64.whl", hash = "sha256:15b5a824b58c7c822c51bc66308e759243c32631896743f030daf449fe3677f3"}, {file = "mypy-1.4.1-cp39-cp39-win_amd64.whl", hash = "sha256:e02d700ec8d9b1859790c0475df4e4092c7bf3272a4fd2c9f33d87fac4427b8f"},
{file = "mypy-1.0.1-py3-none-any.whl", hash = "sha256:eda5c8b9949ed411ff752b9a01adda31afe7eae1e53e946dbdf9db23865e66c4"}, {file = "mypy-1.4.1-py3-none-any.whl", hash = "sha256:45d32cec14e7b97af848bddd97d85ea4f0db4d5a149ed9676caa4eb2f7402bb4"},
{file = "mypy-1.0.1.tar.gz", hash = "sha256:28cea5a6392bb43d266782983b5a4216c25544cd7d80be681a155ddcdafd152d"}, {file = "mypy-1.4.1.tar.gz", hash = "sha256:9bbcd9ab8ea1f2e1c8031c21445b511442cc45c89951e49bbf852cbb70755b1b"},
] ]
[package.dependencies] [package.dependencies]
mypy-extensions = ">=0.4.3" mypy-extensions = ">=1.0.0"
tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""} tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""}
typing-extensions = ">=3.10" typing-extensions = ">=4.1.0"
[package.extras] [package.extras]
dmypy = ["psutil (>=4.0)"] dmypy = ["psutil (>=4.0)"]
@ -1502,17 +1502,17 @@ files = [
[[package]] [[package]]
name = "mypy-zope" name = "mypy-zope"
version = "0.9.1" version = "1.0.0"
description = "Plugin for mypy to support zope interfaces" description = "Plugin for mypy to support zope interfaces"
optional = false optional = false
python-versions = "*" python-versions = "*"
files = [ files = [
{file = "mypy-zope-0.9.1.tar.gz", hash = "sha256:4c87dbc71fec35f6533746ecdf9d400cd9281338d71c16b5676bb5ed00a97ca2"}, {file = "mypy-zope-1.0.0.tar.gz", hash = "sha256:be815c2fcb5333aa87e8ec682029ad3214142fe2a05ea383f9ff2d77c98008b7"},
{file = "mypy_zope-0.9.1-py3-none-any.whl", hash = "sha256:733d4399affe9e61e332ce9c4049418d6775c39b473e4b9f409d51c207c1b71a"}, {file = "mypy_zope-1.0.0-py3-none-any.whl", hash = "sha256:9732e9b2198f2aec3343b38a51905ff49d44dc9e39e8e8bc6fc490b232388209"},
] ]
[package.dependencies] [package.dependencies]
mypy = ">=1.0.0,<1.1.0" mypy = ">=1.0.0,<1.5.0"
"zope.interface" = "*" "zope.interface" = "*"
"zope.schema" = "*" "zope.schema" = "*"

View File

@ -482,7 +482,10 @@ class Porter:
do_backward[0] = False do_backward[0] = False
if forward_rows or backward_rows: if forward_rows or backward_rows:
headers = [column[0] for column in txn.description] assert txn.description is not None
headers: Optional[List[str]] = [
column[0] for column in txn.description
]
else: else:
headers = None headers = None
@ -544,6 +547,7 @@ class Porter:
def r(txn: LoggingTransaction) -> Tuple[List[str], List[Tuple]]: def r(txn: LoggingTransaction) -> Tuple[List[str], List[Tuple]]:
txn.execute(select, (forward_chunk, self.batch_size)) txn.execute(select, (forward_chunk, self.batch_size))
rows = txn.fetchall() rows = txn.fetchall()
assert txn.description is not None
headers = [column[0] for column in txn.description] headers = [column[0] for column in txn.description]
return headers, rows return headers, rows
@ -919,7 +923,8 @@ class Porter:
def r(txn: LoggingTransaction) -> Tuple[List[str], List[Tuple]]: def r(txn: LoggingTransaction) -> Tuple[List[str], List[Tuple]]:
txn.execute(select) txn.execute(select)
rows = txn.fetchall() rows = txn.fetchall()
headers: List[str] = [column[0] for column in txn.description] assert txn.description is not None
headers = [column[0] for column in txn.description]
ts_ind = headers.index("ts") ts_ind = headers.index("ts")

View File

@ -910,10 +910,10 @@ def _custom_sync_async_decorator(
async def _wrapper( async def _wrapper(
*args: P.args, **kwargs: P.kwargs *args: P.args, **kwargs: P.kwargs
) -> Any: # Return type is RInner ) -> Any: # Return type is RInner
with wrapping_logic(func, *args, **kwargs): # type-ignore: func() returns R, but mypy doesn't know that R is
# type-ignore: func() returns R, but mypy doesn't know that R is # Awaitable here.
# Awaitable here. with wrapping_logic(func, *args, **kwargs): # type: ignore[arg-type]
return await func(*args, **kwargs) # type: ignore[misc] return await func(*args, **kwargs)
else: else:
# The other case here handles sync functions including those decorated with # The other case here handles sync functions including those decorated with
@ -980,8 +980,7 @@ def trace_with_opname(
See the module's doc string for usage examples. See the module's doc string for usage examples.
""" """
# type-ignore: mypy bug, see https://github.com/python/mypy/issues/12909 @contextlib.contextmanager
@contextlib.contextmanager # type: ignore[arg-type]
def _wrapping_logic( def _wrapping_logic(
func: Callable[P, R], *args: P.args, **kwargs: P.kwargs func: Callable[P, R], *args: P.args, **kwargs: P.kwargs
) -> Generator[None, None, None]: ) -> Generator[None, None, None]:
@ -1024,8 +1023,7 @@ def tag_args(func: Callable[P, R]) -> Callable[P, R]:
if not opentracing: if not opentracing:
return func return func
# type-ignore: mypy bug, see https://github.com/python/mypy/issues/12909 @contextlib.contextmanager
@contextlib.contextmanager # type: ignore[arg-type]
def _wrapping_logic( def _wrapping_logic(
func: Callable[P, R], *args: P.args, **kwargs: P.kwargs func: Callable[P, R], *args: P.args, **kwargs: P.kwargs
) -> Generator[None, None, None]: ) -> Generator[None, None, None]:

View File

@ -31,6 +31,7 @@ from typing import (
Iterator, Iterator,
List, List,
Optional, Optional,
Sequence,
Tuple, Tuple,
Type, Type,
TypeVar, TypeVar,
@ -358,7 +359,21 @@ class LoggingTransaction:
return self.txn.rowcount return self.txn.rowcount
@property @property
def description(self) -> Any: def description(
self,
) -> Optional[
Sequence[
Tuple[
str,
Optional[Any],
Optional[int],
Optional[int],
Optional[int],
Optional[int],
Optional[int],
]
]
]:
return self.txn.description return self.txn.description
def execute_batch(self, sql: str, args: Iterable[Iterable[Any]]) -> None: def execute_batch(self, sql: str, args: Iterable[Iterable[Any]]) -> None:

View File

@ -51,9 +51,9 @@ class DependencyException(Exception):
DEV_EXTRAS = {"lint", "mypy", "test", "dev"} DEV_EXTRAS = {"lint", "mypy", "test", "dev"}
RUNTIME_EXTRAS = ( ALL_EXTRAS = metadata.metadata(DISTRIBUTION_NAME).get_all("Provides-Extra")
set(metadata.metadata(DISTRIBUTION_NAME).get_all("Provides-Extra")) - DEV_EXTRAS assert ALL_EXTRAS is not None
) RUNTIME_EXTRAS = set(ALL_EXTRAS) - DEV_EXTRAS
VERSION = metadata.version(DISTRIBUTION_NAME) VERSION = metadata.version(DISTRIBUTION_NAME)

View File

@ -96,7 +96,7 @@ class ApplicationServiceApiTestCase(unittest.HomeserverTestCase):
) )
# We assign to a method, which mypy doesn't like. # We assign to a method, which mypy doesn't like.
self.api.get_json = Mock(side_effect=get_json) # type: ignore[assignment] self.api.get_json = Mock(side_effect=get_json) # type: ignore[method-assign]
result = self.get_success( result = self.get_success(
self.api.query_3pe(self.service, "user", PROTOCOL, {b"some": [b"field"]}) self.api.query_3pe(self.service, "user", PROTOCOL, {b"some": [b"field"]})
@ -168,7 +168,7 @@ class ApplicationServiceApiTestCase(unittest.HomeserverTestCase):
) )
# We assign to a method, which mypy doesn't like. # We assign to a method, which mypy doesn't like.
self.api.get_json = Mock(side_effect=get_json) # type: ignore[assignment] self.api.get_json = Mock(side_effect=get_json) # type: ignore[method-assign]
result = self.get_success( result = self.get_success(
self.api.query_3pe(self.service, "user", PROTOCOL, {b"some": [b"field"]}) self.api.query_3pe(self.service, "user", PROTOCOL, {b"some": [b"field"]})
@ -215,7 +215,7 @@ class ApplicationServiceApiTestCase(unittest.HomeserverTestCase):
return RESPONSE return RESPONSE
# We assign to a method, which mypy doesn't like. # We assign to a method, which mypy doesn't like.
self.api.post_json_get_json = Mock(side_effect=post_json_get_json) # type: ignore[assignment] self.api.post_json_get_json = Mock(side_effect=post_json_get_json) # type: ignore[method-assign]
MISSING_KEYS = [ MISSING_KEYS = [
# Known user, known device, missing algorithm. # Known user, known device, missing algorithm.

View File

@ -57,7 +57,7 @@ class RoomComplexityTests(unittest.FederatingHomeserverTestCase):
async def get_current_state_event_counts(room_id: str) -> int: async def get_current_state_event_counts(room_id: str) -> int:
return int(500 * 1.23) return int(500 * 1.23)
store.get_current_state_event_counts = get_current_state_event_counts # type: ignore[assignment] store.get_current_state_event_counts = get_current_state_event_counts # type: ignore[method-assign]
# Get the room complexity again -- make sure it's our artificial value # Get the room complexity again -- make sure it's our artificial value
channel = self.make_signed_federation_request( channel = self.make_signed_federation_request(
@ -74,8 +74,8 @@ class RoomComplexityTests(unittest.FederatingHomeserverTestCase):
fed_transport = self.hs.get_federation_transport_client() fed_transport = self.hs.get_federation_transport_client()
# Mock out some things, because we don't want to test the whole join # Mock out some things, because we don't want to test the whole join
fed_transport.client.get_json = AsyncMock(return_value={"v1": 9999}) # type: ignore[assignment] fed_transport.client.get_json = AsyncMock(return_value={"v1": 9999}) # type: ignore[method-assign]
handler.federation_handler.do_invite_join = AsyncMock( # type: ignore[assignment] handler.federation_handler.do_invite_join = AsyncMock( # type: ignore[method-assign]
return_value=("", 1) return_value=("", 1)
) )
@ -105,8 +105,8 @@ class RoomComplexityTests(unittest.FederatingHomeserverTestCase):
fed_transport = self.hs.get_federation_transport_client() fed_transport = self.hs.get_federation_transport_client()
# Mock out some things, because we don't want to test the whole join # Mock out some things, because we don't want to test the whole join
fed_transport.client.get_json = AsyncMock(return_value={"v1": 9999}) # type: ignore[assignment] fed_transport.client.get_json = AsyncMock(return_value={"v1": 9999}) # type: ignore[method-assign]
handler.federation_handler.do_invite_join = AsyncMock( # type: ignore[assignment] handler.federation_handler.do_invite_join = AsyncMock( # type: ignore[method-assign]
return_value=("", 1) return_value=("", 1)
) )
@ -142,8 +142,8 @@ class RoomComplexityTests(unittest.FederatingHomeserverTestCase):
fed_transport = self.hs.get_federation_transport_client() fed_transport = self.hs.get_federation_transport_client()
# Mock out some things, because we don't want to test the whole join # Mock out some things, because we don't want to test the whole join
fed_transport.client.get_json = AsyncMock(return_value=None) # type: ignore[assignment] fed_transport.client.get_json = AsyncMock(return_value=None) # type: ignore[method-assign]
handler.federation_handler.do_invite_join = AsyncMock( # type: ignore[assignment] handler.federation_handler.do_invite_join = AsyncMock( # type: ignore[method-assign]
return_value=("", 1) return_value=("", 1)
) )
@ -151,7 +151,7 @@ class RoomComplexityTests(unittest.FederatingHomeserverTestCase):
async def get_current_state_event_counts(room_id: str) -> int: async def get_current_state_event_counts(room_id: str) -> int:
return 600 return 600
self.hs.get_datastores().main.get_current_state_event_counts = get_current_state_event_counts # type: ignore[assignment] self.hs.get_datastores().main.get_current_state_event_counts = get_current_state_event_counts # type: ignore[method-assign]
d = handler._remote_join( d = handler._remote_join(
create_requester(u1), create_requester(u1),
@ -199,8 +199,8 @@ class RoomComplexityAdminTests(unittest.FederatingHomeserverTestCase):
fed_transport = self.hs.get_federation_transport_client() fed_transport = self.hs.get_federation_transport_client()
# Mock out some things, because we don't want to test the whole join # Mock out some things, because we don't want to test the whole join
fed_transport.client.get_json = AsyncMock(return_value={"v1": 9999}) # type: ignore[assignment] fed_transport.client.get_json = AsyncMock(return_value={"v1": 9999}) # type: ignore[method-assign]
handler.federation_handler.do_invite_join = AsyncMock( # type: ignore[assignment] handler.federation_handler.do_invite_join = AsyncMock( # type: ignore[method-assign]
return_value=("", 1) return_value=("", 1)
) )
@ -229,8 +229,8 @@ class RoomComplexityAdminTests(unittest.FederatingHomeserverTestCase):
fed_transport = self.hs.get_federation_transport_client() fed_transport = self.hs.get_federation_transport_client()
# Mock out some things, because we don't want to test the whole join # Mock out some things, because we don't want to test the whole join
fed_transport.client.get_json = AsyncMock(return_value={"v1": 9999}) # type: ignore[assignment] fed_transport.client.get_json = AsyncMock(return_value={"v1": 9999}) # type: ignore[method-assign]
handler.federation_handler.do_invite_join = AsyncMock( # type: ignore[assignment] handler.federation_handler.do_invite_join = AsyncMock( # type: ignore[method-assign]
return_value=("", 1) return_value=("", 1)
) )

View File

@ -50,7 +50,7 @@ class FederationCatchUpTestCases(FederatingHomeserverTestCase):
# This mock is crucial for destination_rooms to be populated. # This mock is crucial for destination_rooms to be populated.
# TODO: this seems to no longer be the case---tests pass with this mock # TODO: this seems to no longer be the case---tests pass with this mock
# commented out. # commented out.
state_storage_controller.get_current_hosts_in_room = AsyncMock( # type: ignore[assignment] state_storage_controller.get_current_hosts_in_room = AsyncMock( # type: ignore[method-assign]
return_value={"test", "host2"} return_value={"test", "host2"}
) )
@ -436,7 +436,7 @@ class FederationCatchUpTestCases(FederatingHomeserverTestCase):
def wake_destination_track(destination: str) -> None: def wake_destination_track(destination: str) -> None:
woken.add(destination) woken.add(destination)
self.federation_sender.wake_destination = wake_destination_track # type: ignore[assignment] self.federation_sender.wake_destination = wake_destination_track # type: ignore[method-assign]
# We wait quite long so that all dests can be woken up, since there is a delay # We wait quite long so that all dests can be woken up, since there is a delay
# between them. # between them.

View File

@ -47,11 +47,11 @@ class FederationSenderReceiptsTestCases(HomeserverTestCase):
federation_transport_client=self.federation_transport_client, federation_transport_client=self.federation_transport_client,
) )
hs.get_storage_controllers().state.get_current_hosts_in_room = AsyncMock( # type: ignore[assignment] hs.get_storage_controllers().state.get_current_hosts_in_room = AsyncMock( # type: ignore[method-assign]
return_value={"test", "host2"} return_value={"test", "host2"}
) )
hs.get_storage_controllers().state.get_current_hosts_in_room_or_partial_state_approximation = ( # type: ignore[assignment] hs.get_storage_controllers().state.get_current_hosts_in_room_or_partial_state_approximation = ( # type: ignore[method-assign]
hs.get_storage_controllers().state.get_current_hosts_in_room hs.get_storage_controllers().state.get_current_hosts_in_room
) )

View File

@ -218,7 +218,7 @@ class FederationKnockingTestCase(
) -> EventBase: ) -> EventBase:
return pdu return pdu
homeserver.get_federation_server()._check_sigs_and_hash = ( # type: ignore[assignment] homeserver.get_federation_server()._check_sigs_and_hash = ( # type: ignore[method-assign]
approve_all_signature_checking approve_all_signature_checking
) )
@ -229,7 +229,7 @@ class FederationKnockingTestCase(
) -> None: ) -> None:
pass pass
homeserver.get_federation_event_handler()._check_event_auth = _check_event_auth # type: ignore[assignment] homeserver.get_federation_event_handler()._check_event_auth = _check_event_auth # type: ignore[method-assign]
return super().prepare(reactor, clock, homeserver) return super().prepare(reactor, clock, homeserver)

View File

@ -400,11 +400,11 @@ class ApplicationServicesHandlerSendEventsTestCase(unittest.HomeserverTestCase):
# Mock the ApplicationServiceScheduler's _TransactionController's send method so that # Mock the ApplicationServiceScheduler's _TransactionController's send method so that
# we can track any outgoing ephemeral events # we can track any outgoing ephemeral events
self.send_mock = AsyncMock() self.send_mock = AsyncMock()
hs.get_application_service_handler().scheduler.txn_ctrl.send = self.send_mock # type: ignore[assignment] hs.get_application_service_handler().scheduler.txn_ctrl.send = self.send_mock # type: ignore[method-assign]
# Mock out application services, and allow defining our own in tests # Mock out application services, and allow defining our own in tests
self._services: List[ApplicationService] = [] self._services: List[ApplicationService] = []
self.hs.get_datastores().main.get_app_services = Mock( # type: ignore[assignment] self.hs.get_datastores().main.get_app_services = Mock( # type: ignore[method-assign]
return_value=self._services return_value=self._services
) )
@ -898,11 +898,11 @@ class ApplicationServicesHandlerDeviceListsTestCase(unittest.HomeserverTestCase)
# Mock ApplicationServiceApi's put_json, so we can verify the raw JSON that # Mock ApplicationServiceApi's put_json, so we can verify the raw JSON that
# will be sent over the wire # will be sent over the wire
self.put_json = AsyncMock() self.put_json = AsyncMock()
hs.get_application_service_api().put_json = self.put_json # type: ignore[assignment] hs.get_application_service_api().put_json = self.put_json # type: ignore[method-assign]
# Mock out application services, and allow defining our own in tests # Mock out application services, and allow defining our own in tests
self._services: List[ApplicationService] = [] self._services: List[ApplicationService] = []
self.hs.get_datastores().main.get_app_services = Mock( # type: ignore[assignment] self.hs.get_datastores().main.get_app_services = Mock( # type: ignore[method-assign]
return_value=self._services return_value=self._services
) )
@ -1004,7 +1004,7 @@ class ApplicationServicesHandlerOtkCountsTestCase(unittest.HomeserverTestCase):
# Mock the ApplicationServiceScheduler's _TransactionController's send method so that # Mock the ApplicationServiceScheduler's _TransactionController's send method so that
# we can track what's going out # we can track what's going out
self.send_mock = AsyncMock() self.send_mock = AsyncMock()
hs.get_application_service_handler().scheduler.txn_ctrl.send = self.send_mock # type: ignore[assignment] # We assign to a method. hs.get_application_service_handler().scheduler.txn_ctrl.send = self.send_mock # type: ignore[method-assign] # We assign to a method.
# Define an application service for the tests # Define an application service for the tests
self._service_token = "VERYSECRET" self._service_token = "VERYSECRET"

View File

@ -60,7 +60,7 @@ class CasHandlerTestCase(HomeserverTestCase):
# stub out the auth handler # stub out the auth handler
auth_handler = self.hs.get_auth_handler() auth_handler = self.hs.get_auth_handler()
auth_handler.complete_sso_login = AsyncMock() # type: ignore[assignment] auth_handler.complete_sso_login = AsyncMock() # type: ignore[method-assign]
cas_response = CasResponse("test_user", {}) cas_response = CasResponse("test_user", {})
request = _mock_request() request = _mock_request()
@ -88,7 +88,7 @@ class CasHandlerTestCase(HomeserverTestCase):
# stub out the auth handler # stub out the auth handler
auth_handler = self.hs.get_auth_handler() auth_handler = self.hs.get_auth_handler()
auth_handler.complete_sso_login = AsyncMock() # type: ignore[assignment] auth_handler.complete_sso_login = AsyncMock() # type: ignore[method-assign]
# Map a user via SSO. # Map a user via SSO.
cas_response = CasResponse("test_user", {}) cas_response = CasResponse("test_user", {})
@ -128,7 +128,7 @@ class CasHandlerTestCase(HomeserverTestCase):
# stub out the auth handler # stub out the auth handler
auth_handler = self.hs.get_auth_handler() auth_handler = self.hs.get_auth_handler()
auth_handler.complete_sso_login = AsyncMock() # type: ignore[assignment] auth_handler.complete_sso_login = AsyncMock() # type: ignore[method-assign]
cas_response = CasResponse("föö", {}) cas_response = CasResponse("föö", {})
request = _mock_request() request = _mock_request()
@ -159,7 +159,7 @@ class CasHandlerTestCase(HomeserverTestCase):
# stub out the auth handler # stub out the auth handler
auth_handler = self.hs.get_auth_handler() auth_handler = self.hs.get_auth_handler()
auth_handler.complete_sso_login = AsyncMock() # type: ignore[assignment] auth_handler.complete_sso_login = AsyncMock() # type: ignore[method-assign]
# The response doesn't have the proper userGroup or department. # The response doesn't have the proper userGroup or department.
cas_response = CasResponse("test_user", {}) cas_response = CasResponse("test_user", {})

View File

@ -800,7 +800,7 @@ class E2eKeysHandlerTestCase(unittest.HomeserverTestCase):
remote_master_key = "85T7JXPFBAySB/jwby4S3lBPTqY3+Zg53nYuGmu1ggY" remote_master_key = "85T7JXPFBAySB/jwby4S3lBPTqY3+Zg53nYuGmu1ggY"
remote_self_signing_key = "QeIiFEjluPBtI7WQdG365QKZcFs9kqmHir6RBD0//nQ" remote_self_signing_key = "QeIiFEjluPBtI7WQdG365QKZcFs9kqmHir6RBD0//nQ"
self.hs.get_federation_client().query_client_keys = mock.AsyncMock( # type: ignore[assignment] self.hs.get_federation_client().query_client_keys = mock.AsyncMock( # type: ignore[method-assign]
return_value={ return_value={
"device_keys": {remote_user_id: {}}, "device_keys": {remote_user_id: {}},
"master_keys": { "master_keys": {
@ -876,7 +876,7 @@ class E2eKeysHandlerTestCase(unittest.HomeserverTestCase):
remote_master_key = "85T7JXPFBAySB/jwby4S3lBPTqY3+Zg53nYuGmu1ggY" remote_master_key = "85T7JXPFBAySB/jwby4S3lBPTqY3+Zg53nYuGmu1ggY"
remote_self_signing_key = "QeIiFEjluPBtI7WQdG365QKZcFs9kqmHir6RBD0//nQ" remote_self_signing_key = "QeIiFEjluPBtI7WQdG365QKZcFs9kqmHir6RBD0//nQ"
self.hs.get_federation_client().query_user_devices = mock.AsyncMock( # type: ignore[assignment] self.hs.get_federation_client().query_user_devices = mock.AsyncMock( # type: ignore[method-assign]
return_value={ return_value={
"user_id": remote_user_id, "user_id": remote_user_id,
"stream_id": 1, "stream_id": 1,

View File

@ -371,14 +371,14 @@ class FederationTestCase(unittest.FederatingHomeserverTestCase):
# We mock out the FederationClient.backfill method, to pretend that a remote # We mock out the FederationClient.backfill method, to pretend that a remote
# server has returned our fake event. # server has returned our fake event.
federation_client_backfill_mock = AsyncMock(return_value=[event]) federation_client_backfill_mock = AsyncMock(return_value=[event])
self.hs.get_federation_client().backfill = federation_client_backfill_mock # type: ignore[assignment] self.hs.get_federation_client().backfill = federation_client_backfill_mock # type: ignore[method-assign]
# We also mock the persist method with a side effect of itself. This allows us # We also mock the persist method with a side effect of itself. This allows us
# to track when it has been called while preserving its function. # to track when it has been called while preserving its function.
persist_events_and_notify_mock = Mock( persist_events_and_notify_mock = Mock(
side_effect=self.hs.get_federation_event_handler().persist_events_and_notify side_effect=self.hs.get_federation_event_handler().persist_events_and_notify
) )
self.hs.get_federation_event_handler().persist_events_and_notify = ( # type: ignore[assignment] self.hs.get_federation_event_handler().persist_events_and_notify = ( # type: ignore[method-assign]
persist_events_and_notify_mock persist_events_and_notify_mock
) )

View File

@ -157,7 +157,7 @@ class OidcHandlerTestCase(HomeserverTestCase):
sso_handler = hs.get_sso_handler() sso_handler = hs.get_sso_handler()
# Mock the render error method. # Mock the render error method.
self.render_error = Mock(return_value=None) self.render_error = Mock(return_value=None)
sso_handler.render_error = self.render_error # type: ignore[assignment] sso_handler.render_error = self.render_error # type: ignore[method-assign]
# Reduce the number of attempts when generating MXIDs. # Reduce the number of attempts when generating MXIDs.
sso_handler._MAP_USERNAME_RETRIES = 3 sso_handler._MAP_USERNAME_RETRIES = 3
@ -165,7 +165,7 @@ class OidcHandlerTestCase(HomeserverTestCase):
auth_handler = hs.get_auth_handler() auth_handler = hs.get_auth_handler()
# Mock the complete SSO login method. # Mock the complete SSO login method.
self.complete_sso_login = AsyncMock() self.complete_sso_login = AsyncMock()
auth_handler.complete_sso_login = self.complete_sso_login # type: ignore[assignment] auth_handler.complete_sso_login = self.complete_sso_login # type: ignore[method-assign]
return hs return hs

View File

@ -830,7 +830,7 @@ class PasswordAuthProviderTests(unittest.HomeserverTestCase):
username: The username to use for the test. username: The username to use for the test.
registration: Whether to test with registration URLs. registration: Whether to test with registration URLs.
""" """
self.hs.get_identity_handler().send_threepid_validation = AsyncMock( # type: ignore[assignment] self.hs.get_identity_handler().send_threepid_validation = AsyncMock( # type: ignore[method-assign]
return_value=0 return_value=0
) )

View File

@ -202,7 +202,7 @@ class RegistrationTestCase(unittest.HomeserverTestCase):
@override_config({"limit_usage_by_mau": True}) @override_config({"limit_usage_by_mau": True})
def test_get_or_create_user_mau_not_blocked(self) -> None: def test_get_or_create_user_mau_not_blocked(self) -> None:
self.store.count_monthly_users = AsyncMock( # type: ignore[assignment] self.store.count_monthly_users = AsyncMock( # type: ignore[method-assign]
return_value=self.hs.config.server.max_mau_value - 1 return_value=self.hs.config.server.max_mau_value - 1
) )
# Ensure does not throw exception # Ensure does not throw exception
@ -299,7 +299,7 @@ class RegistrationTestCase(unittest.HomeserverTestCase):
def test_auto_create_auto_join_rooms_when_user_is_the_first_real_user(self) -> None: def test_auto_create_auto_join_rooms_when_user_is_the_first_real_user(self) -> None:
room_alias_str = "#room:test" room_alias_str = "#room:test"
self.store.count_real_users = AsyncMock(return_value=1) # type: ignore[assignment] self.store.count_real_users = AsyncMock(return_value=1) # type: ignore[method-assign]
self.store.is_real_user = AsyncMock(return_value=True) self.store.is_real_user = AsyncMock(return_value=True)
user_id = self.get_success(self.handler.register_user(localpart="real")) user_id = self.get_success(self.handler.register_user(localpart="real"))
rooms = self.get_success(self.store.get_rooms_for_user(user_id)) rooms = self.get_success(self.store.get_rooms_for_user(user_id))
@ -314,7 +314,7 @@ class RegistrationTestCase(unittest.HomeserverTestCase):
def test_auto_create_auto_join_rooms_when_user_is_not_the_first_real_user( def test_auto_create_auto_join_rooms_when_user_is_not_the_first_real_user(
self, self,
) -> None: ) -> None:
self.store.count_real_users = AsyncMock(return_value=2) # type: ignore[assignment] self.store.count_real_users = AsyncMock(return_value=2) # type: ignore[method-assign]
self.store.is_real_user = AsyncMock(return_value=True) self.store.is_real_user = AsyncMock(return_value=True)
user_id = self.get_success(self.handler.register_user(localpart="real")) user_id = self.get_success(self.handler.register_user(localpart="real"))
rooms = self.get_success(self.store.get_rooms_for_user(user_id)) rooms = self.get_success(self.store.get_rooms_for_user(user_id))

View File

@ -133,7 +133,7 @@ class SamlHandlerTestCase(HomeserverTestCase):
# stub out the auth handler # stub out the auth handler
auth_handler = self.hs.get_auth_handler() auth_handler = self.hs.get_auth_handler()
auth_handler.complete_sso_login = AsyncMock() # type: ignore[assignment] auth_handler.complete_sso_login = AsyncMock() # type: ignore[method-assign]
# send a mocked-up SAML response to the callback # send a mocked-up SAML response to the callback
saml_response = FakeAuthnResponse({"uid": "test_user", "username": "test_user"}) saml_response = FakeAuthnResponse({"uid": "test_user", "username": "test_user"})
@ -163,7 +163,7 @@ class SamlHandlerTestCase(HomeserverTestCase):
# stub out the auth handler # stub out the auth handler
auth_handler = self.hs.get_auth_handler() auth_handler = self.hs.get_auth_handler()
auth_handler.complete_sso_login = AsyncMock() # type: ignore[assignment] auth_handler.complete_sso_login = AsyncMock() # type: ignore[method-assign]
# Map a user via SSO. # Map a user via SSO.
saml_response = FakeAuthnResponse( saml_response = FakeAuthnResponse(
@ -205,11 +205,11 @@ class SamlHandlerTestCase(HomeserverTestCase):
# stub out the auth handler # stub out the auth handler
auth_handler = self.hs.get_auth_handler() auth_handler = self.hs.get_auth_handler()
auth_handler.complete_sso_login = AsyncMock() # type: ignore[assignment] auth_handler.complete_sso_login = AsyncMock() # type: ignore[method-assign]
# mock out the error renderer too # mock out the error renderer too
sso_handler = self.hs.get_sso_handler() sso_handler = self.hs.get_sso_handler()
sso_handler.render_error = Mock(return_value=None) # type: ignore[assignment] sso_handler.render_error = Mock(return_value=None) # type: ignore[method-assign]
saml_response = FakeAuthnResponse({"uid": "test", "username": "föö"}) saml_response = FakeAuthnResponse({"uid": "test", "username": "föö"})
request = _mock_request() request = _mock_request()
@ -226,9 +226,9 @@ class SamlHandlerTestCase(HomeserverTestCase):
# stub out the auth handler and error renderer # stub out the auth handler and error renderer
auth_handler = self.hs.get_auth_handler() auth_handler = self.hs.get_auth_handler()
auth_handler.complete_sso_login = AsyncMock() # type: ignore[assignment] auth_handler.complete_sso_login = AsyncMock() # type: ignore[method-assign]
sso_handler = self.hs.get_sso_handler() sso_handler = self.hs.get_sso_handler()
sso_handler.render_error = Mock(return_value=None) # type: ignore[assignment] sso_handler.render_error = Mock(return_value=None) # type: ignore[method-assign]
# register a user to occupy the first-choice MXID # register a user to occupy the first-choice MXID
store = self.hs.get_datastores().main store = self.hs.get_datastores().main
@ -311,7 +311,7 @@ class SamlHandlerTestCase(HomeserverTestCase):
# stub out the auth handler # stub out the auth handler
auth_handler = self.hs.get_auth_handler() auth_handler = self.hs.get_auth_handler()
auth_handler.complete_sso_login = AsyncMock() # type: ignore[assignment] auth_handler.complete_sso_login = AsyncMock() # type: ignore[method-assign]
# The response doesn't have the proper userGroup or department. # The response doesn't have the proper userGroup or department.
saml_response = FakeAuthnResponse({"uid": "test_user", "username": "test_user"}) saml_response = FakeAuthnResponse({"uid": "test_user", "username": "test_user"})

View File

@ -122,15 +122,15 @@ class TypingNotificationsTestCase(unittest.HomeserverTestCase):
self.datastore.get_destination_retry_timings = AsyncMock(return_value=None) self.datastore.get_destination_retry_timings = AsyncMock(return_value=None)
self.datastore.get_device_updates_by_remote = AsyncMock( # type: ignore[assignment] self.datastore.get_device_updates_by_remote = AsyncMock( # type: ignore[method-assign]
return_value=(0, []) return_value=(0, [])
) )
self.datastore.get_destination_last_successful_stream_ordering = AsyncMock( # type: ignore[assignment] self.datastore.get_destination_last_successful_stream_ordering = AsyncMock( # type: ignore[method-assign]
return_value=None return_value=None
) )
self.datastore.get_received_txn_response = AsyncMock( # type: ignore[assignment] self.datastore.get_received_txn_response = AsyncMock( # type: ignore[method-assign]
return_value=None return_value=None
) )
@ -143,25 +143,25 @@ class TypingNotificationsTestCase(unittest.HomeserverTestCase):
raise AuthError(401, "User is not in the room") raise AuthError(401, "User is not in the room")
return None return None
hs.get_auth().check_user_in_room = Mock( # type: ignore[assignment] hs.get_auth().check_user_in_room = Mock( # type: ignore[method-assign]
side_effect=check_user_in_room side_effect=check_user_in_room
) )
async def check_host_in_room(room_id: str, server_name: str) -> bool: async def check_host_in_room(room_id: str, server_name: str) -> bool:
return room_id == ROOM_ID return room_id == ROOM_ID
hs.get_event_auth_handler().is_host_in_room = Mock( # type: ignore[assignment] hs.get_event_auth_handler().is_host_in_room = Mock( # type: ignore[method-assign]
side_effect=check_host_in_room side_effect=check_host_in_room
) )
async def get_current_hosts_in_room(room_id: str) -> Set[str]: async def get_current_hosts_in_room(room_id: str) -> Set[str]:
return {member.domain for member in self.room_members} return {member.domain for member in self.room_members}
hs.get_storage_controllers().state.get_current_hosts_in_room = Mock( # type: ignore[assignment] hs.get_storage_controllers().state.get_current_hosts_in_room = Mock( # type: ignore[method-assign]
side_effect=get_current_hosts_in_room side_effect=get_current_hosts_in_room
) )
hs.get_storage_controllers().state.get_current_hosts_in_room_or_partial_state_approximation = Mock( # type: ignore[assignment] hs.get_storage_controllers().state.get_current_hosts_in_room_or_partial_state_approximation = Mock( # type: ignore[method-assign]
side_effect=get_current_hosts_in_room side_effect=get_current_hosts_in_room
) )
@ -170,24 +170,24 @@ class TypingNotificationsTestCase(unittest.HomeserverTestCase):
self.datastore.get_users_in_room = Mock(side_effect=get_users_in_room) self.datastore.get_users_in_room = Mock(side_effect=get_users_in_room)
self.datastore.get_user_directory_stream_pos = AsyncMock( # type: ignore[assignment] self.datastore.get_user_directory_stream_pos = AsyncMock( # type: ignore[method-assign]
# we deliberately return a non-None stream pos to avoid # we deliberately return a non-None stream pos to avoid
# doing an initial_sync # doing an initial_sync
return_value=1 return_value=1
) )
self.datastore.get_partial_current_state_deltas = Mock(return_value=(0, None)) # type: ignore[assignment] self.datastore.get_partial_current_state_deltas = Mock(return_value=(0, None)) # type: ignore[method-assign]
self.datastore.get_to_device_stream_token = Mock( # type: ignore[assignment] self.datastore.get_to_device_stream_token = Mock( # type: ignore[method-assign]
return_value=0 return_value=0
) )
self.datastore.get_new_device_msgs_for_remote = AsyncMock( # type: ignore[assignment] self.datastore.get_new_device_msgs_for_remote = AsyncMock( # type: ignore[method-assign]
return_value=([], 0) return_value=([], 0)
) )
self.datastore.delete_device_msgs_for_remote = AsyncMock( # type: ignore[assignment] self.datastore.delete_device_msgs_for_remote = AsyncMock( # type: ignore[method-assign]
return_value=None return_value=None
) )
self.datastore.set_received_txn_response = AsyncMock( # type: ignore[assignment] self.datastore.set_received_txn_response = AsyncMock( # type: ignore[method-assign]
return_value=None return_value=None
) )

View File

@ -164,7 +164,7 @@ class TerseJsonTestCase(LoggerCleanupMixin, TestCase):
# Call requestReceived to finish instantiating the object. # Call requestReceived to finish instantiating the object.
request.content = BytesIO() request.content = BytesIO()
# Partially skip some internal processing of SynapseRequest. # Partially skip some internal processing of SynapseRequest.
request._started_processing = Mock() # type: ignore[assignment] request._started_processing = Mock() # type: ignore[method-assign]
request.request_metrics = Mock(spec=["name"]) request.request_metrics = Mock(spec=["name"])
with patch.object(Request, "render"): with patch.object(Request, "render"):
request.requestReceived(b"POST", b"/_matrix/client/versions", b"1.1") request.requestReceived(b"POST", b"/_matrix/client/versions", b"1.1")

View File

@ -233,7 +233,7 @@ class ModuleApiTestCase(BaseModuleApiTestCase):
def test_sending_events_into_room(self) -> None: def test_sending_events_into_room(self) -> None:
"""Tests that a module can send events into a room""" """Tests that a module can send events into a room"""
# Mock out create_and_send_nonmember_event to check whether events are being sent # Mock out create_and_send_nonmember_event to check whether events are being sent
self.event_creation_handler.create_and_send_nonmember_event = Mock( # type: ignore[assignment] self.event_creation_handler.create_and_send_nonmember_event = Mock( # type: ignore[method-assign]
spec=[], spec=[],
side_effect=self.event_creation_handler.create_and_send_nonmember_event, side_effect=self.event_creation_handler.create_and_send_nonmember_event,
) )
@ -579,7 +579,7 @@ class ModuleApiTestCase(BaseModuleApiTestCase):
# Necessary to fake a remote join. # Necessary to fake a remote join.
fake_stream_id = 1 fake_stream_id = 1
mocked_remote_join = AsyncMock(return_value=("fake-event-id", fake_stream_id)) mocked_remote_join = AsyncMock(return_value=("fake-event-id", fake_stream_id))
self.hs.get_room_member_handler()._remote_join = mocked_remote_join # type: ignore[assignment] self.hs.get_room_member_handler()._remote_join = mocked_remote_join # type: ignore[method-assign]
fake_remote_host = f"{self.module_api.server_name}-remote" fake_remote_host = f"{self.module_api.server_name}-remote"
# Given that the join is to be faked, we expect the relevant join event not to # Given that the join is to be faked, we expect the relevant join event not to

View File

@ -190,7 +190,7 @@ class TestBulkPushRuleEvaluator(HomeserverTestCase):
# Mock the method which calculates push rules -- we do this instead of # Mock the method which calculates push rules -- we do this instead of
# e.g. checking the results in the database because we want to ensure # e.g. checking the results in the database because we want to ensure
# that code isn't even running. # that code isn't even running.
bulk_evaluator._action_for_event_by_user = AsyncMock() # type: ignore[assignment] bulk_evaluator._action_for_event_by_user = AsyncMock() # type: ignore[method-assign]
# Ensure no actions are generated! # Ensure no actions are generated!
self.get_success(bulk_evaluator.action_for_events_by_user([(event, context)])) self.get_success(bulk_evaluator.action_for_events_by_user([(event, context)]))

View File

@ -58,7 +58,7 @@ def patch__eq__(cls: object) -> Callable[[], None]:
def unpatch() -> None: def unpatch() -> None:
if eq is not None: if eq is not None:
cls.__eq__ = eq # type: ignore[assignment] cls.__eq__ = eq # type: ignore[method-assign]
return unpatch return unpatch

View File

@ -71,8 +71,8 @@ class UserRegisterTestCase(unittest.HomeserverTestCase):
self.hs.config.registration.registration_shared_secret = "shared" self.hs.config.registration.registration_shared_secret = "shared"
self.hs.get_media_repository = Mock() # type: ignore[assignment] self.hs.get_media_repository = Mock() # type: ignore[method-assign]
self.hs.get_deactivate_account_handler = Mock() # type: ignore[assignment] self.hs.get_deactivate_account_handler = Mock() # type: ignore[method-assign]
return self.hs return self.hs

View File

@ -50,7 +50,7 @@ class UsernameAvailableTestCase(unittest.HomeserverTestCase):
) )
handler = self.hs.get_registration_handler() handler = self.hs.get_registration_handler()
handler.check_username = check_username # type: ignore[assignment] handler.check_username = check_username # type: ignore[method-assign]
def test_username_available(self) -> None: def test_username_available(self) -> None:
""" """

View File

@ -1346,7 +1346,7 @@ class AccountStatusTestCase(unittest.HomeserverTestCase):
return {} return {}
# Register a mock that will return the expected result depending on the remote. # Register a mock that will return the expected result depending on the remote.
self.hs.get_federation_http_client().post_json = Mock(side_effect=post_json) # type: ignore[assignment] self.hs.get_federation_http_client().post_json = Mock(side_effect=post_json) # type: ignore[method-assign]
# Check that we've got the correct response from the client-side endpoint. # Check that we've got the correct response from the client-side endpoint.
self._test_status( self._test_status(

View File

@ -45,7 +45,7 @@ class EventStreamPermissionsTestCase(unittest.HomeserverTestCase):
hs = self.setup_test_homeserver(config=config) hs = self.setup_test_homeserver(config=config)
hs.get_federation_handler = Mock() # type: ignore[assignment] hs.get_federation_handler = Mock() # type: ignore[method-assign]
return hs return hs

View File

@ -65,14 +65,14 @@ class FilterTestCase(unittest.HomeserverTestCase):
def test_add_filter_non_local_user(self) -> None: def test_add_filter_non_local_user(self) -> None:
_is_mine = self.hs.is_mine _is_mine = self.hs.is_mine
self.hs.is_mine = lambda target_user: False # type: ignore[assignment] self.hs.is_mine = lambda target_user: False # type: ignore[method-assign]
channel = self.make_request( channel = self.make_request(
"POST", "POST",
"/_matrix/client/r0/user/%s/filter" % (self.user_id), "/_matrix/client/r0/user/%s/filter" % (self.user_id),
self.EXAMPLE_FILTER_JSON, self.EXAMPLE_FILTER_JSON,
) )
self.hs.is_mine = _is_mine # type: ignore[assignment] self.hs.is_mine = _is_mine # type: ignore[method-assign]
self.assertEqual(channel.code, 403) self.assertEqual(channel.code, 403)
self.assertEqual(channel.json_body["errcode"], Codes.FORBIDDEN) self.assertEqual(channel.json_body["errcode"], Codes.FORBIDDEN)

View File

@ -68,7 +68,7 @@ class RoomBase(unittest.HomeserverTestCase):
"red", "red",
) )
self.hs.get_federation_handler = Mock() # type: ignore[assignment] self.hs.get_federation_handler = Mock() # type: ignore[method-assign]
self.hs.get_federation_handler.return_value.maybe_backfill = AsyncMock( self.hs.get_federation_handler.return_value.maybe_backfill = AsyncMock(
return_value=None return_value=None
) )
@ -76,7 +76,7 @@ class RoomBase(unittest.HomeserverTestCase):
async def _insert_client_ip(*args: Any, **kwargs: Any) -> None: async def _insert_client_ip(*args: Any, **kwargs: Any) -> None:
return None return None
self.hs.get_datastores().main.insert_client_ip = _insert_client_ip # type: ignore[assignment] self.hs.get_datastores().main.insert_client_ip = _insert_client_ip # type: ignore[method-assign]
return self.hs return self.hs
@ -3413,8 +3413,8 @@ class ThreepidInviteTestCase(unittest.HomeserverTestCase):
# a remote IS. We keep the mock for make_and_store_3pid_invite around so we # a remote IS. We keep the mock for make_and_store_3pid_invite around so we
# can check its call_count later on during the test. # can check its call_count later on during the test.
make_invite_mock = AsyncMock(return_value=(Mock(event_id="abc"), 0)) make_invite_mock = AsyncMock(return_value=(Mock(event_id="abc"), 0))
self.hs.get_room_member_handler()._make_and_store_3pid_invite = make_invite_mock # type: ignore[assignment] self.hs.get_room_member_handler()._make_and_store_3pid_invite = make_invite_mock # type: ignore[method-assign]
self.hs.get_identity_handler().lookup_3pid = AsyncMock( # type: ignore[assignment] self.hs.get_identity_handler().lookup_3pid = AsyncMock( # type: ignore[method-assign]
return_value=None, return_value=None,
) )
@ -3477,8 +3477,8 @@ class ThreepidInviteTestCase(unittest.HomeserverTestCase):
# a remote IS. We keep the mock for make_and_store_3pid_invite around so we # a remote IS. We keep the mock for make_and_store_3pid_invite around so we
# can check its call_count later on during the test. # can check its call_count later on during the test.
make_invite_mock = AsyncMock(return_value=(Mock(event_id="abc"), 0)) make_invite_mock = AsyncMock(return_value=(Mock(event_id="abc"), 0))
self.hs.get_room_member_handler()._make_and_store_3pid_invite = make_invite_mock # type: ignore[assignment] self.hs.get_room_member_handler()._make_and_store_3pid_invite = make_invite_mock # type: ignore[method-assign]
self.hs.get_identity_handler().lookup_3pid = AsyncMock( # type: ignore[assignment] self.hs.get_identity_handler().lookup_3pid = AsyncMock( # type: ignore[method-assign]
return_value=None, return_value=None,
) )

View File

@ -84,7 +84,7 @@ class RoomTestCase(_ShadowBannedBase):
def test_invite_3pid(self) -> None: def test_invite_3pid(self) -> None:
"""Ensure that a 3PID invite does not attempt to contact the identity server.""" """Ensure that a 3PID invite does not attempt to contact the identity server."""
identity_handler = self.hs.get_identity_handler() identity_handler = self.hs.get_identity_handler()
identity_handler.lookup_3pid = Mock( # type: ignore[assignment] identity_handler.lookup_3pid = Mock( # type: ignore[method-assign]
side_effect=AssertionError("This should not get called") side_effect=AssertionError("This should not get called")
) )

View File

@ -117,7 +117,7 @@ class ThirdPartyRulesTestCase(unittest.FederatingHomeserverTestCase):
async def _check_event_auth(origin: Any, event: Any, context: Any) -> None: async def _check_event_auth(origin: Any, event: Any, context: Any) -> None:
pass pass
hs.get_federation_event_handler()._check_event_auth = _check_event_auth # type: ignore[assignment] hs.get_federation_event_handler()._check_event_auth = _check_event_auth # type: ignore[method-assign]
return hs return hs

View File

@ -722,7 +722,7 @@ def _make_test_homeserver_synchronous(server: HomeServer) -> None:
**kwargs, **kwargs,
) )
pool.runWithConnection = runWithConnection # type: ignore[assignment] pool.runWithConnection = runWithConnection # type: ignore[method-assign]
pool.runInteraction = runInteraction # type: ignore[assignment] pool.runInteraction = runInteraction # type: ignore[assignment]
# Replace the thread pool with a threadless 'thread' pool # Replace the thread pool with a threadless 'thread' pool
pool.threadpool = ThreadPool(clock._reactor) pool.threadpool = ThreadPool(clock._reactor)

View File

@ -69,7 +69,7 @@ class TestResourceLimitsServerNotices(unittest.HomeserverTestCase):
self._rlsn = rlsn self._rlsn = rlsn
self._rlsn._store.user_last_seen_monthly_active = AsyncMock(return_value=1000) self._rlsn._store.user_last_seen_monthly_active = AsyncMock(return_value=1000)
self._rlsn._server_notices_manager.send_notice = AsyncMock( # type: ignore[assignment] self._rlsn._server_notices_manager.send_notice = AsyncMock( # type: ignore[method-assign]
return_value=Mock() return_value=Mock()
) )
self._send_notice = self._rlsn._server_notices_manager.send_notice self._send_notice = self._rlsn._server_notices_manager.send_notice
@ -82,8 +82,8 @@ class TestResourceLimitsServerNotices(unittest.HomeserverTestCase):
self._rlsn._server_notices_manager.maybe_get_notice_room_for_user = AsyncMock( self._rlsn._server_notices_manager.maybe_get_notice_room_for_user = AsyncMock(
return_value="!something:localhost" return_value="!something:localhost"
) )
self._rlsn._store.add_tag_to_room = AsyncMock(return_value=None) # type: ignore[assignment] self._rlsn._store.add_tag_to_room = AsyncMock(return_value=None) # type: ignore[method-assign]
self._rlsn._store.get_tags_for_room = AsyncMock(return_value={}) # type: ignore[assignment] self._rlsn._store.get_tags_for_room = AsyncMock(return_value={}) # type: ignore[method-assign]
@override_config({"hs_disabled": True}) @override_config({"hs_disabled": True})
def test_maybe_send_server_notice_disabled_hs(self) -> None: def test_maybe_send_server_notice_disabled_hs(self) -> None:
@ -100,13 +100,13 @@ class TestResourceLimitsServerNotices(unittest.HomeserverTestCase):
def test_maybe_send_server_notice_to_user_remove_blocked_notice(self) -> None: def test_maybe_send_server_notice_to_user_remove_blocked_notice(self) -> None:
"""Test when user has blocked notice, but should have it removed""" """Test when user has blocked notice, but should have it removed"""
self._rlsn._auth_blocking.check_auth_blocking = AsyncMock( # type: ignore[assignment] self._rlsn._auth_blocking.check_auth_blocking = AsyncMock( # type: ignore[method-assign]
return_value=None return_value=None
) )
mock_event = Mock( mock_event = Mock(
type=EventTypes.Message, content={"msgtype": ServerNoticeMsgType} type=EventTypes.Message, content={"msgtype": ServerNoticeMsgType}
) )
self._rlsn._store.get_events = AsyncMock( # type: ignore[assignment] self._rlsn._store.get_events = AsyncMock( # type: ignore[method-assign]
return_value={"123": mock_event} return_value={"123": mock_event}
) )
self.get_success(self._rlsn.maybe_send_server_notice_to_user(self.user_id)) self.get_success(self._rlsn.maybe_send_server_notice_to_user(self.user_id))
@ -122,7 +122,7 @@ class TestResourceLimitsServerNotices(unittest.HomeserverTestCase):
""" """
Test when user has blocked notice, but notice ought to be there (NOOP) Test when user has blocked notice, but notice ought to be there (NOOP)
""" """
self._rlsn._auth_blocking.check_auth_blocking = AsyncMock( # type: ignore[assignment] self._rlsn._auth_blocking.check_auth_blocking = AsyncMock( # type: ignore[method-assign]
return_value=None, return_value=None,
side_effect=ResourceLimitError(403, "foo"), side_effect=ResourceLimitError(403, "foo"),
) )
@ -130,7 +130,7 @@ class TestResourceLimitsServerNotices(unittest.HomeserverTestCase):
mock_event = Mock( mock_event = Mock(
type=EventTypes.Message, content={"msgtype": ServerNoticeMsgType} type=EventTypes.Message, content={"msgtype": ServerNoticeMsgType}
) )
self._rlsn._store.get_events = AsyncMock( # type: ignore[assignment] self._rlsn._store.get_events = AsyncMock( # type: ignore[method-assign]
return_value={"123": mock_event} return_value={"123": mock_event}
) )
@ -142,7 +142,7 @@ class TestResourceLimitsServerNotices(unittest.HomeserverTestCase):
""" """
Test when user does not have blocked notice, but should have one Test when user does not have blocked notice, but should have one
""" """
self._rlsn._auth_blocking.check_auth_blocking = AsyncMock( # type: ignore[assignment] self._rlsn._auth_blocking.check_auth_blocking = AsyncMock( # type: ignore[method-assign]
return_value=None, return_value=None,
side_effect=ResourceLimitError(403, "foo"), side_effect=ResourceLimitError(403, "foo"),
) )
@ -155,7 +155,7 @@ class TestResourceLimitsServerNotices(unittest.HomeserverTestCase):
""" """
Test when user does not have blocked notice, nor should they (NOOP) Test when user does not have blocked notice, nor should they (NOOP)
""" """
self._rlsn._auth_blocking.check_auth_blocking = AsyncMock( # type: ignore[assignment] self._rlsn._auth_blocking.check_auth_blocking = AsyncMock( # type: ignore[method-assign]
return_value=None return_value=None
) )
@ -168,7 +168,7 @@ class TestResourceLimitsServerNotices(unittest.HomeserverTestCase):
Test when user is not part of the MAU cohort - this should not ever Test when user is not part of the MAU cohort - this should not ever
happen - but ... happen - but ...
""" """
self._rlsn._auth_blocking.check_auth_blocking = AsyncMock( # type: ignore[assignment] self._rlsn._auth_blocking.check_auth_blocking = AsyncMock( # type: ignore[method-assign]
return_value=None return_value=None
) )
self._rlsn._store.user_last_seen_monthly_active = AsyncMock(return_value=None) self._rlsn._store.user_last_seen_monthly_active = AsyncMock(return_value=None)
@ -184,7 +184,7 @@ class TestResourceLimitsServerNotices(unittest.HomeserverTestCase):
Test that when server is over MAU limit and alerting is suppressed, then Test that when server is over MAU limit and alerting is suppressed, then
an alert message is not sent into the room an alert message is not sent into the room
""" """
self._rlsn._auth_blocking.check_auth_blocking = AsyncMock( # type: ignore[assignment] self._rlsn._auth_blocking.check_auth_blocking = AsyncMock( # type: ignore[method-assign]
return_value=None, return_value=None,
side_effect=ResourceLimitError( side_effect=ResourceLimitError(
403, "foo", limit_type=LimitBlockingTypes.MONTHLY_ACTIVE_USER 403, "foo", limit_type=LimitBlockingTypes.MONTHLY_ACTIVE_USER
@ -199,7 +199,7 @@ class TestResourceLimitsServerNotices(unittest.HomeserverTestCase):
""" """
Test that when a server is disabled, that MAU limit alerting is ignored. Test that when a server is disabled, that MAU limit alerting is ignored.
""" """
self._rlsn._auth_blocking.check_auth_blocking = AsyncMock( # type: ignore[assignment] self._rlsn._auth_blocking.check_auth_blocking = AsyncMock( # type: ignore[method-assign]
return_value=None, return_value=None,
side_effect=ResourceLimitError( side_effect=ResourceLimitError(
403, "foo", limit_type=LimitBlockingTypes.HS_DISABLED 403, "foo", limit_type=LimitBlockingTypes.HS_DISABLED
@ -218,21 +218,21 @@ class TestResourceLimitsServerNotices(unittest.HomeserverTestCase):
When the room is already in a blocked state, test that when alerting When the room is already in a blocked state, test that when alerting
is suppressed that the room is returned to an unblocked state. is suppressed that the room is returned to an unblocked state.
""" """
self._rlsn._auth_blocking.check_auth_blocking = AsyncMock( # type: ignore[assignment] self._rlsn._auth_blocking.check_auth_blocking = AsyncMock( # type: ignore[method-assign]
return_value=None, return_value=None,
side_effect=ResourceLimitError( side_effect=ResourceLimitError(
403, "foo", limit_type=LimitBlockingTypes.MONTHLY_ACTIVE_USER 403, "foo", limit_type=LimitBlockingTypes.MONTHLY_ACTIVE_USER
), ),
) )
self._rlsn._is_room_currently_blocked = AsyncMock( # type: ignore[assignment] self._rlsn._is_room_currently_blocked = AsyncMock( # type: ignore[method-assign]
return_value=(True, []) return_value=(True, [])
) )
mock_event = Mock( mock_event = Mock(
type=EventTypes.Message, content={"msgtype": ServerNoticeMsgType} type=EventTypes.Message, content={"msgtype": ServerNoticeMsgType}
) )
self._rlsn._store.get_events = AsyncMock( # type: ignore[assignment] self._rlsn._store.get_events = AsyncMock( # type: ignore[method-assign]
return_value={"123": mock_event} return_value={"123": mock_event}
) )
self.get_success(self._rlsn.maybe_send_server_notice_to_user(self.user_id)) self.get_success(self._rlsn.maybe_send_server_notice_to_user(self.user_id))

View File

@ -338,7 +338,7 @@ class ApplicationServiceTransactionStoreTestCase(unittest.HomeserverTestCase):
# we aren't testing store._base stuff here, so mock this out # we aren't testing store._base stuff here, so mock this out
# (ignore needed because Mypy won't allow us to assign to a method otherwise) # (ignore needed because Mypy won't allow us to assign to a method otherwise)
self.store.get_events_as_list = AsyncMock(return_value=events) # type: ignore[assignment] self.store.get_events_as_list = AsyncMock(return_value=events) # type: ignore[method-assign]
self.get_success(self._insert_txn(self.as_list[1]["id"], 9, other_events)) self.get_success(self._insert_txn(self.as_list[1]["id"], 9, other_events))
self.get_success(self._insert_txn(service.id, 10, events)) self.get_success(self._insert_txn(service.id, 10, events))

View File

@ -252,7 +252,7 @@ class MonthlyActiveUsersTestCase(unittest.HomeserverTestCase):
) )
self.get_success(d) self.get_success(d)
self.store.upsert_monthly_active_user = AsyncMock(return_value=None) # type: ignore[assignment] self.store.upsert_monthly_active_user = AsyncMock(return_value=None) # type: ignore[method-assign]
d = self.store.populate_monthly_active_users(user_id) d = self.store.populate_monthly_active_users(user_id)
self.get_success(d) self.get_success(d)
@ -260,9 +260,9 @@ class MonthlyActiveUsersTestCase(unittest.HomeserverTestCase):
self.store.upsert_monthly_active_user.assert_not_called() self.store.upsert_monthly_active_user.assert_not_called()
def test_populate_monthly_users_should_update(self) -> None: def test_populate_monthly_users_should_update(self) -> None:
self.store.upsert_monthly_active_user = AsyncMock(return_value=None) # type: ignore[assignment] self.store.upsert_monthly_active_user = AsyncMock(return_value=None) # type: ignore[method-assign]
self.store.is_trial_user = AsyncMock(return_value=False) # type: ignore[assignment] self.store.is_trial_user = AsyncMock(return_value=False) # type: ignore[method-assign]
self.store.user_last_seen_monthly_active = AsyncMock(return_value=None) self.store.user_last_seen_monthly_active = AsyncMock(return_value=None)
d = self.store.populate_monthly_active_users("user_id") d = self.store.populate_monthly_active_users("user_id")
@ -271,9 +271,9 @@ class MonthlyActiveUsersTestCase(unittest.HomeserverTestCase):
self.store.upsert_monthly_active_user.assert_called_once() self.store.upsert_monthly_active_user.assert_called_once()
def test_populate_monthly_users_should_not_update(self) -> None: def test_populate_monthly_users_should_not_update(self) -> None:
self.store.upsert_monthly_active_user = AsyncMock(return_value=None) # type: ignore[assignment] self.store.upsert_monthly_active_user = AsyncMock(return_value=None) # type: ignore[method-assign]
self.store.is_trial_user = AsyncMock(return_value=False) # type: ignore[assignment] self.store.is_trial_user = AsyncMock(return_value=False) # type: ignore[method-assign]
self.store.user_last_seen_monthly_active = AsyncMock( self.store.user_last_seen_monthly_active = AsyncMock(
return_value=self.hs.get_clock().time_msec() return_value=self.hs.get_clock().time_msec()
) )
@ -356,7 +356,7 @@ class MonthlyActiveUsersTestCase(unittest.HomeserverTestCase):
@override_config({"limit_usage_by_mau": False, "mau_stats_only": False}) @override_config({"limit_usage_by_mau": False, "mau_stats_only": False})
def test_no_users_when_not_tracking(self) -> None: def test_no_users_when_not_tracking(self) -> None:
self.store.upsert_monthly_active_user = AsyncMock(return_value=None) # type: ignore[assignment] self.store.upsert_monthly_active_user = AsyncMock(return_value=None) # type: ignore[method-assign]
self.get_success(self.store.populate_monthly_active_users("@user:sever")) self.get_success(self.store.populate_monthly_active_users("@user:sever"))

View File

@ -80,7 +80,7 @@ class MessageAcceptTests(unittest.HomeserverTestCase):
) -> None: ) -> None:
pass pass
federation_event_handler._check_event_auth = _check_event_auth # type: ignore[assignment] federation_event_handler._check_event_auth = _check_event_auth # type: ignore[method-assign]
self.client = self.hs.get_federation_client() self.client = self.hs.get_federation_client()
async def _check_sigs_and_hash_for_pulled_events_and_fetch( async def _check_sigs_and_hash_for_pulled_events_and_fetch(
@ -190,7 +190,7 @@ class MessageAcceptTests(unittest.HomeserverTestCase):
# Register the mock on the federation client. # Register the mock on the federation client.
federation_client = self.hs.get_federation_client() federation_client = self.hs.get_federation_client()
federation_client.query_user_devices = Mock(side_effect=query_user_devices) # type: ignore[assignment] federation_client.query_user_devices = Mock(side_effect=query_user_devices) # type: ignore[method-assign]
# Register a mock on the store so that the incoming update doesn't fail because # Register a mock on the store so that the incoming update doesn't fail because
# we don't share a room with the user. # we don't share a room with the user.
@ -240,7 +240,7 @@ class MessageAcceptTests(unittest.HomeserverTestCase):
# Register mock device list retrieval on the federation client. # Register mock device list retrieval on the federation client.
federation_client = self.hs.get_federation_client() federation_client = self.hs.get_federation_client()
federation_client.query_user_devices = AsyncMock( # type: ignore[assignment] federation_client.query_user_devices = AsyncMock( # type: ignore[method-assign]
return_value={ return_value={
"user_id": remote_user_id, "user_id": remote_user_id,
"stream_id": 1, "stream_id": 1,

View File

@ -714,7 +714,7 @@ class StateTestCase(unittest.TestCase):
store = _DummyStore() store = _DummyStore()
store.register_events(old_state_1) store.register_events(old_state_1)
store.register_events(old_state_2) store.register_events(old_state_2)
self.dummy_store.get_events = store.get_events # type: ignore[assignment] self.dummy_store.get_events = store.get_events # type: ignore[method-assign]
context: EventContext context: EventContext
context = yield self._get_context( context = yield self._get_context(
@ -773,7 +773,7 @@ class StateTestCase(unittest.TestCase):
store = _DummyStore() store = _DummyStore()
store.register_events(old_state_1) store.register_events(old_state_1)
store.register_events(old_state_2) store.register_events(old_state_2)
self.dummy_store.get_events = store.get_events # type: ignore[assignment] self.dummy_store.get_events = store.get_events # type: ignore[method-assign]
context: EventContext context: EventContext
context = yield self._get_context( context = yield self._get_context(

View File

@ -395,9 +395,9 @@ class HomeserverTestCase(TestCase):
) )
# Type ignore: mypy doesn't like us assigning to methods. # Type ignore: mypy doesn't like us assigning to methods.
self.hs.get_auth().get_user_by_req = get_requester # type: ignore[assignment] self.hs.get_auth().get_user_by_req = get_requester # type: ignore[method-assign]
self.hs.get_auth().get_user_by_access_token = get_requester # type: ignore[assignment] self.hs.get_auth().get_user_by_access_token = get_requester # type: ignore[method-assign]
self.hs.get_auth().get_access_token_from_request = Mock(return_value=token) # type: ignore[assignment] self.hs.get_auth().get_access_token_from_request = Mock(return_value=token) # type: ignore[method-assign]
if self.needs_threadpool: if self.needs_threadpool:
self.reactor.threadpool = ThreadPool() # type: ignore[assignment] self.reactor.threadpool = ThreadPool() # type: ignore[assignment]