Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

webhooks: Strengthen format_pull_request_event type.

Anders Kaseorg121208321818
diff --git a/zerver/webhooks/gogs/view.py b/zerver/webhooks/gogs/view.py
index 9778480d236..d6b5c58097c 100644
--- a/zerver/webhooks/gogs/view.py
+++ b/zerver/webhooks/gogs/view.py
@@ -1,7 +1,8 @@
# vim:fenc=utf-8
-from typing import Any, Callable, Dict, Optional
+from typing import Any, Dict, Optional
from django.http import HttpRequest, HttpResponse
+from typing_extensions import Protocol
from zerver.decorator import webhook_view
from zerver.lib.exceptions import UnsupportedWebhookEventType
@@ -147,10 +148,15 @@ def api_gogs_webhook(
)
+class FormatPullRequestEvent(Protocol):
+ def __call__(self, payload: Dict[str, Any], include_title: bool) -> str:
+ ...
+
+
def gogs_webhook_main(
integration_name: str,
http_header_name: str,
- format_pull_request_event: Callable[..., Any],
+ format_pull_request_event: FormatPullRequestEvent,
request: HttpRequest,
user_profile: UserProfile,
payload: Dict[str, Any],