mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-08 13:04:46 +08:00
dataclasses: work around default factory issues (#5718)
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
import sys
|
||||
from typing import Any, Callable, Dict, Generic, Iterable, List, Mapping, Optional, Tuple, Type, TypeVar, Union, overload
|
||||
from typing_extensions import Protocol
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
from types import GenericAlias
|
||||
|
||||
_T = TypeVar("_T")
|
||||
_T_co = TypeVar("_T_co", covariant=True)
|
||||
|
||||
class _MISSING_TYPE: ...
|
||||
|
||||
@@ -63,11 +65,15 @@ else:
|
||||
*, init: bool = ..., repr: bool = ..., eq: bool = ..., order: bool = ..., unsafe_hash: bool = ..., frozen: bool = ...
|
||||
) -> Callable[[Type[_T]], Type[_T]]: ...
|
||||
|
||||
# See https://github.com/python/mypy/issues/10750
|
||||
class _DefaultFactory(Protocol[_T_co]):
|
||||
def __call__(self) -> _T_co: ...
|
||||
|
||||
class Field(Generic[_T]):
|
||||
name: str
|
||||
type: Type[_T]
|
||||
default: _T
|
||||
default_factory: Callable[[], _T]
|
||||
default_factory: _DefaultFactory[_T]
|
||||
repr: bool
|
||||
hash: Optional[bool]
|
||||
init: bool
|
||||
|
||||
Reference in New Issue
Block a user