mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-15 08:17:08 +08:00
Broaden type annotation for verbose_name(_plural) to accept lazystr. (#1139)
* Broaden type annotation for verbose_name(_plural) to accept lazystr. Fixes #1137. Signed-off-by: Zixuan James Li <p359101898@gmail.com> * Broaden type annotation for help_text to accept lazystr. Signed-off-by: Zixuan James Li <p359101898@gmail.com> * Broaden type annotation for ValidationError to accept lazystr. Signed-off-by: Zixuan James Li <p359101898@gmail.com> * Broaden type annotation for label to accept lazystr. Signed-off-by: Zixuan James Li <p359101898@gmail.com> * Add StrPromise and StrOrPromise aliases to django_stubs_ext. We make StrPromise and StrOrPromise available via django_stubs_ext so that conditional imports with TYPE_CHECKING is not required. These aliases fall back to Promise or Union[str, Promise] when not TYPE_CHECKING. Signed-off-by: Zixuan James Li <p359101898@gmail.com> Signed-off-by: Zixuan James Li <p359101898@gmail.com>
This commit is contained in:
@@ -1,7 +1,16 @@
|
||||
from .aliases import StrOrPromise, StrPromise
|
||||
from .aliases import ValuesQuerySet as ValuesQuerySet
|
||||
from .annotations import Annotations as Annotations
|
||||
from .annotations import WithAnnotations as WithAnnotations
|
||||
from .patch import monkeypatch as monkeypatch
|
||||
from .types import AnyAttrAllowed as AnyAttrAllowed
|
||||
|
||||
__all__ = ["monkeypatch", "ValuesQuerySet", "WithAnnotations", "Annotations", "AnyAttrAllowed"]
|
||||
__all__ = [
|
||||
"monkeypatch",
|
||||
"ValuesQuerySet",
|
||||
"WithAnnotations",
|
||||
"Annotations",
|
||||
"AnyAttrAllowed",
|
||||
"StrPromise",
|
||||
"StrOrPromise",
|
||||
]
|
||||
|
||||
@@ -2,9 +2,15 @@ import typing
|
||||
|
||||
if typing.TYPE_CHECKING:
|
||||
from django.db.models.query import _T, _QuerySet, _Row
|
||||
from django.utils.functional import _StrOrPromise as StrOrPromise
|
||||
from django.utils.functional import _StrPromise as StrPromise
|
||||
|
||||
ValuesQuerySet = _QuerySet[_T, _Row]
|
||||
else:
|
||||
from django.db.models.query import QuerySet
|
||||
from django.utils.functional import Promise as StrPromise
|
||||
|
||||
ValuesQuerySet = QuerySet
|
||||
StrOrPromise = typing.Union[str, StrPromise]
|
||||
|
||||
__all__ = ["StrOrPromise", "StrPromise", "ValuesQuerySet"]
|
||||
|
||||
Reference in New Issue
Block a user