From 1060594ef85025c93c191f493578543af1927c80 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 27 Dec 2020 20:48:44 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Define=20Conversation=20as=20a?= =?UTF-8?q?=20Protocol?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- royalnet/royaltyping/__init__.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/royalnet/royaltyping/__init__.py b/royalnet/royaltyping/__init__.py index da17ae44..e12fa28d 100644 --- a/royalnet/royaltyping/__init__.py +++ b/royalnet/royaltyping/__init__.py @@ -11,6 +11,9 @@ from typing import * # noinspection PyUnresolvedReferences from typing import IO, TextIO, BinaryIO +if TYPE_CHECKING: + from royalnet.engineer import Sentry + JSONScalar = Union[ None, @@ -76,4 +79,6 @@ An async generator yielding either: """ -Conversation = Callable[["Sentry", ...], Awaitable[Optional["Conversation"]]] +class Conversation(Protocol): + def __call__(self, _sentry: "Sentry", **kwargs) -> Awaitable["Conversation"]: + ...