diff --git a/stdlib/2/typing.pyi b/stdlib/2/typing.pyi index e591333f3..b7da4d0d6 100644 --- a/stdlib/2/typing.pyi +++ b/stdlib/2/typing.pyi @@ -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]: ... diff --git a/stdlib/3/typing.pyi b/stdlib/3/typing.pyi index c48f4a8b1..01fd87f84 100644 --- a/stdlib/3/typing.pyi +++ b/stdlib/3/typing.pyi @@ -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]: ...