@@ -11,6 +11,8 @@ from django.utils.translation import ugettext_lazy as _
11
11
from django .utils .functional import cached_property
12
12
from typing_extensions import Literal
13
13
14
+ from django_stubs_ext import StrOrPromise
15
+
14
16
from rest_framework .exceptions import APIException as APIException
15
17
from rest_framework .exceptions import AuthenticationFailed as AuthenticationFailed
16
18
from rest_framework .exceptions import ErrorDetail as ErrorDetail
@@ -97,10 +99,10 @@ class BaseSerializer(Generic[_IN], Field[Any, Any, Any, _IN]):
97
99
default : Any = ...,
98
100
initial : Any = ...,
99
101
source : str = ...,
100
- label : str = ...,
101
- help_text : str = ...,
102
+ label : StrOrPromise = ...,
103
+ help_text : StrOrPromise = ...,
102
104
style : dict [str , Any ] = ...,
103
- error_messages : dict [str , str ] = ...,
105
+ error_messages : dict [str , StrOrPromise ] = ...,
104
106
validators : Sequence [Validator [Any ]] | None = ...,
105
107
allow_null : bool = ...,
106
108
): ...
@@ -132,7 +134,7 @@ class Serializer(
132
134
metaclass = SerializerMetaclass ,
133
135
):
134
136
_declared_fields : dict [str , Field ]
135
- default_error_messages : dict [str , Any ]
137
+ default_error_messages : dict [str , StrOrPromise ]
136
138
def get_initial (self ) -> Any : ...
137
139
@cached_property
138
140
def fields (self ) -> BindingDict : ...
@@ -155,7 +157,7 @@ class ListSerializer(
155
157
):
156
158
child : Field | BaseSerializer | None
157
159
many : bool
158
- default_error_messages : dict [str , Any ]
160
+ default_error_messages : dict [str , StrOrPromise ]
159
161
allow_empty : bool | None
160
162
def __init__ (
161
163
self ,
@@ -171,10 +173,10 @@ class ListSerializer(
171
173
default : Any = ...,
172
174
initial : Any = ...,
173
175
source : str = ...,
174
- label : str = ...,
175
- help_text : str = ...,
176
+ label : StrOrPromise = ...,
177
+ help_text : StrOrPromise = ...,
176
178
style : dict [str , Any ] = ...,
177
- error_messages : dict [str , str ] = ...,
179
+ error_messages : dict [str , StrOrPromise ] = ...,
178
180
validators : Sequence [Validator [list [Any ]]] | None = ...,
179
181
allow_null : bool = ...,
180
182
): ...
@@ -216,10 +218,10 @@ class ModelSerializer(Serializer, BaseSerializer[_MT]):
216
218
default : _MT | Sequence [_MT ] | Callable [[], _MT | Sequence [_MT ]] = ...,
217
219
initial : _MT | Sequence [_MT ] | Callable [[], _MT | Sequence [_MT ]] = ...,
218
220
source : str = ...,
219
- label : str = ...,
220
- help_text : str = ...,
221
+ label : StrOrPromise = ...,
222
+ help_text : StrOrPromise = ...,
221
223
style : dict [str , Any ] = ...,
222
- error_messages : dict [str , str ] = ...,
224
+ error_messages : dict [str , StrOrPromise ] = ...,
223
225
validators : Sequence [Validator [_MT ]] | None = ...,
224
226
allow_null : bool = ...,
225
227
allow_empty : bool = ...,
0 commit comments