Skip to content

Commit 15a0032

Browse files
committed
Add StrPromise and StrOrPromise aliases to django_stubs_ext.
We re-export StrPromise and StrOrPromise implicitly making it 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 <[email protected]>
1 parent 83bba91 commit 15a0032

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed
Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
1+
from .aliases import StrOrPromise, StrPromise
12
from .aliases import ValuesQuerySet as ValuesQuerySet
23
from .annotations import Annotations as Annotations
34
from .annotations import WithAnnotations as WithAnnotations
45
from .patch import monkeypatch as monkeypatch
56
from .types import AnyAttrAllowed as AnyAttrAllowed
67

7-
__all__ = ["monkeypatch", "ValuesQuerySet", "WithAnnotations", "Annotations", "AnyAttrAllowed"]
8+
__all__ = [
9+
"monkeypatch",
10+
"ValuesQuerySet",
11+
"WithAnnotations",
12+
"Annotations",
13+
"AnyAttrAllowed",
14+
"StrPromise",
15+
"StrOrPromise",
16+
]

django_stubs_ext/django_stubs_ext/aliases.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22

33
if typing.TYPE_CHECKING:
44
from django.db.models.query import _T, _QuerySet, _Row
5+
from django.utils.functional import StrOrPromise, StrPromise
56

67
ValuesQuerySet = _QuerySet[_T, _Row]
78
else:
89
from django.db.models.query import QuerySet
10+
from django.utils.functional import Promise, StrOrPromise
911

1012
ValuesQuerySet = QuerySet
13+
StrPromise = Promise
14+
StrOrPromise = typing.Union[str, Promise]

0 commit comments

Comments
 (0)