Added methods of typing.NamedTuple (#864)

This commit is contained in:
Andrey Vlasovskikh
2017-01-26 22:52:59 +03:00
committed by Łukasz Langa
parent 39df0d0725
commit 1d1a2e458c
2 changed files with 24 additions and 6 deletions

View File

@@ -355,8 +355,17 @@ def cast(tp: Type[_T], obj: Any) -> _T: ...
# Type constructors
# NamedTuple is special-cased in the type checker; the initializer is ignored.
def NamedTuple(typename: str, fields: Iterable[Tuple[str, Any]], *,
verbose: bool = ..., rename: bool = ...) -> Type[tuple]: ...
# NamedTuple is special-cased in the type checker
class NamedTuple(tuple):
_fields = ... # type: Tuple[str, ...]
def __init__(self, typename: str, fields: Iterable[Tuple[str, Any]], *,
verbose: bool = ..., rename: bool = ...) -> None: ...
@classmethod
def _make(cls, iterable: Iterable[Any]) -> NamedTuple: ...
def _asdict(self) -> dict: ...
def _replace(self, **kwargs: Any) -> NamedTuple: ...
def NewType(name: str, tp: Type[_T]) -> Type[_T]: ...

View File

@@ -462,8 +462,17 @@ def cast(tp: Type[_T], obj: Any) -> _T: ...
# Type constructors
# NamedTuple is special-cased in the type checker; the initializer is ignored.
def NamedTuple(typename: str, fields: Iterable[Tuple[str, Any]], *,
verbose: bool = ..., rename: bool = ..., module: str = None) -> Type[tuple]: ...
# NamedTuple is special-cased in the type checker
class NamedTuple(tuple):
_fields = ... # type: Tuple[str, ...]
def __init__(self, typename: str, fields: Iterable[Tuple[str, Any]], *,
verbose: bool = ..., rename: bool = ..., module: Any = ...) -> None: ...
@classmethod
def _make(cls, iterable: Iterable[Any]) -> NamedTuple: ...
def _asdict(self) -> dict: ...
def _replace(self, **kwargs: Any) -> NamedTuple: ...
def NewType(name: str, tp: Type[_T]) -> Type[_T]: ...