Skip to content

Commit 21ce4fe

Browse files
committed
Add StrPromise and StrOrPromise aliases to django_stubs_ext.
We re-export StrPromise and StrOrPromise explicitly 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 21ce4fe

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-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: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,15 @@
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]
8+
StrOrPromise = StrOrPromise
9+
StrPromise = StrPromise
710
else:
811
from django.db.models.query import QuerySet
12+
from django.utils.functional import Promise, StrOrPromise
913

1014
ValuesQuerySet = QuerySet
15+
StrPromise = Promise
16+
StrOrPromise = typing.Union[str, Promise]

0 commit comments

Comments
 (0)