From 8740e9fbbae90436422148ccba374c74a82ae6d5 Mon Sep 17 00:00:00 2001 From: "H.Shay" Date: Tue, 3 Aug 2021 10:42:29 -0700 Subject: [PATCH 1/6] constrain twisted version and fix mypy errors --- setup.py | 2 +- sygnal/helper/proxy/connectproxyclient_twisted.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index c3eedd26..79208a4c 100755 --- a/setup.py +++ b/setup.py @@ -39,7 +39,7 @@ def read(fname: Union[str, "PathLike[str]"]) -> str: python_requires=">=3.7", setup_requires=["setuptools_scm"], install_requires=[ - "Twisted>=19.2.1", + "Twisted>=19.2.1,<21.7.0", "prometheus_client>=0.7.0,<0.8", "aioapns>=1.10", "cryptography>=2.1.4", 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") From 2dfacc46be550bb809d3e7d55d69c73e45e67fea Mon Sep 17 00:00:00 2001 From: "H.Shay" Date: Tue, 3 Aug 2021 10:48:16 -0700 Subject: [PATCH 2/6] Add changelog entry Signed-off-by: H.Shay --- changelog.d/237.misc | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/237.misc diff --git a/changelog.d/237.misc b/changelog.d/237.misc new file mode 100644 index 00000000..05f9f2f6 --- /dev/null +++ b/changelog.d/237.misc @@ -0,0 +1 @@ +Constrain Twisted verison in setup.py and fix type hint errors. \ No newline at end of file From f1a1055f6d9aacd282f97b0a09bc7f01c3b0c835 Mon Sep 17 00:00:00 2001 From: "H.Shay" Date: Tue, 3 Aug 2021 11:11:06 -0700 Subject: [PATCH 3/6] update changelog entry to proper PR number --- changelog.d/239.misc | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/239.misc diff --git a/changelog.d/239.misc b/changelog.d/239.misc new file mode 100644 index 00000000..05f9f2f6 --- /dev/null +++ b/changelog.d/239.misc @@ -0,0 +1 @@ +Constrain Twisted verison in setup.py and fix type hint errors. \ No newline at end of file From 4f95c7ee358c8028069de2b724cfb642c4f6fd67 Mon Sep 17 00:00:00 2001 From: reivilibre <38398653+reivilibre@users.noreply.github.com> Date: Wed, 4 Aug 2021 11:04:23 +0100 Subject: [PATCH 4/6] Update setup.py --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 79208a4c..c3eedd26 100755 --- a/setup.py +++ b/setup.py @@ -39,7 +39,7 @@ def read(fname: Union[str, "PathLike[str]"]) -> str: python_requires=">=3.7", setup_requires=["setuptools_scm"], install_requires=[ - "Twisted>=19.2.1,<21.7.0", + "Twisted>=19.2.1", "prometheus_client>=0.7.0,<0.8", "aioapns>=1.10", "cryptography>=2.1.4", From fdc479adfab2f5267014f32252e314247a0a5b85 Mon Sep 17 00:00:00 2001 From: Dan Callahan Date: Wed, 4 Aug 2021 14:39:33 +0100 Subject: [PATCH 5/6] Update changelog Signed-off-by: Dan Callahan --- changelog.d/237.misc | 1 - changelog.d/239.misc | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) delete mode 100644 changelog.d/237.misc diff --git a/changelog.d/237.misc b/changelog.d/237.misc deleted file mode 100644 index 05f9f2f6..00000000 --- a/changelog.d/237.misc +++ /dev/null @@ -1 +0,0 @@ -Constrain Twisted verison in setup.py and fix type hint errors. \ No newline at end of file diff --git a/changelog.d/239.misc b/changelog.d/239.misc index 05f9f2f6..35759845 100644 --- a/changelog.d/239.misc +++ b/changelog.d/239.misc @@ -1 +1 @@ -Constrain Twisted verison in setup.py and fix type hint errors. \ No newline at end of file +Fix type hint errors from new upstream Twisted release. From 1008ba1eedee4a94663e5c79a462126a198fbc46 Mon Sep 17 00:00:00 2001 From: Dan Callahan Date: Wed, 4 Aug 2021 15:25:23 +0100 Subject: [PATCH 6/6] Fix mypy lints Signed-off-by: Dan Callahan --- sygnal/utils.py | 2 +- tests/test_pushgateway_api_v1.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) 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(