mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-10-01 08:25:44 -04:00
Fix a handful of type annotations. (#10446)
* switch from `types.CoroutineType` to `typing.Coroutine` these should be identical semantically, and since `defer.ensureDeferred` is defined to take a `typing.Coroutine`, will keep mypy happy * Fix some annotations on inlineCallbacks functions * changelog
This commit is contained in:
parent
d518b05a86
commit
d8324b8238
1
changelog.d/10446.misc
Normal file
1
changelog.d/10446.misc
Normal file
@ -0,0 +1 @@
|
||||
Update type annotations to work with forthcoming Twisted 21.7.0 release.
|
@ -27,7 +27,7 @@ from twisted.internet.interfaces import (
|
||||
)
|
||||
from twisted.web.client import URI, Agent, HTTPConnectionPool
|
||||
from twisted.web.http_headers import Headers
|
||||
from twisted.web.iweb import IAgent, IAgentEndpointFactory, IBodyProducer
|
||||
from twisted.web.iweb import IAgent, IAgentEndpointFactory, IBodyProducer, IResponse
|
||||
|
||||
from synapse.crypto.context_factory import FederationPolicyForHTTPS
|
||||
from synapse.http.client import BlacklistingAgentWrapper
|
||||
@ -116,7 +116,7 @@ class MatrixFederationAgent:
|
||||
uri: bytes,
|
||||
headers: Optional[Headers] = None,
|
||||
bodyProducer: Optional[IBodyProducer] = None,
|
||||
) -> Generator[defer.Deferred, Any, defer.Deferred]:
|
||||
) -> Generator[defer.Deferred, Any, IResponse]:
|
||||
"""
|
||||
Args:
|
||||
method: HTTP method: GET/POST/etc
|
||||
|
@ -25,7 +25,7 @@ See doc/log_contexts.rst for details on how this works.
|
||||
import inspect
|
||||
import logging
|
||||
import threading
|
||||
import types
|
||||
import typing
|
||||
import warnings
|
||||
from typing import TYPE_CHECKING, Optional, Tuple, TypeVar, Union
|
||||
|
||||
@ -745,7 +745,7 @@ def run_in_background(f, *args, **kwargs) -> defer.Deferred:
|
||||
# by synchronous exceptions, so let's turn them into Failures.
|
||||
return defer.fail()
|
||||
|
||||
if isinstance(res, types.CoroutineType):
|
||||
if isinstance(res, typing.Coroutine):
|
||||
res = defer.ensureDeferred(res)
|
||||
|
||||
# At this point we should have a Deferred, if not then f was a synchronous
|
||||
|
@ -484,7 +484,7 @@ class ModuleApi:
|
||||
@defer.inlineCallbacks
|
||||
def get_state_events_in_room(
|
||||
self, room_id: str, types: Iterable[Tuple[str, Optional[str]]]
|
||||
) -> Generator[defer.Deferred, Any, defer.Deferred]:
|
||||
) -> Generator[defer.Deferred, Any, Iterable[EventBase]]:
|
||||
"""Gets current state events for the given room.
|
||||
|
||||
(This is exposed for compatibility with the old SpamCheckerApi. We should
|
||||
|
Loading…
Reference in New Issue
Block a user