From 5de7f2018000cbfed0fd57867a26d514bba56851 Mon Sep 17 00:00:00 2001 From: Andrey Lebedev Date: Fri, 10 Feb 2023 21:33:32 +0200 Subject: [PATCH] Attempt to reproduce #91 --- tests/samples/isinstance_impl.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 tests/samples/isinstance_impl.py diff --git a/tests/samples/isinstance_impl.py b/tests/samples/isinstance_impl.py new file mode 100644 index 0000000..242744d --- /dev/null +++ b/tests/samples/isinstance_impl.py @@ -0,0 +1,29 @@ +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]" + +"""