@@ -5,9 +5,12 @@ from _typeshed import DataclassInstance
55from builtins import type as Type # alias to avoid name clashes with fields named "type"
66from collections .abc import Callable , Iterable , Mapping
77from types import GenericAlias
8- from typing import Any , Final , Generic , Literal , Protocol , TypeVar , overload , type_check_only
8+ from typing import Any , Final , Generic , Literal , Protocol , TypeAlias , TypeVar , overload , type_check_only
99from typing_extensions import Never , TypeIs
1010
11+ if sys .version_info >= (3 , 15 ):
12+ from builtins import sentinel as _sentinel
13+
1114_T = TypeVar ("_T" )
1215_T_co = TypeVar ("_T_co" , covariant = True )
1316
@@ -56,7 +59,12 @@ class _DataclassFactory(Protocol):
5659class _MISSING_TYPE (enum .Enum ):
5760 MISSING = enum .auto ()
5861
59- MISSING : Final = _MISSING_TYPE .MISSING
62+ if sys .version_info >= (3 , 15 ):
63+ _MISSING : TypeAlias = _sentinel
64+ else :
65+ _MISSING : TypeAlias = Literal [_MISSING_TYPE .MISSING ]
66+
67+ MISSING : Final [_MISSING ]
6068
6169class KW_ONLY : ...
6270
@@ -172,8 +180,8 @@ class Field(Generic[_T]):
172180 )
173181 name : str
174182 type : Type [_T ] | str | Any
175- default : _T | Literal [ _MISSING_TYPE . MISSING ]
176- default_factory : _DefaultFactory [_T ] | Literal [ _MISSING_TYPE . MISSING ]
183+ default : _T | _MISSING
184+ default_factory : _DefaultFactory [_T ] | _MISSING
177185 repr : bool
178186 hash : bool | None
179187 init : bool
@@ -183,7 +191,7 @@ class Field(Generic[_T]):
183191 if sys .version_info >= (3 , 14 ):
184192 doc : str | None
185193
186- kw_only : bool | Literal [ _MISSING_TYPE . MISSING ]
194+ kw_only : bool | _MISSING
187195
188196 if sys .version_info >= (3 , 14 ):
189197 def __init__ (
@@ -221,39 +229,39 @@ if sys.version_info >= (3, 14):
221229 def field (
222230 * ,
223231 default : _T ,
224- default_factory : Literal [ _MISSING_TYPE . MISSING ] = ...,
232+ default_factory : _MISSING = ...,
225233 init : bool = True ,
226234 repr : bool = True ,
227235 hash : bool | None = None ,
228236 compare : bool = True ,
229237 metadata : Mapping [Any , Any ] | None = None ,
230- kw_only : bool | Literal [ _MISSING_TYPE . MISSING ] = ...,
238+ kw_only : bool | _MISSING = ...,
231239 doc : str | None = None ,
232240 ) -> _T : ...
233241 @overload
234242 def field (
235243 * ,
236- default : Literal [ _MISSING_TYPE . MISSING ] = ...,
244+ default : _MISSING = ...,
237245 default_factory : Callable [[], _T ],
238246 init : bool = True ,
239247 repr : bool = True ,
240248 hash : bool | None = None ,
241249 compare : bool = True ,
242250 metadata : Mapping [Any , Any ] | None = None ,
243- kw_only : bool | Literal [ _MISSING_TYPE . MISSING ] = ...,
251+ kw_only : bool | _MISSING = ...,
244252 doc : str | None = None ,
245253 ) -> _T : ...
246254 @overload
247255 def field (
248256 * ,
249- default : Literal [ _MISSING_TYPE . MISSING ] = ...,
250- default_factory : Literal [ _MISSING_TYPE . MISSING ] = ...,
257+ default : _MISSING = ...,
258+ default_factory : _MISSING = ...,
251259 init : bool = True ,
252260 repr : bool = True ,
253261 hash : bool | None = None ,
254262 compare : bool = True ,
255263 metadata : Mapping [Any , Any ] | None = None ,
256- kw_only : bool | Literal [ _MISSING_TYPE . MISSING ] = ...,
264+ kw_only : bool | _MISSING = ...,
257265 doc : str | None = None ,
258266 ) -> Any : ...
259267
@@ -262,37 +270,37 @@ else:
262270 def field (
263271 * ,
264272 default : _T ,
265- default_factory : Literal [ _MISSING_TYPE . MISSING ] = ...,
273+ default_factory : _MISSING = ...,
266274 init : bool = True ,
267275 repr : bool = True ,
268276 hash : bool | None = None ,
269277 compare : bool = True ,
270278 metadata : Mapping [Any , Any ] | None = None ,
271- kw_only : bool | Literal [ _MISSING_TYPE . MISSING ] = ...,
279+ kw_only : bool | _MISSING = ...,
272280 ) -> _T : ...
273281 @overload
274282 def field (
275283 * ,
276- default : Literal [ _MISSING_TYPE . MISSING ] = ...,
284+ default : _MISSING = ...,
277285 default_factory : Callable [[], _T ],
278286 init : bool = True ,
279287 repr : bool = True ,
280288 hash : bool | None = None ,
281289 compare : bool = True ,
282290 metadata : Mapping [Any , Any ] | None = None ,
283- kw_only : bool | Literal [ _MISSING_TYPE . MISSING ] = ...,
291+ kw_only : bool | _MISSING = ...,
284292 ) -> _T : ...
285293 @overload
286294 def field (
287295 * ,
288- default : Literal [ _MISSING_TYPE . MISSING ] = ...,
289- default_factory : Literal [ _MISSING_TYPE . MISSING ] = ...,
296+ default : _MISSING = ...,
297+ default_factory : _MISSING = ...,
290298 init : bool = True ,
291299 repr : bool = True ,
292300 hash : bool | None = None ,
293301 compare : bool = True ,
294302 metadata : Mapping [Any , Any ] | None = None ,
295- kw_only : bool | Literal [ _MISSING_TYPE . MISSING ] = ...,
303+ kw_only : bool | _MISSING = ...,
296304 ) -> Any : ...
297305
298306def fields (class_or_instance : DataclassInstance | type [DataclassInstance ]) -> tuple [Field [Any ], ...]: ...
0 commit comments