From 8b28753b64ee6e757be068333b41db2f84d1928e Mon Sep 17 00:00:00 2001 From: Carl Meyer Date: Tue, 17 Sep 2019 20:48:27 -0600 Subject: [PATCH] Update and improve py_compile module stubs. (#3240) --- stdlib/2and3/py_compile.pyi | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/stdlib/2and3/py_compile.pyi b/stdlib/2and3/py_compile.pyi index a8be1136a..4b57f0d3a 100644 --- a/stdlib/2and3/py_compile.pyi +++ b/stdlib/2and3/py_compile.pyi @@ -1,7 +1,8 @@ # Stubs for py_compile (Python 2 and 3) +import enum import sys -from typing import Optional, List, Text, AnyStr, Union +from typing import Optional, List, Text, AnyStr, Union, Type _EitherStr = Union[bytes, Text] @@ -10,9 +11,16 @@ class PyCompileError(Exception): exc_value: BaseException file: str msg: str - def __init__(self, exc_type: str, exc_value: BaseException, file: str, msg: str = ...) -> None: ... + def __init__(self, exc_type: Type[BaseException], exc_value: BaseException, file: str, msg: str = ...) -> None: ... -if sys.version_info >= (3, 2): +if sys.version_info >= (3, 7): + class PycInvalidationMode(enum.Enum): + TIMESTAMP: int = ... + CHECKED_HASH: int = ... + UNCHECKED_HASH: int = ... + def _get_default_invalidation_mode() -> PycInvalidationMode: ... + def compile(file: AnyStr, cfile: Optional[AnyStr] = ..., dfile: Optional[AnyStr] = ..., doraise: bool = ..., optimize: int = ..., invalidation_mode: Optional[PycInvalidationMode] = ...) -> Optional[AnyStr]: ... +elif 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: ...