From cdea0098e631abcc34e49a5a7173eb6fded93783 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Wed, 21 Sep 2022 13:46:42 +0100 Subject: [PATCH 1/2] Revert "Use Callable[..., Any] instead of Callable[..., object] in unittest (#8399)" This reverts commit 1a2914adc503105bcd1ef87c6dee5a5d6f88089e. --- stdlib/doctest.pyi | 4 ++-- stdlib/unittest/case.pyi | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/stdlib/doctest.pyi b/stdlib/doctest.pyi index 719551eb77de..579f2481978c 100644 --- a/stdlib/doctest.pyi +++ b/stdlib/doctest.pyi @@ -199,8 +199,8 @@ class DocTestCase(unittest.TestCase): self, test: DocTest, optionflags: int = ..., - setUp: Callable[[DocTest], Any] | None = ..., - tearDown: Callable[[DocTest], Any] | None = ..., + setUp: Callable[[DocTest], object] | None = ..., + tearDown: Callable[[DocTest], object] | None = ..., checker: OutputChecker | None = ..., ) -> None: ... def runTest(self) -> None: ... diff --git a/stdlib/unittest/case.pyi b/stdlib/unittest/case.pyi index 200f8dbaea23..b9dfdb523a8b 100644 --- a/stdlib/unittest/case.pyi +++ b/stdlib/unittest/case.pyi @@ -65,7 +65,7 @@ else: ) -> bool | None: ... if sys.version_info >= (3, 8): - def addModuleCleanup(__function: Callable[_P, Any], *args: _P.args, **kwargs: _P.kwargs) -> None: ... + def addModuleCleanup(__function: Callable[_P, object], *args: _P.args, **kwargs: _P.kwargs) -> None: ... def doModuleCleanups() -> None: ... if sys.version_info >= (3, 11): @@ -158,7 +158,7 @@ class TestCase: self, expected_exception: type[BaseException] | tuple[type[BaseException], ...], expected_regex: str | bytes | Pattern[str] | Pattern[bytes], - callable: Callable[..., Any], + callable: Callable[..., object], *args: Any, **kwargs: Any, ) -> None: ... @@ -174,7 +174,7 @@ class TestCase: def assertWarns( # type: ignore[misc] self, expected_warning: type[Warning] | tuple[type[Warning], ...], - callable: Callable[_P, Any], + callable: Callable[_P, object], *args: _P.args, **kwargs: _P.kwargs, ) -> None: ... @@ -187,7 +187,7 @@ class TestCase: self, expected_warning: type[Warning] | tuple[type[Warning], ...], expected_regex: str | bytes | Pattern[str] | Pattern[bytes], - callable: Callable[_P, Any], + callable: Callable[_P, object], *args: _P.args, **kwargs: _P.kwargs, ) -> None: ... @@ -273,9 +273,9 @@ class TestCase: def id(self) -> str: ... def shortDescription(self) -> str | None: ... if sys.version_info >= (3, 8): - def addCleanup(self, __function: Callable[_P, Any], *args: _P.args, **kwargs: _P.kwargs) -> None: ... + def addCleanup(self, __function: Callable[_P, object], *args: _P.args, **kwargs: _P.kwargs) -> None: ... else: - def addCleanup(self, function: Callable[_P, Any], *args: _P.args, **kwargs: _P.kwargs) -> None: ... + def addCleanup(self, function: Callable[_P, object], *args: _P.args, **kwargs: _P.kwargs) -> None: ... if sys.version_info >= (3, 11): def enterContext(self, cm: AbstractContextManager[_T]) -> _T: ... @@ -283,7 +283,7 @@ class TestCase: def doCleanups(self) -> None: ... if sys.version_info >= (3, 8): @classmethod - def addClassCleanup(cls, __function: Callable[_P, Any], *args: _P.args, **kwargs: _P.kwargs) -> None: ... + def addClassCleanup(cls, __function: Callable[_P, object], *args: _P.args, **kwargs: _P.kwargs) -> None: ... @classmethod def doClassCleanups(cls) -> None: ... @@ -316,9 +316,9 @@ class TestCase: class FunctionTestCase(TestCase): def __init__( self, - testFunc: Callable[[], Any], - setUp: Callable[[], Any] | None = ..., - tearDown: Callable[[], Any] | None = ..., + testFunc: Callable[[], object], + setUp: Callable[[], object] | None = ..., + tearDown: Callable[[], object] | None = ..., description: str | None = ..., ) -> None: ... def runTest(self) -> None: ... From f0779ee23f0b3f562d91682f25b62aa6604d4683 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Wed, 21 Sep 2022 13:49:28 +0100 Subject: [PATCH 2/2] Also revert #8373 --- stdlib/unittest/case.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/unittest/case.pyi b/stdlib/unittest/case.pyi index b9dfdb523a8b..ad31ad298310 100644 --- a/stdlib/unittest/case.pyi +++ b/stdlib/unittest/case.pyi @@ -145,7 +145,7 @@ class TestCase: def assertRaises( # type: ignore[misc] self, expected_exception: type[BaseException] | tuple[type[BaseException], ...], - callable: Callable[..., Any], + callable: Callable[..., object], *args: Any, **kwargs: Any, ) -> None: ...