mirror of https://github.com/zulip/zulip.git
8cfacbf8aa
The previous link was to "extended callable" types, which are deprecated in favor of callback protocols. Unfortunately, defining a protocol class can't express the typing -- we need some sort of variadic generics[1]. Specifically, we wish to support hitting the endpoint with additional parameters; thus, this protocol is insufficient: ``` class WebhookHandler(Protocol): def __call__(request: HttpRequest, api_key: str) -> HttpResponse: ... ``` ...since it prohibits additional parameters. And allowing extra arguments: ``` class WebhookHandler(Protocol): def __call__(request: HttpRequest, api_key: str, *args: object, **kwargs: object) -> HttpResponse: ... ``` ...is similarly problematic, since the view handlers do not support _arbitrary_ keyword arguments. [1] https://github.com/python/typing/issues/193 |
||
---|---|---|
.. | ||
data_import | ||
lib | ||
management | ||
migrations | ||
openapi | ||
templatetags | ||
tests | ||
tornado | ||
views | ||
webhooks | ||
worker | ||
__init__.py | ||
apps.py | ||
context_processors.py | ||
decorator.py | ||
filters.py | ||
forms.py | ||
logging_handlers.py | ||
middleware.py | ||
models.py | ||
signals.py |