Skip to content

Commit

Permalink
Fix up typing
Browse files Browse the repository at this point in the history
  • Loading branch information
erikjohnston committed Jan 8, 2024
1 parent 146ffee commit 056490e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion synapse/storage/databases/main/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ def get(
raise Exception("State map was filtered and doesn't include: %s", key)
return super().get(key, default)

def __contains__(self, key: object) -> bool:
def __contains__(self, key: Any) -> bool:
if key not in self.state_filter:
raise Exception("State map was filtered and doesn't include: %s", key)

Expand Down
8 changes: 7 additions & 1 deletion synapse/types/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import logging
from typing import (
TYPE_CHECKING,
Any,
Callable,
Collection,
Dict,
Expand Down Expand Up @@ -584,12 +585,17 @@ def must_await_full_state(self, is_mine_id: Callable[[str], bool]) -> bool:
# local users only
return False

def __contains__(self, key: Tuple[str, str]) -> bool:
def __contains__(self, key: Any) -> bool:
if not isinstance(key, tuple) or len(key) != 2:
return False

typ, state_key = key

if typ in self.types:
state_keys = self.types[typ]
if state_keys is None or state_key in state_keys:
return True

elif self.include_others:
return True

Expand Down

0 comments on commit 056490e

Please sign in to comment.