Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

More specific types. #16395

Merged
merged 2 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/16395.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Improve type hints.
5 changes: 2 additions & 3 deletions synapse/state/v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
Generator,
Iterable,
List,
Mapping,
Optional,
Sequence,
Set,
Expand Down Expand Up @@ -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]:
Expand Down Expand Up @@ -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:
Expand Down
13 changes: 8 additions & 5 deletions tests/state/test_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,10 @@ def test_simple(self) -> None:
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)

Expand Down Expand Up @@ -774,8 +777,8 @@ def test_multiple_unpersisted_chain(self) -> None:
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)
Expand Down Expand Up @@ -841,8 +844,8 @@ def test_unpersisted_events_different_sets(self) -> None:
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)
Expand Down
Loading