mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-08 21:14:48 +08:00
Switch to PEP-604 syntax in python2 stubs (#5915)
Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>
This commit is contained in:
@@ -11,7 +11,6 @@ from typing import (
|
||||
List,
|
||||
Mapping,
|
||||
NoReturn,
|
||||
Optional,
|
||||
Pattern,
|
||||
Sequence,
|
||||
Set,
|
||||
@@ -79,7 +78,7 @@ class _AssertRaisesContext(_AssertRaisesBaseContext):
|
||||
class TestCase(Testable):
|
||||
failureException: Type[BaseException]
|
||||
longMessage: bool
|
||||
maxDiff: Optional[int]
|
||||
maxDiff: int | None
|
||||
# undocumented
|
||||
_testMethodName: str
|
||||
def __init__(self, methodName: str = ...) -> None: ...
|
||||
@@ -144,9 +143,7 @@ class TestCase(Testable):
|
||||
) -> None: ...
|
||||
def assertListEqual(self, first: List[Any], second: List[Any], msg: object = ...) -> None: ...
|
||||
def assertTupleEqual(self, first: Tuple[Any, ...], second: Tuple[Any, ...], msg: object = ...) -> None: ...
|
||||
def assertSetEqual(
|
||||
self, first: Union[Set[Any], FrozenSet[Any]], second: Union[Set[Any], FrozenSet[Any]], msg: object = ...
|
||||
) -> None: ...
|
||||
def assertSetEqual(self, first: Set[Any] | FrozenSet[Any], second: Set[Any] | FrozenSet[Any], msg: object = ...) -> None: ...
|
||||
def assertDictEqual(self, first: Dict[Any, Any], second: Dict[Any, Any], msg: object = ...) -> None: ...
|
||||
def assertLess(self, first: Any, second: Any, msg: object = ...) -> None: ...
|
||||
def assertLessEqual(self, first: Any, second: Any, msg: object = ...) -> None: ...
|
||||
@@ -177,8 +174,8 @@ class TestCase(Testable):
|
||||
def assertIsNotNone(self, expr: Any, msg: object = ...) -> None: ...
|
||||
def assertIn(self, first: _T, second: Iterable[_T], msg: object = ...) -> None: ...
|
||||
def assertNotIn(self, first: _T, second: Iterable[_T], msg: object = ...) -> None: ...
|
||||
def assertIsInstance(self, obj: Any, cls: Union[type, Tuple[type, ...]], msg: object = ...) -> None: ...
|
||||
def assertNotIsInstance(self, obj: Any, cls: Union[type, Tuple[type, ...]], msg: object = ...) -> None: ...
|
||||
def assertIsInstance(self, obj: Any, cls: type | Tuple[type, ...], msg: object = ...) -> None: ...
|
||||
def assertNotIsInstance(self, obj: Any, cls: type | Tuple[type, ...], msg: object = ...) -> None: ...
|
||||
def fail(self, msg: object = ...) -> NoReturn: ...
|
||||
def countTestCases(self) -> int: ...
|
||||
def defaultTestResult(self) -> TestResult: ...
|
||||
@@ -187,16 +184,16 @@ class TestCase(Testable):
|
||||
def addCleanup(self, function: Any, *args: Any, **kwargs: Any) -> None: ...
|
||||
def doCleanups(self) -> bool: ...
|
||||
def skipTest(self, reason: Any) -> None: ...
|
||||
def _formatMessage(self, msg: Optional[Text], standardMsg: Text) -> str: ... # undocumented
|
||||
def _formatMessage(self, msg: Text | None, standardMsg: Text) -> str: ... # undocumented
|
||||
def _getAssertEqualityFunc(self, first: Any, second: Any) -> Callable[..., None]: ... # undocumented
|
||||
|
||||
class FunctionTestCase(TestCase):
|
||||
def __init__(
|
||||
self,
|
||||
testFunc: Callable[[], None],
|
||||
setUp: Optional[Callable[[], None]] = ...,
|
||||
tearDown: Optional[Callable[[], None]] = ...,
|
||||
description: Optional[str] = ...,
|
||||
setUp: Callable[[], None] | None = ...,
|
||||
tearDown: Callable[[], None] | None = ...,
|
||||
description: str | None = ...,
|
||||
) -> None: ...
|
||||
def debug(self) -> None: ...
|
||||
def countTestCases(self) -> int: ...
|
||||
@@ -212,13 +209,13 @@ class TestSuite(Testable):
|
||||
|
||||
class TestLoader:
|
||||
testMethodPrefix: str
|
||||
sortTestMethodsUsing: Optional[Callable[[str, str], int]]
|
||||
sortTestMethodsUsing: Callable[[str, str], int] | None
|
||||
suiteClass: Callable[[List[TestCase]], TestSuite]
|
||||
def loadTestsFromTestCase(self, testCaseClass: Type[TestCase]) -> TestSuite: ...
|
||||
def loadTestsFromModule(self, module: types.ModuleType = ..., use_load_tests: bool = ...) -> TestSuite: ...
|
||||
def loadTestsFromName(self, name: str = ..., module: Optional[types.ModuleType] = ...) -> TestSuite: ...
|
||||
def loadTestsFromNames(self, names: List[str] = ..., module: Optional[types.ModuleType] = ...) -> TestSuite: ...
|
||||
def discover(self, start_dir: str, pattern: str = ..., top_level_dir: Optional[str] = ...) -> TestSuite: ...
|
||||
def loadTestsFromName(self, name: str = ..., module: types.ModuleType | None = ...) -> TestSuite: ...
|
||||
def loadTestsFromNames(self, names: List[str] = ..., module: types.ModuleType | None = ...) -> TestSuite: ...
|
||||
def discover(self, start_dir: str, pattern: str = ..., top_level_dir: str | None = ...) -> TestSuite: ...
|
||||
def getTestCaseNames(self, testCaseClass: Type[TestCase] = ...) -> List[str]: ...
|
||||
|
||||
defaultTestLoader: TestLoader
|
||||
@@ -232,12 +229,12 @@ class TextTestResult(TestResult):
|
||||
class TextTestRunner:
|
||||
def __init__(
|
||||
self,
|
||||
stream: Optional[TextIO] = ...,
|
||||
stream: TextIO | None = ...,
|
||||
descriptions: bool = ...,
|
||||
verbosity: int = ...,
|
||||
failfast: bool = ...,
|
||||
buffer: bool = ...,
|
||||
resultclass: Optional[Type[TestResult]] = ...,
|
||||
resultclass: Type[TestResult] | None = ...,
|
||||
) -> None: ...
|
||||
def _makeResult(self) -> TestResult: ...
|
||||
def run(self, test: Testable) -> TestResult: ... # undocumented
|
||||
@@ -245,10 +242,10 @@ class TextTestRunner:
|
||||
class SkipTest(Exception): ...
|
||||
|
||||
# TODO precise types
|
||||
def skipUnless(condition: Any, reason: Union[str, unicode]) -> Any: ...
|
||||
def skipIf(condition: Any, reason: Union[str, unicode]) -> Any: ...
|
||||
def skipUnless(condition: Any, reason: str | unicode) -> Any: ...
|
||||
def skipIf(condition: Any, reason: str | unicode) -> Any: ...
|
||||
def expectedFailure(func: _FT) -> _FT: ...
|
||||
def skip(reason: Union[str, unicode]) -> Any: ...
|
||||
def skip(reason: str | unicode) -> Any: ...
|
||||
|
||||
# not really documented
|
||||
class TestProgram:
|
||||
@@ -256,18 +253,18 @@ class TestProgram:
|
||||
def runTests(self) -> None: ... # undocumented
|
||||
|
||||
def main(
|
||||
module: Union[None, Text, types.ModuleType] = ...,
|
||||
defaultTest: Optional[str] = ...,
|
||||
argv: Optional[Sequence[str]] = ...,
|
||||
testRunner: Union[Type[TextTestRunner], TextTestRunner, None] = ...,
|
||||
module: None | Text | types.ModuleType = ...,
|
||||
defaultTest: str | None = ...,
|
||||
argv: Sequence[str] | None = ...,
|
||||
testRunner: Type[TextTestRunner] | TextTestRunner | None = ...,
|
||||
testLoader: TestLoader = ...,
|
||||
exit: bool = ...,
|
||||
verbosity: int = ...,
|
||||
failfast: Optional[bool] = ...,
|
||||
catchbreak: Optional[bool] = ...,
|
||||
buffer: Optional[bool] = ...,
|
||||
failfast: bool | None = ...,
|
||||
catchbreak: bool | None = ...,
|
||||
buffer: bool | None = ...,
|
||||
) -> TestProgram: ...
|
||||
def load_tests(loader: TestLoader, tests: TestSuite, pattern: Optional[Text]) -> TestSuite: ...
|
||||
def load_tests(loader: TestLoader, tests: TestSuite, pattern: Text | None) -> TestSuite: ...
|
||||
def installHandler() -> None: ...
|
||||
def registerResult(result: TestResult) -> None: ...
|
||||
def removeResult(result: TestResult) -> bool: ...
|
||||
|
||||
Reference in New Issue
Block a user