summary refs log tree commit diff
diff options
context:
space:
mode:
authorDavid Robertson <davidr@element.io>2023-03-27 12:23:05 +0100
committerDavid Robertson <davidr@element.io>2023-03-27 12:23:05 +0100
commitf031e406d79649c3c69ea990bdb48bc61cd19e35 (patch)
treef376bd220e8c28c573d4653a9fa0ed11cea4112f
parentwip 10 (diff)
downloadsynapse-f031e406d79649c3c69ea990bdb48bc61cd19e35.tar.xz
Include mypy-zope test file verbatim
-rw-r--r--tests/isinstance_impl.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/isinstance_impl.py b/tests/isinstance_impl.py
new file mode 100644
index 0000000000..50dccc5dc5
--- /dev/null
+++ b/tests/isinstance_impl.py
@@ -0,0 +1,30 @@
+# Per https://github.com/Shoobx/mypy-zope/pull/92#issuecomment-1483266683
+from typing import Optional
+from zope.interface import implementer, Interface
+
+
+class IFoo(Interface):
+    ...
+
+
+@implementer(IFoo)
+class MyFoo:
+    ...
+
+
+def make_foo() -> Optional[IFoo]:
+    return MyFoo()
+
+
+x = make_foo()
+reveal_type(x)
+assert isinstance(x, MyFoo)
+
+# The code below should not be considered unreachable
+print("hello")
+
+"""
+<output>
+isinstance_impl.py:19: note: Revealed type is "Union[__main__.IFoo, None]"
+</output>
+"""