diff --git a/changelog.d/239.misc b/changelog.d/239.misc new file mode 100644 index 00000000..35759845 --- /dev/null +++ b/changelog.d/239.misc @@ -0,0 +1 @@ +Fix type hint errors from new upstream Twisted release. diff --git a/sygnal/helper/proxy/connectproxyclient_twisted.py b/sygnal/helper/proxy/connectproxyclient_twisted.py index 1c24bc47..5a4b386b 100644 --- a/sygnal/helper/proxy/connectproxyclient_twisted.py +++ b/sygnal/helper/proxy/connectproxyclient_twisted.py @@ -109,13 +109,14 @@ def __init__( self.dst_port = dst_port self._proxy_auth = proxy_auth self.wrapped_factory = wrapped_factory - self.on_connection = defer.Deferred() + self.on_connection: defer.Deferred = defer.Deferred() def startedConnecting(self, connector): return self.wrapped_factory.startedConnecting(connector) def buildProtocol(self, addr): wrapped_protocol = self.wrapped_factory.buildProtocol(addr) + assert wrapped_protocol is not None return HTTPConnectProtocol( self.dst_host, @@ -220,7 +221,7 @@ def __init__(self, host: bytes, port: int, proxy_auth: Optional[Tuple[str, str]] self.host = host self.port = port self._proxy_auth = proxy_auth - self.on_connected = defer.Deferred() + self.on_connected: defer.Deferred = defer.Deferred() def connectionMade(self): logger.debug("Connected to proxy, sending CONNECT") diff --git a/sygnal/utils.py b/sygnal/utils.py index fb71e673..9d3db1dd 100644 --- a/sygnal/utils.py +++ b/sygnal/utils.py @@ -31,7 +31,7 @@ async def twisted_sleep(delay, twisted_reactor): Returns: a Deferred which fires in `delay` seconds. """ - deferred = Deferred() + deferred: Deferred[None] = Deferred() twisted_reactor.callLater(delay, deferred.callback, None) await deferred diff --git a/tests/test_pushgateway_api_v1.py b/tests/test_pushgateway_api_v1.py index 6b2be88a..7c81758a 100644 --- a/tests/test_pushgateway_api_v1.py +++ b/tests/test_pushgateway_api_v1.py @@ -192,7 +192,7 @@ def test_overlong_requests_are_rejected(self): # connect the site to a fake transport. transport = StringTransport() - protocol = self.site.buildProtocol(IPv6Address("TCP", "::1", "2345")) + protocol = self.site.buildProtocol(IPv6Address("TCP", "::1", 2345)) protocol.makeConnection(transport) protocol.dataReceived( @@ -209,7 +209,7 @@ def test_overlong_requests_are_rejected(self): # now send an oversized request transport = StringTransport() - protocol = self.site.buildProtocol(IPv6Address("TCP", "::1", "2345")) + protocol = self.site.buildProtocol(IPv6Address("TCP", "::1", 2345)) protocol.makeConnection(transport) protocol.dataReceived(