diff options
author | Patrick Cloke <clokep@users.noreply.github.com> | 2023-10-23 14:28:05 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-23 14:28:05 -0400 |
commit | 3ab861ab9eaf54a336a5a900eeb8402c3e9ed811 (patch) | |
tree | 18d47ad957c59644aa4ec6881f5eab55f675cf8a /synapse | |
parent | Fix bug where a new writer advances their token too quickly (#16473) (diff) | |
download | synapse-3ab861ab9eaf54a336a5a900eeb8402c3e9ed811.tar.xz |
Fix type hint errors from Twisted trunk (#16526)
Diffstat (limited to 'synapse')
-rw-r--r-- | synapse/util/file_consumer.py | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/synapse/util/file_consumer.py b/synapse/util/file_consumer.py index 46771a401b..26b46be5e1 100644 --- a/synapse/util/file_consumer.py +++ b/synapse/util/file_consumer.py @@ -13,7 +13,7 @@ # limitations under the License. import queue -from typing import BinaryIO, Optional, Union, cast +from typing import Any, BinaryIO, Optional, Union, cast from twisted.internet import threads from twisted.internet.defer import Deferred @@ -58,7 +58,9 @@ class BackgroundFileConsumer: self._bytes_queue: queue.Queue[Optional[bytes]] = queue.Queue() # Deferred that is resolved when finished writing - self._finished_deferred: Optional[Deferred[None]] = None + # + # This is really Deferred[None], but mypy doesn't seem to like that. + self._finished_deferred: Optional[Deferred[Any]] = None # If the _writer thread throws an exception it gets stored here. self._write_exception: Optional[Exception] = None @@ -80,9 +82,13 @@ class BackgroundFileConsumer: self.streaming = streaming self._finished_deferred = run_in_background( threads.deferToThreadPool, - self._reactor, - self._reactor.getThreadPool(), - self._writer, + # mypy seems to get confused with the chaining of ParamSpec from + # run_in_background to deferToThreadPool. + # + # For Twisted trunk, ignore arg-type; for Twisted release ignore unused-ignore. + self._reactor, # type: ignore[arg-type,unused-ignore] + self._reactor.getThreadPool(), # type: ignore[arg-type,unused-ignore] + self._writer, # type: ignore[arg-type,unused-ignore] ) if not streaming: self._producer.resumeProducing() |