dmr_reproduce_mypy_zope_pain.py 449 B

123456789101112131415161718192021222324252627
  1. from typing import Optional
  2. from zope.interface import Interface, implementer
  3. class IFoo(Interface):
  4. pass
  5. @implementer(IFoo)
  6. class BaseFoo:
  7. pass
  8. class ChildFoo(BaseFoo):
  9. pass
  10. class IFooFactory(Interface):
  11. def build() -> Optional[IFoo]:
  12. pass
  13. def build_and_use_foo(client_factory: IFooFactory) -> None:
  14. client_protocol = client_factory.build()
  15. assert isinstance(client_protocol, ChildFoo)
  16. print("Hello")