From e5a276c94f7f44a56fe609f2bd575f73d52ab4b2 Mon Sep 17 00:00:00 2001 From: Rune Tynan Date: Fri, 6 Mar 2020 14:34:05 -0500 Subject: [PATCH] Add parser stubs (#3822) --- stdlib/2and3/parser.pyi | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 stdlib/2and3/parser.pyi diff --git a/stdlib/2and3/parser.pyi b/stdlib/2and3/parser.pyi new file mode 100644 index 000000000..85c19ecc4 --- /dev/null +++ b/stdlib/2and3/parser.pyi @@ -0,0 +1,29 @@ +from typing import Any, List, Sequence, Text, Tuple, Union +from types import CodeType + +import sys + +if sys.version_info >= (3, 6): + from builtins import _PathLike + _Path = Union[str, bytes, _PathLike] +else: + _Path = Union[str, bytes] + +def expr(source: Text) -> STType: ... +def suite(source: Text) -> STType: ... +def sequence2st(sequence: Sequence[Any]) -> STType: ... +def tuple2st(sequence: Sequence[Any]) -> STType: ... +def st2list(st: STType, line_info: bool = ..., col_info: bool = ...) -> List[Any]: ... +def st2tuple(st: STType, line_info: bool = ..., col_info: bool = ...) -> Tuple[Any]: ... +def compilest(st: STType, filename: _Path = ...) -> CodeType: ... +def isexpr(st: STType) -> bool: ... +def issuite(st: STType) -> bool: ... + +class ParserError(Exception): ... + +class STType: + def compile(self, filename: _Path) -> CodeType: ... + def isexpr(self) -> bool: ... + def issuite(self) -> bool: ... + def tolist(self, line_info: bool = ..., col_info: bool = ...) -> List[Any]: ... + def totuple(self, line_info: bool = ..., col_info: bool = ...) -> Tuple[Any]: ...