Mark all dunder attributes of BaseException as Optional (#1992)

All of these properties can be set to `None`.

Also updates `with_traceback` to only accept the values which can be stored in `__traceback__`
This commit is contained in:
Eric Wieser
2018-03-28 07:55:10 -07:00
committed by Jelle Zijlstra
parent ac70fdc614
commit 6cf1ec9654

View File

@@ -954,11 +954,11 @@ Ellipsis = ... # type: ellipsis
class BaseException:
args = ... # type: Tuple[Any, ...]
__cause__ = ... # type: BaseException
__context__ = ... # type: BaseException
__traceback__ = ... # type: TracebackType
__cause__ = ... # type: Optional[BaseException]
__context__ = ... # type: Optional[BaseException]
__traceback__ = ... # type: Optional[TracebackType]
def __init__(self, *args: object, **kwargs: object) -> None: ...
def with_traceback(self, tb: Any) -> BaseException: ...
def with_traceback(self, tb: Optional[TracebackType]) -> BaseException: ...
class GeneratorExit(BaseException): ...
class KeyboardInterrupt(BaseException): ...