diff --git a/django-stubs/shortcuts.pyi b/django-stubs/shortcuts.pyi index 3e43b7d..ad3f2c7 100644 --- a/django-stubs/shortcuts.pyi +++ b/django-stubs/shortcuts.pyi @@ -21,8 +21,8 @@ class SupportsGetAbsoluteUrl(Protocol): def get_absolute_url(self) -> str: ... @overload -def redirect( # type: ignore - to: Union[Callable, str, SupportsGetAbsoluteUrl], *args: Any, permanent: Literal[True] = ..., **kwargs: Any +def redirect( + to: Union[Callable, str, SupportsGetAbsoluteUrl], *args: Any, permanent: Literal[True], **kwargs: Any ) -> HttpResponsePermanentRedirect: ... @overload def redirect( @@ -30,7 +30,7 @@ def redirect( ) -> HttpResponseRedirect: ... @overload def redirect( - to: Union[Callable, str, SupportsGetAbsoluteUrl], *args: Any, permanent: bool = ..., **kwargs: Any + to: Union[Callable, str, SupportsGetAbsoluteUrl], *args: Any, permanent: bool, **kwargs: Any ) -> Union[HttpResponseRedirect, HttpResponsePermanentRedirect]: ... _T = TypeVar("_T", bound=Model) diff --git a/tests/typecheck/test_shortcuts.yml b/tests/typecheck/test_shortcuts.yml index 976656b..99769fe 100644 --- a/tests/typecheck/test_shortcuts.yml +++ b/tests/typecheck/test_shortcuts.yml @@ -54,6 +54,7 @@ from django.shortcuts import redirect reveal_type(redirect(to = '', permanent = True)) # N: Revealed type is "django.http.response.HttpResponsePermanentRedirect" reveal_type(redirect(to = '', permanent = False)) # N: Revealed type is "django.http.response.HttpResponseRedirect" + reveal_type(redirect(to = '')) # N: Revealed type is "django.http.response.HttpResponseRedirect" var = True reveal_type(redirect(to = '', permanent = var)) # N: Revealed type is "Union[django.http.response.HttpResponseRedirect, django.http.response.HttpResponsePermanentRedirect]"