mirror of
https://github.com/element-hq/synapse.git
synced 2026-09-26 20:19:57 +00:00
Use type hinting generics in standard collections (#19046)
aka PEP 585, added in Python 3.9 - https://peps.python.org/pep-0585/ - https://docs.astral.sh/ruff/rules/non-pep585-annotation/
This commit is contained in:
@@ -19,7 +19,7 @@
|
||||
#
|
||||
#
|
||||
|
||||
from typing import Any, Dict, List, Optional, Tuple, cast
|
||||
from typing import Any, Optional, cast
|
||||
from unittest.mock import AsyncMock
|
||||
|
||||
from parameterized import parameterized
|
||||
@@ -104,7 +104,7 @@ class ClientIpStoreTestCase(unittest.HomeserverTestCase):
|
||||
self.pump(0)
|
||||
|
||||
result = cast(
|
||||
List[Tuple[str, str, str, Optional[str], int]],
|
||||
list[tuple[str, str, str, Optional[str], int]],
|
||||
self.get_success(
|
||||
self.store.db_pool.simple_select_list(
|
||||
table="user_ips",
|
||||
@@ -135,7 +135,7 @@ class ClientIpStoreTestCase(unittest.HomeserverTestCase):
|
||||
self.pump(0)
|
||||
|
||||
result = cast(
|
||||
List[Tuple[str, str, str, Optional[str], int]],
|
||||
list[tuple[str, str, str, Optional[str], int]],
|
||||
self.get_success(
|
||||
self.store.db_pool.simple_select_list(
|
||||
table="user_ips",
|
||||
@@ -184,7 +184,7 @@ class ClientIpStoreTestCase(unittest.HomeserverTestCase):
|
||||
else:
|
||||
# Check that the new IP and user agent has not been stored yet
|
||||
db_result = cast(
|
||||
List[Tuple[str, Optional[str], Optional[str], str, Optional[int]]],
|
||||
list[tuple[str, Optional[str], Optional[str], str, Optional[int]]],
|
||||
self.get_success(
|
||||
self.store.db_pool.simple_select_list(
|
||||
table="devices",
|
||||
@@ -266,7 +266,7 @@ class ClientIpStoreTestCase(unittest.HomeserverTestCase):
|
||||
|
||||
# Check that the new IP and user agent has not been stored yet
|
||||
db_result = cast(
|
||||
List[Tuple[str, Optional[str], Optional[str], str, Optional[int]]],
|
||||
list[tuple[str, Optional[str], Optional[str], str, Optional[int]]],
|
||||
self.get_success(
|
||||
self.store.db_pool.simple_select_list(
|
||||
table="devices",
|
||||
@@ -381,7 +381,7 @@ class ClientIpStoreTestCase(unittest.HomeserverTestCase):
|
||||
|
||||
# Check that the new IP and user agent has not been stored yet
|
||||
db_result = cast(
|
||||
List[Tuple[str, str, str, int]],
|
||||
list[tuple[str, str, str, int]],
|
||||
self.get_success(
|
||||
self.store.db_pool.simple_select_list(
|
||||
table="user_ips",
|
||||
@@ -589,7 +589,7 @@ class ClientIpStoreTestCase(unittest.HomeserverTestCase):
|
||||
|
||||
# We should see that in the DB
|
||||
result = cast(
|
||||
List[Tuple[str, str, str, Optional[str], int]],
|
||||
list[tuple[str, str, str, Optional[str], int]],
|
||||
self.get_success(
|
||||
self.store.db_pool.simple_select_list(
|
||||
table="user_ips",
|
||||
@@ -616,7 +616,7 @@ class ClientIpStoreTestCase(unittest.HomeserverTestCase):
|
||||
|
||||
# We should get no results.
|
||||
result = cast(
|
||||
List[Tuple[str, str, str, Optional[str], int]],
|
||||
list[tuple[str, str, str, Optional[str], int]],
|
||||
self.get_success(
|
||||
self.store.db_pool.simple_select_list(
|
||||
table="user_ips",
|
||||
@@ -695,7 +695,7 @@ class ClientIpStoreTestCase(unittest.HomeserverTestCase):
|
||||
|
||||
# We should see that in the DB
|
||||
result = cast(
|
||||
List[Tuple[str, str, str, Optional[str], int]],
|
||||
list[tuple[str, str, str, Optional[str], int]],
|
||||
self.get_success(
|
||||
self.store.db_pool.simple_select_list(
|
||||
table="user_ips",
|
||||
@@ -745,9 +745,9 @@ class ClientIpAuthTestCase(unittest.HomeserverTestCase):
|
||||
|
||||
def _runtest(
|
||||
self,
|
||||
headers: Dict[bytes, bytes],
|
||||
headers: dict[bytes, bytes],
|
||||
expected_ip: str,
|
||||
make_request_args: Dict[str, Any],
|
||||
make_request_args: dict[str, Any],
|
||||
) -> None:
|
||||
device_id = "bleb"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user