1from types import ClassType, FrameType, ModuleType, TracebackType
2from typing import IO, Any, BinaryIO, Callable, Dict, List, NoReturn, Optional, Sequence, Text, Tuple, Type, Union, overload
3
4# The following type alias are stub-only and do not exist during runtime
5_ExcInfo = Tuple[Type[BaseException], BaseException, TracebackType]
6_OptExcInfo = Union[_ExcInfo, Tuple[None, None, None]]
7
8class _flags:
9    bytes_warning: int
10    debug: int
11    division_new: int
12    division_warning: int
13    dont_write_bytecode: int
14    hash_randomization: int
15    ignore_environment: int
16    inspect: int
17    interactive: int
18    no_site: int
19    no_user_site: int
20    optimize: int
21    py3k_warning: int
22    tabcheck: int
23    unicode: int
24    verbose: int
25
26class _float_info:
27    max: float
28    max_exp: int
29    max_10_exp: int
30    min: float
31    min_exp: int
32    min_10_exp: int
33    dig: int
34    mant_dig: int
35    epsilon: float
36    radix: int
37    rounds: int
38
39class _version_info(Tuple[int, int, int, str, int]):
40    major: int
41    minor: int
42    micro: int
43    releaselevel: str
44    serial: int
45
46_mercurial: Tuple[str, str, str]
47api_version: int
48argv: List[str]
49builtin_module_names: Tuple[str, ...]
50byteorder: str
51copyright: str
52dont_write_bytecode: bool
53exec_prefix: str
54executable: str
55flags: _flags
56float_repr_style: str
57hexversion: int
58long_info: object
59maxint: int
60maxsize: int
61maxunicode: int
62modules: Dict[str, Any]
63path: List[str]
64platform: str
65prefix: str
66py3kwarning: bool
67__stderr__: IO[str]
68__stdin__: IO[str]
69__stdout__: IO[str]
70stderr: IO[str]
71stdin: IO[str]
72stdout: IO[str]
73subversion: Tuple[str, str, str]
74version: str
75warnoptions: object
76float_info: _float_info
77version_info: _version_info
78ps1: str
79ps2: str
80last_type: type
81last_value: BaseException
82last_traceback: TracebackType
83# TODO precise types
84meta_path: List[Any]
85path_hooks: List[Any]
86path_importer_cache: Dict[str, Any]
87displayhook: Callable[[object], Any]
88excepthook: Callable[[Type[BaseException], BaseException, TracebackType], Any]
89exc_type: Optional[type]
90exc_value: Union[BaseException, ClassType]
91exc_traceback: TracebackType
92
93class _WindowsVersionType:
94    major: Any
95    minor: Any
96    build: Any
97    platform: Any
98    service_pack: Any
99    service_pack_major: Any
100    service_pack_minor: Any
101    suite_mask: Any
102    product_type: Any
103
104def getwindowsversion() -> _WindowsVersionType: ...
105def _clear_type_cache() -> None: ...
106def _current_frames() -> Dict[int, FrameType]: ...
107def _getframe(depth: int = ...) -> FrameType: ...
108def call_tracing(fn: Any, args: Any) -> Any: ...
109def __displayhook__(value: object) -> None: ...
110def __excepthook__(type_: type, value: BaseException, traceback: TracebackType) -> None: ...
111def exc_clear() -> None: ...
112def exc_info() -> _OptExcInfo: ...
113
114# sys.exit() accepts an optional argument of anything printable
115def exit(arg: Any = ...) -> NoReturn: ...
116def getcheckinterval() -> int: ...  # deprecated
117def getdefaultencoding() -> str: ...
118def getdlopenflags() -> int: ...
119def getfilesystemencoding() -> str: ...  # In practice, never returns None
120def getrefcount(arg: Any) -> int: ...
121def getrecursionlimit() -> int: ...
122def getsizeof(obj: object, default: int = ...) -> int: ...
123def getprofile() -> Optional[Any]: ...
124def gettrace() -> Optional[Any]: ...
125def setcheckinterval(interval: int) -> None: ...  # deprecated
126def setdlopenflags(n: int) -> None: ...
127def setdefaultencoding(encoding: Text) -> None: ...  # only exists after reload(sys)
128def setprofile(profilefunc: Any) -> None: ...  # TODO type
129def setrecursionlimit(limit: int) -> None: ...
130def settrace(tracefunc: Any) -> None: ...  # TODO type
131