Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Mypy linting with latest Twisted #239

Merged
merged 7 commits into from
Aug 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/239.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix type hint errors from new upstream Twisted release.
5 changes: 3 additions & 2 deletions sygnal/helper/proxy/connectproxyclient_twisted.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion sygnal/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions tests/test_pushgateway_api_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand Down