|
14 | 14 | import warnings |
15 | 15 | from binascii import b2a_hex |
16 | 16 | from collections import defaultdict, deque |
| 17 | +from collections.abc import Callable |
17 | 18 | from io import StringIO, TextIOBase |
18 | 19 | from threading import local |
19 | | -from typing import Any, Callable, Optional |
| 20 | +from typing import Any |
20 | 21 |
|
21 | 22 | import zmq |
22 | 23 | from jupyter_client.session import extract_header |
@@ -70,7 +71,7 @@ def __init__(self, socket, pipe=False): |
70 | 71 | self._event_pipes: dict[threading.Thread, Any] = {} |
71 | 72 | self._event_pipe_gc_lock: threading.Lock = threading.Lock() |
72 | 73 | self._event_pipe_gc_seconds: float = 10 |
73 | | - self._event_pipe_gc_task: Optional[asyncio.Task[Any]] = None |
| 74 | + self._event_pipe_gc_task: asyncio.Task[Any] | None = None |
74 | 75 | self._setup_event_pipe() |
75 | 76 | self.thread = threading.Thread(target=self._thread_main, name="IOPub") |
76 | 77 | self.thread.daemon = True |
@@ -359,7 +360,7 @@ class OutStream(TextIOBase): |
359 | 360 | flush_interval = 0.2 |
360 | 361 | topic = None |
361 | 362 | encoding = "UTF-8" |
362 | | - _exc: Optional[Any] = None |
| 363 | + _exc: Any | None = None |
363 | 364 |
|
364 | 365 | def fileno(self): |
365 | 366 | """ |
@@ -658,7 +659,7 @@ def _flush(self): |
658 | 659 | ident=self.topic, |
659 | 660 | ) |
660 | 661 |
|
661 | | - def write(self, string: str) -> Optional[int]: # type:ignore[override] |
| 662 | + def write(self, string: str) -> int | None: # type:ignore[override] |
662 | 663 | """Write to current stream after encoding if necessary |
663 | 664 |
|
664 | 665 | Returns |
|
0 commit comments