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

Commit 6203f7d

Browse files
committed
Correct type hints for computing auth events.
1 parent f0e02f5 commit 6203f7d

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

changelog.d/10253.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix type hints for computing auth events.

synapse/api/auth.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414
import logging
15-
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple
15+
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union
1616

1717
import pymacaroons
1818
from netaddr import IPAddress
@@ -31,6 +31,7 @@
3131
from synapse.api.room_versions import KNOWN_ROOM_VERSIONS
3232
from synapse.appservice import ApplicationService
3333
from synapse.events import EventBase
34+
from synapse.events.builder import EventBuilder
3435
from synapse.http import get_request_user_agent
3536
from synapse.http.site import SynapseRequest
3637
from synapse.logging import opentracing as opentracing
@@ -490,7 +491,7 @@ async def is_server_admin(self, user: UserID) -> bool:
490491

491492
def compute_auth_events(
492493
self,
493-
event,
494+
event: Union[EventBase, EventBuilder],
494495
current_state_ids: StateMap[str],
495496
for_verification: bool = False,
496497
) -> List[str]:

synapse/event_auth.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# limitations under the License.
1515

1616
import logging
17-
from typing import Any, Dict, List, Optional, Set, Tuple
17+
from typing import Any, Dict, List, Optional, Set, Tuple, Union
1818

1919
from canonicaljson import encode_canonical_json
2020
from signedjson.key import decode_verify_key_bytes
@@ -29,6 +29,7 @@
2929
RoomVersion,
3030
)
3131
from synapse.events import EventBase
32+
from synapse.events.builder import EventBuilder
3233
from synapse.types import StateMap, UserID, get_domain_from_id
3334

3435
logger = logging.getLogger(__name__)
@@ -724,7 +725,7 @@ def get_public_keys(invite_event: EventBase) -> List[Dict[str, Any]]:
724725
return public_keys
725726

726727

727-
def auth_types_for_event(event: EventBase) -> Set[Tuple[str, str]]:
728+
def auth_types_for_event(event: Union[EventBase, EventBuilder]) -> Set[Tuple[str, str]]:
728729
"""Given an event, return a list of (EventType, StateKey) that may be
729730
needed to auth the event. The returned list may be a superset of what
730731
would actually be required depending on the full state of the room.

0 commit comments

Comments
 (0)