1
0

isinstance_impl.py 515 B

123456789101112131415161718192021222324252627282930
  1. # Per https://github.com/Shoobx/mypy-zope/pull/92#issuecomment-1483266683
  2. from typing import Optional
  3. from zope.interface import implementer, Interface
  4. class IFoo(Interface):
  5. ...
  6. @implementer(IFoo)
  7. class MyFoo:
  8. ...
  9. def make_foo() -> Optional[IFoo]:
  10. return MyFoo()
  11. x = make_foo()
  12. reveal_type(x)
  13. assert isinstance(x, MyFoo)
  14. # The code below should not be considered unreachable
  15. print("hello")
  16. """
  17. <output>
  18. isinstance_impl.py:19: note: Revealed type is "Union[__main__.IFoo, None]"
  19. </output>
  20. """