From: Ben Darnell Date: Sat, 31 Oct 2020 16:14:42 +0000 (-0400) Subject: iostream: Add platform assertion for mypy X-Git-Tag: v6.2.0b1~62^2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a024d4dfe75d98aee1101547732823ca5d607621;p=thirdparty%2Ftornado.git iostream: Add platform assertion for mypy Without this mypy would fail when run on windows. --- 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)