Update sys.exit and SystemExit.code to have the same types (#8554)

This commit is contained in:
Kevin Kirsche
2022-08-20 05:59:38 -04:00
committed by GitHub
parent 5435ed76ef
commit b26c31a23c
2 changed files with 6 additions and 5 deletions

View File

@@ -1279,7 +1279,7 @@ else:
__locals: Mapping[str, object] | None = ...,
) -> None: ...
def exit(code: object = ...) -> NoReturn: ...
def exit(code: sys._ExitCode = ...) -> NoReturn: ...
class filter(Iterator[_T], Generic[_T]):
@overload
@@ -1616,7 +1616,7 @@ else:
@overload
def pow(__base: _SupportsSomeKindOfPow, __exp: complex, __mod: None = ...) -> complex: ...
def quit(code: object = ...) -> NoReturn: ...
def quit(code: sys._ExitCode = ...) -> NoReturn: ...
class reversed(Iterator[_T], Generic[_T]):
@overload
@@ -1794,7 +1794,7 @@ class GeneratorExit(BaseException): ...
class KeyboardInterrupt(BaseException): ...
class SystemExit(BaseException):
code: int
code: sys._ExitCode
class Exception(BaseException): ...

View File

@@ -11,6 +11,8 @@ from typing_extensions import Literal, TypeAlias, final
_T = TypeVar("_T")
# see https://github.com/python/typeshed/issues/8513#issue-1333671093 for the rationale behind this alias
_ExitCode: TypeAlias = str | int | None
_OptExcInfo: TypeAlias = OptExcInfo # noqa: Y047 # TODO: obsolete, remove fall 2022 or later
# Intentionally omits one deprecated and one optional method of `importlib.abc.MetaPathFinder`
@@ -221,8 +223,7 @@ def exc_info() -> OptExcInfo: ...
if sys.version_info >= (3, 11):
def exception() -> BaseException | None: ...
# sys.exit() accepts an optional argument of anything printable
def exit(__status: object = ...) -> NoReturn: ...
def exit(__status: _ExitCode = ...) -> NoReturn: ...
def getallocatedblocks() -> int: ...
def getdefaultencoding() -> str: ...