mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-16 08:47:39 +08:00
Use _typeshed.OptExcInfo in pydoc and unittest (#7668)
This commit is contained in:
@@ -1,17 +1,13 @@
|
||||
from _typeshed import SupportsWrite
|
||||
from _typeshed import OptExcInfo, SupportsWrite
|
||||
from abc import abstractmethod
|
||||
from builtins import list as _list # "list" conflicts with method name
|
||||
from collections.abc import Callable, Container, Mapping, MutableMapping
|
||||
from reprlib import Repr
|
||||
from types import MethodType, ModuleType, TracebackType
|
||||
from typing import IO, Any, AnyStr, NoReturn, TypeVar
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
__all__ = ["help"]
|
||||
|
||||
# the return type of sys.exc_info(), used by ErrorDuringImport.__init__
|
||||
_Exc_Info: TypeAlias = tuple[type[BaseException] | None, BaseException | None, TracebackType | None]
|
||||
|
||||
_T = TypeVar("_T")
|
||||
|
||||
__author__: str
|
||||
@@ -39,7 +35,7 @@ class ErrorDuringImport(Exception):
|
||||
exc: type[BaseException] | None
|
||||
value: BaseException | None
|
||||
tb: TracebackType | None
|
||||
def __init__(self, filename: str, exc_info: _Exc_Info) -> None: ...
|
||||
def __init__(self, filename: str, exc_info: OptExcInfo) -> None: ...
|
||||
|
||||
def importfile(path: str) -> ModuleType: ...
|
||||
def safeimport(path: str, forceload: bool = ..., cache: MutableMapping[str, ModuleType] = ...) -> ModuleType: ...
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
import unittest.case
|
||||
from _typeshed import OptExcInfo
|
||||
from collections.abc import Callable
|
||||
from types import TracebackType
|
||||
from typing import Any, TextIO, TypeVar, Union
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
_SysExcInfoType: TypeAlias = Union[tuple[type[BaseException], BaseException, TracebackType], tuple[None, None, None]]
|
||||
from typing import Any, TextIO, TypeVar
|
||||
|
||||
_F = TypeVar("_F", bound=Callable[..., Any])
|
||||
|
||||
@@ -33,10 +30,10 @@ class TestResult:
|
||||
def stopTest(self, test: unittest.case.TestCase) -> None: ...
|
||||
def startTestRun(self) -> None: ...
|
||||
def stopTestRun(self) -> None: ...
|
||||
def addError(self, test: unittest.case.TestCase, err: _SysExcInfoType) -> None: ...
|
||||
def addFailure(self, test: unittest.case.TestCase, err: _SysExcInfoType) -> None: ...
|
||||
def addError(self, test: unittest.case.TestCase, err: OptExcInfo) -> None: ...
|
||||
def addFailure(self, test: unittest.case.TestCase, err: OptExcInfo) -> None: ...
|
||||
def addSuccess(self, test: unittest.case.TestCase) -> None: ...
|
||||
def addSkip(self, test: unittest.case.TestCase, reason: str) -> None: ...
|
||||
def addExpectedFailure(self, test: unittest.case.TestCase, err: _SysExcInfoType) -> None: ...
|
||||
def addExpectedFailure(self, test: unittest.case.TestCase, err: OptExcInfo) -> None: ...
|
||||
def addUnexpectedSuccess(self, test: unittest.case.TestCase) -> None: ...
|
||||
def addSubTest(self, test: unittest.case.TestCase, subtest: unittest.case.TestCase, err: _SysExcInfoType | None) -> None: ...
|
||||
def addSubTest(self, test: unittest.case.TestCase, subtest: unittest.case.TestCase, err: OptExcInfo | None) -> None: ...
|
||||
|
||||
Reference in New Issue
Block a user