]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
iostream: Add platform assertion for mypy
authorBen Darnell <ben@bendarnell.com>
Sat, 31 Oct 2020 16:14:42 +0000 (12:14 -0400)
committerBen Darnell <ben@bendarnell.com>
Sat, 31 Oct 2020 16:14:42 +0000 (12:14 -0400)
Without this mypy would fail when run on windows.

tornado/iostream.py

index 19c548553a5a583f7f0ea03bb805eeeb8fad8574..ced869bc4e80f113f017fca08c1e2e2787a506ca 100644 (file)
@@ -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)