Skip to content

Commit 8d3894c

Browse files
committed
typing: Make less use of ParamSpec
This is a partial revert of 1078647. mypy (and possibly others) are not able to correctly resolve a ParamSpec for an overridden method. This causes a lot of false positives when using assertRaises (as a function) on methods with overrides, which cannot be resolved except through `type: ignore` statements. In addition, it's often desirable to test functions with incorrect types to assert runtime validation. Given these two issues, it's easier to just drop the use of ParamSpec. Signed-off-by: Stephen Finucane <stephen@that.guru>
1 parent 08ec4e6 commit 8d3894c

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

testtools/testcase.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -577,18 +577,18 @@ def assertIsInstance( # type: ignore[override]
577577
def assertRaises(
578578
self,
579579
expected_exception: type[_E],
580-
callable: Callable[_P, _R],
581-
*args: _P.args,
582-
**kwargs: _P.kwargs,
580+
callable: Callable[..., Any],
581+
*args: Any,
582+
**kwargs: Any,
583583
) -> _E: ...
584584

585585
@overload
586586
def assertRaises(
587587
self,
588588
expected_exception: tuple[type[BaseException], ...],
589-
callable: Callable[_P, _R],
590-
*args: _P.args,
591-
**kwargs: _P.kwargs,
589+
callable: Callable[..., Any],
590+
*args: Any,
591+
**kwargs: Any,
592592
) -> BaseException: ...
593593

594594
@overload

0 commit comments

Comments
 (0)