Skip to content

Commit

Permalink
Quote Deferred annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
twm committed Apr 30, 2023
1 parent c09df9f commit 0a49042
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/treq/multipart.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def __init__(

self.length = self._calculateLength()

def startProducing(self, consumer: IConsumer) -> Deferred[None]:
def startProducing(self, consumer: IConsumer) -> "Deferred[None]":
"""
Start a cooperative task which will read bytes from the input file and
write them to `consumer`. Return a `Deferred` which fires after all
Expand All @@ -94,13 +94,13 @@ def startProducing(self, consumer: IConsumer) -> Deferred[None]:
self._task = self._cooperate(self._writeLoop(consumer)) # type: ignore
# whenDone returns the iterator that was passed to cooperate, so who
# cares what type it has? It's an edge signal; we ignore its value.
d: Deferred[Any] = self._task.whenDone()
d: "Deferred[Any]" = self._task.whenDone()

def maybeStopped(reason: Failure) -> Deferred:
def maybeStopped(reason: Failure) -> "Deferred[None]":
reason.trap(task.TaskStopped)
return Deferred()

d = cast(Deferred[None], d.addCallbacks(lambda ignored: None, maybeStopped))
d = cast("Deferred[None]", d.addCallbacks(lambda ignored: None, maybeStopped))
return d

def stopProducing(self) -> None:
Expand Down Expand Up @@ -215,7 +215,7 @@ def _writeFile(
content_type: str,
producer: IBodyProducer,
consumer: _Consumer,
) -> Optional[Deferred[None]]:
) -> "Optional[Deferred[None]]":
cdisp = _Header(b"Content-Disposition", b"form-data")
cdisp.add_param(b"name", name)
if filename:
Expand All @@ -240,7 +240,7 @@ def unset(val):
return val

d = producer.startProducing(consumer)
return cast(Deferred[None], d.addCallback(unset))
return cast("Deferred[None]", d.addCallback(unset))


def _escape(value: Union[str, bytes]) -> str:
Expand Down

0 comments on commit 0a49042

Please sign in to comment.