Skip to content

Commit 8941c4e

Browse files
committed
Preliminary implementation of stdlib/3.7/dataclasses.pyi.
1 parent 8891b02 commit 8941c4e

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

stdlib/3.7/dataclasses.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
from typing import *
2+
3+
4+
T = TypeVar('T')
5+
6+
DictType = TypeVar('DictType', bound=dict)
7+
TupleType = TypeVar('TupleType', bound=tuple)
8+
9+
class _MISSING_TYPE: ...
10+
11+
class _InitVarMeta(type): ...
12+
13+
def asdict(obj: Any, *, dict_factory:DictType=...) -> DictType: ...
14+
15+
def astuple(obj: Any, *, tuple_factory:TupleType=...) -> TupleType: ...
16+
17+
def dataclass(_cls:Optional[Type[T]]=..., *, init:bool=..., repr:bool=...,
18+
eq:bool=..., order:bool=..., hash:Optional[bool]=..., frozen:bool=...) -> Type[T]: ...
19+
20+
class Field(Generic[T]):
21+
name: str
22+
type: Type[T]
23+
default: T
24+
default_factory: Callable[[], T]
25+
repr: bool
26+
hash: Optional[bool]
27+
init: bool
28+
compare: bool
29+
metadata: Optional[Mapping[str, Any]]
30+
31+
32+
def field(*, default:Union[T, _MISSING_TYPE]=..., default_factory:Union[Callable[[], T], _MISSING_TYPE]=...,
33+
init:bool=..., repr:bool=..., hash:Optional[bool]=..., compare:bool=..., metadata:Optional[Mapping[str, Any]]=...) -> Field: ...
34+
35+
def fields(class_or_instance:Type) -> Tuple[Field, ...]: ...
36+
37+
def is_dataclass(obj:Any) -> bool: ...
38+
39+
class FrozenInstanceError(AttributeError): ...
40+
41+
class InitVar(metaclass=_InitVarMeta): ...
42+
43+
def make_dataclass(cls_name:str, fields:Iterable[Union[str, Tuple[str, type], Tuple[str, type, Field]]], *,
44+
bases:Tuple[type, ...]=..., namespace:Dict[str, Any]=...,
45+
init:bool=..., repr:bool=..., eq:bool=..., order:bool=..., hash:bool=..., frozen:bool=...): ...
46+
47+
def replace(obj:T, **changes:Any) -> T: ...

0 commit comments

Comments
 (0)