wip 10
This commit is contained in:
@@ -3,27 +3,25 @@ from typing import Optional
|
||||
from zope.interface import Interface, implementer
|
||||
|
||||
|
||||
class IProtocol(Interface):
|
||||
class IFoo(Interface):
|
||||
pass
|
||||
|
||||
|
||||
@implementer(IProtocol)
|
||||
class Protocol:
|
||||
@implementer(IFoo)
|
||||
class BaseFoo:
|
||||
pass
|
||||
|
||||
|
||||
class _WrappingProtocol(Protocol):
|
||||
class ChildFoo(BaseFoo):
|
||||
pass
|
||||
|
||||
|
||||
class IProtocolFactory(Interface):
|
||||
def buildProtocol() -> Optional[IProtocol]:
|
||||
class IFooFactory(Interface):
|
||||
def build() -> Optional[IFoo]:
|
||||
pass
|
||||
|
||||
|
||||
def _make_connection(
|
||||
client_factory: IProtocolFactory,
|
||||
) -> None:
|
||||
client_protocol = client_factory.buildProtocol()
|
||||
assert isinstance(client_protocol, _WrappingProtocol)
|
||||
def build_and_use_foo(client_factory: IFooFactory) -> None:
|
||||
client_protocol = client_factory.build()
|
||||
assert isinstance(client_protocol, ChildFoo)
|
||||
print("Hello")
|
||||
|
||||
Reference in New Issue
Block a user