-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Another batch of type annotations #12726
Changes from 8 commits
680fb0a
77f1be9
6fe983e
8b1a64d
23bbbff
c11b867
3c8ec37
9d62e76
ea27f05
71a58f3
1123bf9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -245,7 +245,7 @@ def http_proxy_endpoint( | |
proxy: Optional[bytes], | ||
reactor: IReactorCore, | ||
tls_options_factory: Optional[IPolicyForHTTPS], | ||
**kwargs, | ||
**kwargs: object, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. bit of a cop-out. |
||
) -> Tuple[Optional[IStreamClientEndpoint], Optional[ProxyCredentials]]: | ||
"""Parses an http proxy setting and returns an endpoint for the proxy | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,11 @@ | |
TCP4ClientEndpoint, | ||
TCP6ClientEndpoint, | ||
) | ||
from twisted.internet.interfaces import IPushProducer, IStreamClientEndpoint | ||
from twisted.internet.interfaces import ( | ||
IPushProducer, | ||
IReactorTCP, | ||
IStreamClientEndpoint, | ||
) | ||
from twisted.internet.protocol import Factory, Protocol | ||
from twisted.internet.tcp import Connection | ||
from twisted.python.failure import Failure | ||
|
@@ -59,14 +63,14 @@ class LogProducer: | |
_buffer: Deque[logging.LogRecord] | ||
_paused: bool = attr.ib(default=False, init=False) | ||
|
||
def pauseProducing(self): | ||
def pauseProducing(self) -> None: | ||
self._paused = True | ||
|
||
def stopProducing(self): | ||
def stopProducing(self) -> None: | ||
self._paused = True | ||
self._buffer = deque() | ||
|
||
def resumeProducing(self): | ||
def resumeProducing(self) -> None: | ||
# If we're already producing, nothing to do. | ||
self._paused = False | ||
|
||
|
@@ -102,8 +106,8 @@ def __init__( | |
host: str, | ||
port: int, | ||
maximum_buffer: int = 1000, | ||
level=logging.NOTSET, | ||
_reactor=None, | ||
level: int = logging.NOTSET, | ||
_reactor: Optional[IReactorTCP] = None, | ||
): | ||
super().__init__(level=level) | ||
self.host = host | ||
|
@@ -118,7 +122,7 @@ def __init__( | |
if _reactor is None: | ||
from twisted.internet import reactor | ||
|
||
_reactor = reactor | ||
_reactor = reactor # type: ignore[assignment] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No wonder mypy is confused. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In other spots we do: from twisted.internet import reactor as _reactor
reactor = cast(ISynapseReactor, _reactor) 🤷 (Could probably just put a |
||
|
||
try: | ||
ip = ip_address(self.host) | ||
|
@@ -139,7 +143,7 @@ def __init__( | |
self._stopping = False | ||
self._connect() | ||
|
||
def close(self): | ||
def close(self) -> None: | ||
self._stopping = True | ||
self._service.stopService() | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apparently I wrote this comment?