From f031e406d79649c3c69ea990bdb48bc61cd19e35 Mon Sep 17 00:00:00 2001 From: David Robertson Date: Mon, 27 Mar 2023 12:23:05 +0100 Subject: Include mypy-zope test file verbatim --- tests/isinstance_impl.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 tests/isinstance_impl.py 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") + +""" + +isinstance_impl.py:19: note: Revealed type is "Union[__main__.IFoo, None]" + +""" -- cgit 1.4.1