Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add path signature for async views #2085

Merged
merged 1 commit into from
Apr 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 15 additions & 1 deletion django-stubs/urls/conf.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from collections.abc import Callable, Sequence
from types import ModuleType
from typing import Any, overload
from typing import Any, Coroutine, overload

from django.urls import URLPattern, URLResolver, _AnyURL
from django.utils.functional import _StrOrPromise
Expand All @@ -21,6 +21,13 @@ def path(
route: _StrOrPromise, view: Callable[..., HttpResponseBase], kwargs: dict[str, Any] = ..., name: str = ...
) -> URLPattern: ...
@overload
def path(
route: _StrOrPromise,
view: Callable[..., Coroutine[Any, Any, HttpResponseBase]],
kwargs: dict[str, Any] = ...,
name: str = ...,
) -> URLPattern: ...
@overload
def path(route: _StrOrPromise, view: IncludedURLConf, kwargs: dict[str, Any] = ..., name: str = ...) -> URLResolver: ...
@overload
def path(
Expand All @@ -33,6 +40,13 @@ def re_path(
route: _StrOrPromise, view: Callable[..., HttpResponseBase], kwargs: dict[str, Any] = ..., name: str = ...
) -> URLPattern: ...
@overload
def re_path(
route: _StrOrPromise,
view: Callable[..., Coroutine[Any, Any, HttpResponseBase]],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be Coroutine[None, None, HttpResponseBase]? I don't think view coroutines should yield any values?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds fair enough

kwargs: dict[str, Any] = ...,
name: str = ...,
) -> URLPattern: ...
@overload
def re_path(
route: _StrOrPromise, view: IncludedURLConf, kwargs: dict[str, Any] = ..., name: str = ...
) -> URLResolver: ...
Expand Down