From 1965e9dd22393dd5fa4495f7df00461b741c8851 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Thu, 2 Aug 2018 23:02:49 -0700 Subject: [PATCH] Add stub for toml (#2355) See https://github.com/uiri/toml/issues/178 --- third_party/2and3/toml.pyi | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 third_party/2and3/toml.pyi diff --git a/third_party/2and3/toml.pyi b/third_party/2and3/toml.pyi new file mode 100644 index 000000000..2639178e0 --- /dev/null +++ b/third_party/2and3/toml.pyi @@ -0,0 +1,24 @@ +from typing import Any, IO, List, Mapping, MutableMapping, Optional, Protocol, Text, Type, Union +import datetime +import sys + +if sys.version_info >= (3, 4): + import pathlib + if sys.version_info >= (3, 6): + import os + _PathLike = Union[Text, pathlib.PurePath, os.PathLike] + else: + _PathLike = Union[Text, pathlib.PurePath] +else: + _PathLike = Text + +class _Writable(Protocol): + def write(self, obj: str) -> Any: ... + +class TomlDecodeError(Exception): ... + +def load(f: Union[_PathLike, List[Text], IO[str]], _dict: Type[MutableMapping[str, Any]] = ...) -> MutableMapping[str, Any]: ... +def loads(s: Text, _dict: Type[MutableMapping[str, Any]] = ...) -> MutableMapping[str, Any]: ... + +def dump(o: Mapping[str, Any], f: _Writable) -> str: ... +def dumps(o: Mapping[str, Any]) -> str: ...