Skip to content

Commit d5178ed

Browse files
committed
Make _StrPromise and _StrOrPromise public.
This removes the leading underscore for both of these types since they will be needed by the users when typing "StrPromise" related things. Since the type is stub only, it needs to be imported conditionally: ``` from typing import TYPE_CHECKING if TYPE_CHECKING: from django.utils.functional import StrPromise ``` Signed-off-by: Zixuan James Li <[email protected]>
1 parent e95c760 commit d5178ed

File tree

22 files changed

+135
-135
lines changed

22 files changed

+135
-135
lines changed

django-stubs/apps/config.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ from typing import Dict, Iterator, Optional, Type
33

44
from django.apps.registry import Apps
55
from django.db.models.base import Model
6-
from django.utils.functional import _StrOrPromise
6+
from django.utils.functional import StrOrPromise
77

88
MODELS_MODULE_NAME: str
99

@@ -12,7 +12,7 @@ class AppConfig:
1212
module: Optional[types.ModuleType] = ...
1313
apps: Optional[Apps] = ...
1414
label: str = ...
15-
verbose_name: _StrOrPromise = ...
15+
verbose_name: StrOrPromise = ...
1616
path: str = ...
1717
models_module: Optional[str] = ...
1818
models: Dict[str, Type[Model]] = ...

django-stubs/contrib/admin/options.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ from django.http.response import HttpResponse, HttpResponseRedirect, JsonRespons
4141
from django.template.response import _TemplateForResponseT
4242
from django.urls.resolvers import URLPattern
4343
from django.utils.datastructures import _ListOrTuple
44-
from django.utils.functional import _StrOrPromise
44+
from django.utils.functional import StrOrPromise
4545
from django.utils.safestring import SafeString
4646
from typing_extensions import Literal, TypedDict
4747

@@ -297,8 +297,8 @@ class InlineModelAdmin(Generic[_ChildModelT, _ParentModelT], BaseModelAdmin[_Chi
297297
min_num: Optional[int] = ...
298298
max_num: Optional[int] = ...
299299
template: str = ...
300-
verbose_name: Optional[_StrOrPromise] = ...
301-
verbose_name_plural: Optional[_StrOrPromise] = ...
300+
verbose_name: Optional[StrOrPromise] = ...
301+
verbose_name_plural: Optional[StrOrPromise] = ...
302302
can_delete: bool = ...
303303
show_change_link: bool = ...
304304
classes: Optional[Sequence[str]] = ...

django-stubs/contrib/admin/sites.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ from django.http.request import HttpRequest
1111
from django.http.response import HttpResponse
1212
from django.template.response import TemplateResponse
1313
from django.urls import URLPattern, URLResolver
14-
from django.utils.functional import LazyObject, _StrOrPromise
14+
from django.utils.functional import LazyObject, StrOrPromise
1515

1616
if sys.version_info >= (3, 9):
1717
from weakref import WeakSet
@@ -77,7 +77,7 @@ class AdminSite:
7777
def i18n_javascript(self, request: HttpRequest, extra_context: Optional[Dict[str, Any]] = ...) -> HttpResponse: ...
7878
def logout(self, request: HttpRequest, extra_context: Optional[Dict[str, Any]] = ...) -> TemplateResponse: ...
7979
def login(self, request: HttpRequest, extra_context: Optional[Dict[str, Any]] = ...) -> HttpResponse: ...
80-
def _build_app_dict(self, request: HttpRequest, label: Optional[_StrOrPromise] = ...) -> Dict[str, Any]: ...
80+
def _build_app_dict(self, request: HttpRequest, label: Optional[StrOrPromise] = ...) -> Dict[str, Any]: ...
8181
def get_app_list(self, request: HttpRequest) -> List[Any]: ...
8282
def index(self, request: HttpRequest, extra_context: Optional[Dict[str, Any]] = ...) -> TemplateResponse: ...
8383
def app_index(

django-stubs/contrib/admin/widgets.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ from django.db.models.fields import _FieldChoices
77
from django.db.models.fields.reverse_related import ForeignObjectRel, ManyToManyRel, ManyToOneRel
88
from django.forms.models import ModelChoiceIterator
99
from django.forms.widgets import Media, _OptAttrs
10-
from django.utils.functional import _StrOrPromise
10+
from django.utils.functional import StrOrPromise
1111

1212
class FilteredSelectMultiple(forms.SelectMultiple):
13-
verbose_name: _StrOrPromise = ...
13+
verbose_name: StrOrPromise = ...
1414
is_stacked: bool = ...
1515
def __init__(
1616
self,
17-
verbose_name: _StrOrPromise,
17+
verbose_name: StrOrPromise,
1818
is_stacked: bool,
1919
attrs: Optional[_OptAttrs] = ...,
2020
choices: _FieldChoices = ...,

django-stubs/contrib/gis/db/models/fields.pyi

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ from typing import Any, Iterable, NamedTuple, Optional, Tuple, TypeVar, Union
22

33
from django.core.validators import _ValidatorCallable
44
from django.db.models.fields import Field, _ErrorMessagesT, _FieldChoices
5-
from django.utils.functional import _StrOrPromise
5+
from django.utils.functional import StrOrPromise
66

77
# __set__ value type
88
_ST = TypeVar("_ST")
@@ -20,7 +20,7 @@ def get_srid_info(srid: int, connection: Any) -> SRIDCacheEntry: ...
2020
class BaseSpatialField(Field[_ST, _GT]):
2121
def __init__(
2222
self,
23-
verbose_name: Optional[Union[_StrOrPromise, bytes]] = ...,
23+
verbose_name: Optional[Union[StrOrPromise, bytes]] = ...,
2424
srid: int = ...,
2525
spatial_index: bool = ...,
2626
*,
@@ -39,7 +39,7 @@ class BaseSpatialField(Field[_ST, _GT]):
3939
unique_for_month: Optional[str] = ...,
4040
unique_for_year: Optional[str] = ...,
4141
choices: Optional[_FieldChoices] = ...,
42-
help_text: _StrOrPromise = ...,
42+
help_text: StrOrPromise = ...,
4343
db_column: Optional[str] = ...,
4444
db_tablespace: Optional[str] = ...,
4545
validators: Iterable[_ValidatorCallable] = ...,
@@ -66,7 +66,7 @@ class GeometryField(BaseSpatialField):
6666
geography: Any = ...
6767
def __init__(
6868
self,
69-
verbose_name: Optional[Union[_StrOrPromise, bytes]] = ...,
69+
verbose_name: Optional[Union[StrOrPromise, bytes]] = ...,
7070
dim: int = ...,
7171
geography: bool = ...,
7272
*,
@@ -89,7 +89,7 @@ class GeometryField(BaseSpatialField):
8989
unique_for_month: Optional[str] = ...,
9090
unique_for_year: Optional[str] = ...,
9191
choices: Optional[_FieldChoices] = ...,
92-
help_text: _StrOrPromise = ...,
92+
help_text: StrOrPromise = ...,
9393
db_column: Optional[str] = ...,
9494
db_tablespace: Optional[str] = ...,
9595
validators: Iterable[_ValidatorCallable] = ...,

django-stubs/contrib/postgres/fields/array.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ from django.db.models import Field, Transform
55
from django.db.models.expressions import Combinable
66
from django.db.models.fields import _ErrorMessagesT, _FieldChoices
77
from django.db.models.fields.mixins import CheckFieldDefaultMixin
8-
from django.utils.functional import _StrOrPromise
8+
from django.utils.functional import StrOrPromise
99

1010
# __set__ value type
1111
_ST = TypeVar("_ST")
@@ -43,7 +43,7 @@ class ArrayField(CheckFieldDefaultMixin, Field[_ST, _GT]):
4343
unique_for_month: Optional[str] = ...,
4444
unique_for_year: Optional[str] = ...,
4545
choices: Optional[_FieldChoices] = ...,
46-
help_text: _StrOrPromise = ...,
46+
help_text: StrOrPromise = ...,
4747
db_column: Optional[str] = ...,
4848
db_tablespace: Optional[str] = ...,
4949
validators: Iterable[_ValidatorCallable] = ...,

django-stubs/core/cache/backends/db.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
from typing import Any, Dict
22

33
from django.core.cache.backends.base import BaseCache
4-
from django.utils.functional import _StrOrPromise
4+
from django.utils.functional import StrOrPromise
55

66
class Options:
77
db_table: str = ...
88
app_label: str = ...
99
model_name: str = ...
10-
verbose_name: _StrOrPromise = ...
11-
verbose_name_plural: _StrOrPromise = ...
10+
verbose_name: StrOrPromise = ...
11+
verbose_name_plural: StrOrPromise = ...
1212
object_name: str = ...
1313
abstract: bool = ...
1414
managed: bool = ...

django-stubs/core/exceptions.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from typing import Any, Dict, Iterator, List, Optional, Tuple, Union
22

3-
from django.utils.functional import _StrPromise
3+
from django.utils.functional import StrPromise
44
from typing_extensions import Literal
55

66
class FieldDoesNotExist(Exception): ...
@@ -36,7 +36,7 @@ class ValidationError(Exception):
3636
def __init__(
3737
self,
3838
# Accepts arbitrarily nested data structure, mypy doesn't allow describing it accurately.
39-
message: Union[str, _StrPromise, ValidationError, Dict[str, Any], List[Any]],
39+
message: Union[str, StrPromise, ValidationError, Dict[str, Any], List[Any]],
4040
code: Optional[str] = ...,
4141
params: Optional[Dict[str, Any]] = ...,
4242
) -> None: ...

django-stubs/core/validators.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ from re import RegexFlag
33
from typing import Any, Callable, Collection, Dict, List, Optional, Pattern, Sequence, Sized, Tuple, Union
44

55
from django.core.files.base import File
6-
from django.utils.functional import _StrPromise
6+
from django.utils.functional import StrPromise
77

88
EMPTY_VALUES: Any
99

@@ -12,14 +12,14 @@ _ValidatorCallable = Callable[[Any], None]
1212

1313
class RegexValidator:
1414
regex: _Regex = ... # Pattern[str] on instance, but may be str on class definition
15-
message: Union[str, _StrPromise] = ...
15+
message: Union[str, StrPromise] = ...
1616
code: str = ...
1717
inverse_match: bool = ...
1818
flags: int = ...
1919
def __init__(
2020
self,
2121
regex: Optional[_Regex] = ...,
22-
message: Union[str, _StrPromise, None] = ...,
22+
message: Union[str, StrPromise, None] = ...,
2323
code: Optional[str] = ...,
2424
inverse_match: Optional[bool] = ...,
2525
flags: Optional[RegexFlag] = ...,

0 commit comments

Comments
 (0)