2 from builtins import object as _object
3 from importlib.abc import PathEntryFinder
4 from importlib.machinery import ModuleSpec
5 from io import TextIOWrapper
6 from types import FrameType, ModuleType, TracebackType
22 from typing_extensions import Literal
26 # The following type alias are stub-only and do not exist during runtime
27 _ExcInfo = Tuple[Type[BaseException], BaseException, TracebackType]
28 _OptExcInfo = Union[_ExcInfo, Tuple[None, None, None]]
30 # Intentionally omits one deprecated and one optional method of `importlib.abc.MetaPathFinder`
31 class _MetaPathFinder(Protocol):
32 def find_spec(self, fullname: str, path: Sequence[str] | None, target: ModuleType | None = ...) -> ModuleSpec | None: ...
34 # ----- sys variables -----
35 if sys.platform != "win32":
40 byteorder: Literal["little", "big"]
41 builtin_module_names: Sequence[str] # actually a tuple of strings
43 if sys.platform == "win32":
45 dont_write_bytecode: bool
46 displayhook: Callable[[object], Any]
47 excepthook: Callable[[Type[BaseException], BaseException, TracebackType | None], Any]
52 last_type: Type[BaseException] | None
53 last_value: BaseException | None
54 last_traceback: TracebackType | None
57 meta_path: list[_MetaPathFinder]
58 modules: dict[str, ModuleType]
59 if sys.version_info >= (3, 10):
62 path_hooks: list[Any] # TODO precise type; function, path to finder
63 path_importer_cache: dict[str, PathEntryFinder | None]
65 if sys.version_info >= (3, 9):
68 if sys.version_info >= (3, 8):
69 pycache_prefix: str | None
75 if sys.version_info >= (3, 10):
76 stdlib_module_names: frozenset[str]
77 __stdin__: TextIOWrapper
78 __stdout__: TextIOWrapper
79 __stderr__: TextIOWrapper
84 # Each entry is a tuple of the form (action, message, category, module,
86 if sys.platform == "win32":
88 _xoptions: dict[Any, Any]
98 dont_write_bytecode: int
101 ignore_environment: int
105 hash_randomization: int
106 if sys.version_info >= (3, 7):
110 float_info: _float_info
113 epsilon: float # DBL_EPSILON
115 mant_dig: int # DBL_MANT_DIG
117 max_exp: int # DBL_MAX_EXP
118 max_10_exp: int # DBL_MAX_10_EXP
120 min_exp: int # DBL_MIN_EXP
121 min_10_exp: int # DBL_MIN_10_EXP
122 radix: int # FLT_RADIX
123 rounds: int # FLT_ROUNDS
125 hash_info: _hash_info
134 implementation: _implementation
136 class _implementation:
138 version: _version_info
149 class _version_info(Tuple[int, int, int, str, int]):
156 version_info: _version_info
158 def call_tracing(__func: Callable[..., _T], __args: Any) -> _T: ...
159 def _clear_type_cache() -> None: ...
160 def _current_frames() -> dict[int, FrameType]: ...
161 def _getframe(__depth: int = ...) -> FrameType: ...
162 def _debugmallocstats() -> None: ...
163 def __displayhook__(value: object) -> None: ...
164 def __excepthook__(type_: Type[BaseException], value: BaseException, traceback: TracebackType) -> None: ...
165 def exc_info() -> _OptExcInfo: ...
167 # sys.exit() accepts an optional argument of anything printable
168 def exit(__status: object = ...) -> NoReturn: ...
169 def getallocatedblocks() -> int: ...
170 def getdefaultencoding() -> str: ...
172 if sys.platform != "win32":
173 def getdlopenflags() -> int: ...
175 def getfilesystemencoding() -> str: ...
176 def getfilesystemencodeerrors() -> str: ...
177 def getrefcount(__object: Any) -> int: ...
178 def getrecursionlimit() -> int: ...
180 def getsizeof(obj: object) -> int: ...
182 def getsizeof(obj: object, default: int) -> int: ...
183 def getswitchinterval() -> float: ...
185 _ProfileFunc = Callable[[FrameType, str, Any], Any]
187 def getprofile() -> _ProfileFunc | None: ...
188 def setprofile(profilefunc: _ProfileFunc | None) -> None: ...
190 _TraceFunc = Callable[[FrameType, str, Any], Optional[Callable[[FrameType, str, Any], Any]]]
192 def gettrace() -> _TraceFunc | None: ...
193 def settrace(tracefunc: _TraceFunc | None) -> None: ...
195 class _WinVersion(Tuple[int, int, int, int, str, int, int, int, int, Tuple[int, int, int]]):
201 service_pack_minor: int
202 service_pack_major: int
205 platform_version: tuple[int, int, int]
207 if sys.platform == "win32":
208 def getwindowsversion() -> _WinVersion: ...
210 def intern(__string: str) -> str: ...
211 def is_finalizing() -> bool: ...
213 if sys.version_info >= (3, 7):
214 __breakpointhook__: Any # contains the original value of breakpointhook
215 def breakpointhook(*args: Any, **kwargs: Any) -> Any: ...
217 if sys.platform != "win32":
218 def setdlopenflags(__flags: int) -> None: ...
220 def setrecursionlimit(__limit: int) -> None: ...
221 def setswitchinterval(__interval: float) -> None: ...
222 def gettotalrefcount() -> int: ... # Debug builds only
224 if sys.version_info < (3, 9):
225 def getcheckinterval() -> int: ... # deprecated
226 def setcheckinterval(__n: int) -> None: ... # deprecated
228 if sys.version_info >= (3, 8):
229 # not exported by sys
230 class UnraisableHookArgs:
231 exc_type: Type[BaseException]
232 exc_value: BaseException | None
233 exc_traceback: TracebackType | None
235 object: _object | None
236 unraisablehook: Callable[[UnraisableHookArgs], Any]
237 def addaudithook(hook: Callable[[str, Tuple[Any, ...]], Any]) -> None: ...
238 def audit(__event: str, *args: Any) -> None: ...
240 _AsyncgenHook = Optional[Callable[[AsyncGenerator[Any, Any]], None]]
242 class _asyncgen_hooks(Tuple[_AsyncgenHook, _AsyncgenHook]):
243 firstiter: _AsyncgenHook
244 finalizer: _AsyncgenHook
246 def get_asyncgen_hooks() -> _asyncgen_hooks: ...
247 def set_asyncgen_hooks(firstiter: _AsyncgenHook = ..., finalizer: _AsyncgenHook = ...) -> None: ...
249 if sys.version_info >= (3, 7):
250 def get_coroutine_origin_tracking_depth() -> int: ...
251 def set_coroutine_origin_tracking_depth(depth: int) -> None: ...