Skip to content

Commit

Permalink
Return Promise for lazy functions.
Browse files Browse the repository at this point in the history
Django uses a proxy method for lazy translation functions that actually
returns instances of `Promise` instead of `str`.

Fixes #688.
  • Loading branch information
PIG208 committed Jun 29, 2022
1 parent 214b0c7 commit 3cfe137
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions django-stubs/utils/translation/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ from contextlib import ContextDecorator
from typing import Any, Callable, Optional, Type, Union

from django.http.request import HttpRequest
from django.utils.functional import Promise

LANGUAGE_SESSION_KEY: str

Expand Down Expand Up @@ -33,14 +34,14 @@ def ngettext(singular: str, plural: str, number: float) -> str: ...
def ungettext(singular: str, plural: str, number: float) -> str: ...
def pgettext(context: str, message: str) -> str: ...
def npgettext(context: str, singular: str, plural: str, number: int) -> str: ...
def gettext_lazy(message: str) -> Promise: ...
def pgettext_lazy(context: str, message: str) -> Promise: ...
def ngettext_lazy(singular: str, plural: str, number: Union[int, str, None]) -> Promise: ...

gettext_lazy = gettext
pgettext_lazy = pgettext
ugettext_lazy = gettext_lazy
ungettext_lazy = ngettext_lazy

def ugettext_lazy(message: str) -> str: ...
def ngettext_lazy(singular: str, plural: str, number: Union[int, str, None] = ...) -> str: ...
def ungettext_lazy(singular: str, plural: str, number: Union[int, str, None] = ...) -> str: ...
def npgettext_lazy(context: str, singular: str, plural: str, number: Union[int, str, None] = ...) -> str: ...
def npgettext_lazy(context: str, singular: str, plural: str, number: Union[int, str, None]) -> Promise: ...
def activate(language: str) -> None: ...
def deactivate() -> None: ...

Expand Down

0 comments on commit 3cfe137

Please sign in to comment.