mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-06 12:14:27 +08:00
use Literal[_MISSING_TYPE.MISSING] for dataclasses.field defaults (#13256)
This commit is contained in:
@@ -330,8 +330,6 @@ _?ctypes.Union.__getattr__ # doesn't exist, but makes things easy if we pretend
|
||||
# These would ideally be special-cased by type checkers; see https://github.com/python/mypy/issues/2220
|
||||
_?ctypes.Array.__iter__
|
||||
|
||||
dataclasses.field # White lies around defaults
|
||||
|
||||
# __all__-related weirdness (see #6523)
|
||||
email.__all__
|
||||
email.base64mime
|
||||
|
||||
@@ -152,33 +152,37 @@ if sys.version_info >= (3, 10):
|
||||
def field(
|
||||
*,
|
||||
default: _T,
|
||||
default_factory: Literal[_MISSING_TYPE.MISSING] = ...,
|
||||
init: bool = True,
|
||||
repr: bool = True,
|
||||
hash: bool | None = None,
|
||||
compare: bool = True,
|
||||
metadata: Mapping[Any, Any] | None = None,
|
||||
kw_only: bool = ...,
|
||||
kw_only: bool | Literal[_MISSING_TYPE.MISSING] = ...,
|
||||
) -> _T: ...
|
||||
@overload
|
||||
def field(
|
||||
*,
|
||||
default: Literal[_MISSING_TYPE.MISSING] = ...,
|
||||
default_factory: Callable[[], _T],
|
||||
init: bool = True,
|
||||
repr: bool = True,
|
||||
hash: bool | None = None,
|
||||
compare: bool = True,
|
||||
metadata: Mapping[Any, Any] | None = None,
|
||||
kw_only: bool = ...,
|
||||
kw_only: bool | Literal[_MISSING_TYPE.MISSING] = ...,
|
||||
) -> _T: ...
|
||||
@overload
|
||||
def field(
|
||||
*,
|
||||
default: Literal[_MISSING_TYPE.MISSING] = ...,
|
||||
default_factory: Literal[_MISSING_TYPE.MISSING] = ...,
|
||||
init: bool = True,
|
||||
repr: bool = True,
|
||||
hash: bool | None = None,
|
||||
compare: bool = True,
|
||||
metadata: Mapping[Any, Any] | None = None,
|
||||
kw_only: bool = ...,
|
||||
kw_only: bool | Literal[_MISSING_TYPE.MISSING] = ...,
|
||||
) -> Any: ...
|
||||
|
||||
else:
|
||||
@@ -186,6 +190,7 @@ else:
|
||||
def field(
|
||||
*,
|
||||
default: _T,
|
||||
default_factory: Literal[_MISSING_TYPE.MISSING] = ...,
|
||||
init: bool = True,
|
||||
repr: bool = True,
|
||||
hash: bool | None = None,
|
||||
@@ -195,6 +200,7 @@ else:
|
||||
@overload
|
||||
def field(
|
||||
*,
|
||||
default: Literal[_MISSING_TYPE.MISSING] = ...,
|
||||
default_factory: Callable[[], _T],
|
||||
init: bool = True,
|
||||
repr: bool = True,
|
||||
@@ -205,6 +211,8 @@ else:
|
||||
@overload
|
||||
def field(
|
||||
*,
|
||||
default: Literal[_MISSING_TYPE.MISSING] = ...,
|
||||
default_factory: Literal[_MISSING_TYPE.MISSING] = ...,
|
||||
init: bool = True,
|
||||
repr: bool = True,
|
||||
hash: bool | None = None,
|
||||
|
||||
Reference in New Issue
Block a user