From a024d4dfe75d98aee1101547732823ca5d607621 Mon Sep 17 00:00:00 2001 From: Ben Darnell Date: Sat, 31 Oct 2020 12:14:42 -0400 Subject: [PATCH] iostream: Add platform assertion for mypy Without this mypy would fail when run on windows. --- tornado/iostream.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tornado/iostream.py b/tornado/iostream.py index 19c548553..ced869bc4 100644 --- a/tornado/iostream.py +++ b/tornado/iostream.py @@ -1622,6 +1622,13 @@ class PipeIOStream(BaseIOStream): def __init__(self, fd: int, *args: Any, **kwargs: Any) -> None: self.fd = fd self._fio = io.FileIO(self.fd, "r+") + if sys.platform == "win32": + # The form and placement of this assertion is important to mypy. + # A plain assert statement isn't recognized here. If the assertion + # were earlier it would worry that the attributes of self aren't + # set on windows. If it were missing it would complain about + # the absence of the set_blocking function. + raise AssertionError("PipeIOStream is not supported on Windows") os.set_blocking(fd, False) super().__init__(*args, **kwargs) -- 2.47.3