mirror of
https://github.com/element-hq/synapse.git
synced 2024-12-14 11:57:44 +00:00
Improve state types. (#16395)
This commit is contained in:
parent
c690fd16c4
commit
cdb89dcefe
3 changed files with 11 additions and 8 deletions
1
changelog.d/16395.misc
Normal file
1
changelog.d/16395.misc
Normal file
|
@ -0,0 +1 @@
|
|||
Improve type hints.
|
|
@ -23,7 +23,6 @@ from typing import (
|
|||
Generator,
|
||||
Iterable,
|
||||
List,
|
||||
Mapping,
|
||||
Optional,
|
||||
Sequence,
|
||||
Set,
|
||||
|
@ -269,7 +268,7 @@ async def _get_power_level_for_sender(
|
|||
|
||||
async def _get_auth_chain_difference(
|
||||
room_id: str,
|
||||
state_sets: Sequence[Mapping[Any, str]],
|
||||
state_sets: Sequence[StateMap[str]],
|
||||
unpersisted_events: Dict[str, EventBase],
|
||||
state_res_store: StateResolutionStore,
|
||||
) -> Set[str]:
|
||||
|
@ -405,7 +404,7 @@ def _seperate(
|
|||
|
||||
# mypy doesn't understand that discarding None above means that conflicted
|
||||
# state is StateMap[Set[str]], not StateMap[Set[Optional[Str]]].
|
||||
return unconflicted_state, conflicted_state # type: ignore
|
||||
return unconflicted_state, conflicted_state # type: ignore[return-value]
|
||||
|
||||
|
||||
def _is_power_event(event: EventBase) -> bool:
|
||||
|
|
|
@ -719,7 +719,10 @@ class AuthChainDifferenceTestCase(unittest.TestCase):
|
|||
persisted_events = {a.event_id: a, b.event_id: b}
|
||||
unpersited_events = {c.event_id: c}
|
||||
|
||||
state_sets = [{"a": a.event_id, "b": b.event_id}, {"c": c.event_id}]
|
||||
state_sets = [
|
||||
{("a", ""): a.event_id, ("b", ""): b.event_id},
|
||||
{("c", ""): c.event_id},
|
||||
]
|
||||
|
||||
store = TestStateResolutionStore(persisted_events)
|
||||
|
||||
|
@ -774,8 +777,8 @@ class AuthChainDifferenceTestCase(unittest.TestCase):
|
|||
unpersited_events = {c.event_id: c, d.event_id: d}
|
||||
|
||||
state_sets = [
|
||||
{"a": a.event_id, "b": b.event_id},
|
||||
{"c": c.event_id, "d": d.event_id},
|
||||
{("a", ""): a.event_id, ("b", ""): b.event_id},
|
||||
{("c", ""): c.event_id, ("d", ""): d.event_id},
|
||||
]
|
||||
|
||||
store = TestStateResolutionStore(persisted_events)
|
||||
|
@ -841,8 +844,8 @@ class AuthChainDifferenceTestCase(unittest.TestCase):
|
|||
unpersited_events = {c.event_id: c, d.event_id: d, e.event_id: e}
|
||||
|
||||
state_sets = [
|
||||
{"a": a.event_id, "b": b.event_id, "e": e.event_id},
|
||||
{"c": c.event_id, "d": d.event_id},
|
||||
{("a", ""): a.event_id, ("b", ""): b.event_id, ("e", ""): e.event_id},
|
||||
{("c", ""): c.event_id, ("d", ""): d.event_id},
|
||||
]
|
||||
|
||||
store = TestStateResolutionStore(persisted_events)
|
||||
|
|
Loading…
Reference in a new issue