From 2e5845a4c07e6df03e48cb5c94a12bd1872d40af Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Fri, 13 Mar 2026 21:17:27 +0000 Subject: [PATCH] typing: Correct type of TestCase.skipTest This raises an exception so we will never return. Correcting this allows type checkers to use the check for type narrowing. Signed-off-by: Stephen Finucane --- testtools/testcase.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/testtools/testcase.py b/testtools/testcase.py index d3929a97..a5dc8efd 100644 --- a/testtools/testcase.py +++ b/testtools/testcase.py @@ -23,7 +23,7 @@ import types import unittest from collections.abc import Callable, Iterator -from typing import TYPE_CHECKING, ParamSpec, TypeVar, cast, overload +from typing import TYPE_CHECKING, NoReturn, ParamSpec, TypeVar, cast, overload from unittest.case import SkipTest T = TypeVar("T") @@ -366,7 +366,7 @@ def patch(self, obj: object, attribute: str, value: object) -> None: def shortDescription(self) -> str: return self.id() - def skipTest(self, reason: str) -> None: # type: ignore[override] + def skipTest(self, reason: str) -> NoReturn: """Cause this test to be skipped. This raises self.skipException(reason). skipException is raised