webhooks: Strengthen format_pull_request_event type.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2021-02-15 16:25:55 -08:00 committed by Tim Abbott
parent d001676728
commit 1212083218
1 changed files with 8 additions and 2 deletions

View File

@ -1,7 +1,8 @@
# vim:fenc=utf-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 django.http import HttpRequest, HttpResponse
from typing_extensions import Protocol
from zerver.decorator import webhook_view from zerver.decorator import webhook_view
from zerver.lib.exceptions import UnsupportedWebhookEventType 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( def gogs_webhook_main(
integration_name: str, integration_name: str,
http_header_name: str, http_header_name: str,
format_pull_request_event: Callable[..., Any], format_pull_request_event: FormatPullRequestEvent,
request: HttpRequest, request: HttpRequest,
user_profile: UserProfile, user_profile: UserProfile,
payload: Dict[str, Any], payload: Dict[str, Any],