Skip to content

Commit 8345ecd

Browse files
author
Loren Arthur
committed
Update type annotations.
1 parent 18f1bda commit 8345ecd

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

tornado/gen.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -699,13 +699,13 @@ async def run(self) -> None:
699699
future = self.future
700700
if future is None:
701701
raise Exception("No pending future")
702-
if not self.future.done():
702+
if not self.future.done(): # type: ignore
703703
_step = asyncio.Event()
704704

705-
def step(*args):
705+
def step(f: "Future[_T]") -> None:
706706
_step.set()
707707

708-
self.io_loop.add_future(self.future, step)
708+
self.io_loop.add_future(self.future, step) # type: ignore
709709
await _step.wait()
710710
self.future = None
711711
try:
@@ -747,18 +747,17 @@ def step(*args):
747747
if self.future is moment:
748748
await sleep(0)
749749

750-
def handle_yield(self, yielded: _Yieldable) -> bool:
750+
def handle_yield(self, yielded: _Yieldable) -> None:
751751
try:
752752
self.future = convert_yielded(yielded)
753753
except BadYieldError:
754754
self.future = Future()
755755
future_set_exc_info(self.future, sys.exc_info())
756756

757-
def finish(self, future):
757+
def finish(self, future: "Future[_T]") -> None:
758758
if future.cancelled():
759759
self.task.cancel()
760-
self.future.cancel()
761-
self.task = None
760+
self.future.cancel() # type: ignore
762761

763762

764763
# Convert Awaitables into Futures.

tornado/ioloop.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -506,9 +506,11 @@ def run() -> None:
506506
future_cell[0] = fut
507507
fut.set_result(result)
508508
assert future_cell[0] is not None
509-
self.add_future(
510-
future_cell[0], lambda f: f.add_done_callback(lambda _: self.stop())
511-
)
509+
510+
def _stop(f: "Future[_T]") -> None:
511+
f.add_done_callback(lambda _: self.stop())
512+
513+
self.add_future(future_cell[0], _stop)
512514

513515
self.add_callback(run)
514516
if timeout is not None:

0 commit comments

Comments
 (0)