From 7dd623bcb660b79b4a74602905bc71ae6563be44 Mon Sep 17 00:00:00 2001 From: Zixuan James Li Date: Tue, 28 Jun 2022 17:54:34 -0400 Subject: [PATCH] Add proxied functions for Promise. Although there is nothing defined in `Promise` itself, the only instances of `Promise` are created by the `lazy` function, with magic methods defined on it. https://github.com/django/django/blob/3.2.6/django/utils/functional.py#L84-L191. Signed-off-by: Zixuan James Li --- django-stubs/utils/functional.pyi | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/django-stubs/utils/functional.pyi b/django-stubs/utils/functional.pyi index 9809cf13b4..fab97fc5b5 100644 --- a/django-stubs/utils/functional.pyi +++ b/django-stubs/utils/functional.pyi @@ -20,7 +20,16 @@ class cached_property(Generic[_T]): @overload def __get__(self, instance: object, cls: Type[Any] = ...) -> _T: ... -class Promise: ... +# Promise is only subclassed by a proxy class defined in the lazy function +# so it makes sense for it to have all the methods available in that proxy class +class Promise: + def __init__(self, args: Any, kw: Any) -> None: ... + def __reduce__(self) -> Tuple[Any, Tuple[Any]]: ... + def __lt__(self, other: Any) -> bool: ... + def __mod__(self, rhs: Any) -> str: ... + def __add__(self, other: Any) -> str: ... + def __radd__(self, other: Any) -> str: ... + def __deepcopy__(self, memo: Any): ... _C = TypeVar("_C", bound=Callable)