blob: 50dccc5dc5189a0f94d9bd776121cfe47a0dddc6 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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>
"""
|