Skip to content

Commit 3cfe137

Browse files
committed
Return Promise for lazy functions.
Django uses a proxy method for lazy translation functions that actually returns instances of `Promise` instead of `str`. Fixes typeddjango#688.
1 parent 214b0c7 commit 3cfe137

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

django-stubs/utils/translation/__init__.pyi

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ from contextlib import ContextDecorator
44
from typing import Any, Callable, Optional, Type, Union
55

66
from django.http.request import HttpRequest
7+
from django.utils.functional import Promise
78

89
LANGUAGE_SESSION_KEY: str
910

@@ -33,14 +34,14 @@ def ngettext(singular: str, plural: str, number: float) -> str: ...
3334
def ungettext(singular: str, plural: str, number: float) -> str: ...
3435
def pgettext(context: str, message: str) -> str: ...
3536
def npgettext(context: str, singular: str, plural: str, number: int) -> str: ...
37+
def gettext_lazy(message: str) -> Promise: ...
38+
def pgettext_lazy(context: str, message: str) -> Promise: ...
39+
def ngettext_lazy(singular: str, plural: str, number: Union[int, str, None]) -> Promise: ...
3640

37-
gettext_lazy = gettext
38-
pgettext_lazy = pgettext
41+
ugettext_lazy = gettext_lazy
42+
ungettext_lazy = ngettext_lazy
3943

40-
def ugettext_lazy(message: str) -> str: ...
41-
def ngettext_lazy(singular: str, plural: str, number: Union[int, str, None] = ...) -> str: ...
42-
def ungettext_lazy(singular: str, plural: str, number: Union[int, str, None] = ...) -> str: ...
43-
def npgettext_lazy(context: str, singular: str, plural: str, number: Union[int, str, None] = ...) -> str: ...
44+
def npgettext_lazy(context: str, singular: str, plural: str, number: Union[int, str, None]) -> Promise: ...
4445
def activate(language: str) -> None: ...
4546
def deactivate() -> None: ...
4647

0 commit comments

Comments
 (0)