From 63590301f7c6f38ae162ba9d00192c83116110d2 Mon Sep 17 00:00:00 2001 From: David Euresti Date: Tue, 7 Mar 2017 16:35:45 -0800 Subject: [PATCH] Add stubs for py_compile. (#954) * Add stubs for py_compile. * Correct Text --- stdlib/2and3/py_compile.pyi | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 stdlib/2and3/py_compile.pyi diff --git a/stdlib/2and3/py_compile.pyi b/stdlib/2and3/py_compile.pyi new file mode 100644 index 000000000..cdd51ec77 --- /dev/null +++ b/stdlib/2and3/py_compile.pyi @@ -0,0 +1,20 @@ +# Stubs for py_compile (Python 2 and 3) +import sys + +from typing import Optional, List, Text, AnyStr, Union + +_EitherStr = Union[bytes, Text] + +class PyCompileError(Exception): + exc_type_name = ... # type: str + exc_value = ... # type: BaseException + file = ... # type: str + msg = ... # type: str + def __init__(self, exc_type: str, exc_value: BaseException, file: str, msg: str = ...) -> None: ... + +if sys.version_info >= (3, 2): + def compile(file: AnyStr, cfile: Optional[AnyStr] = ..., dfile: Optional[AnyStr] = ..., doraise: bool = ..., optimize: int = ...) -> Optional[AnyStr]: ... +else: + def compile(file: _EitherStr, cfile: Optional[_EitherStr] = ..., dfile: Optional[_EitherStr] = ..., doraise: bool = ...) -> None: ... + +def main(args: Optional[List[Text]] = ...): ...