update to solve other test

This commit is contained in:
Reagan Lee 2024-02-08 16:03:09 -08:00
parent 1b3ac3659e
commit 6e61340f91
1 changed files with 7 additions and 9 deletions

View File

@ -42,13 +42,11 @@ def recwarn() -> Generator["WarningsRecorder", None, None]:
@overload
def deprecated_call(
*, match: Optional[Union[str, Pattern[str]]] = ...
) -> "WarningsRecorder":
...
) -> "WarningsRecorder": ...
@overload
def deprecated_call(func: Callable[..., T], *args: Any, **kwargs: Any) -> T:
...
def deprecated_call(func: Callable[..., T], *args: Any, **kwargs: Any) -> T: ...
def deprecated_call(
@ -90,8 +88,7 @@ def warns(
expected_warning: Union[Type[Warning], Tuple[Type[Warning], ...]] = ...,
*,
match: Optional[Union[str, Pattern[str]]] = ...,
) -> "WarningsChecker":
...
) -> "WarningsChecker": ...
@overload
@ -100,8 +97,7 @@ def warns(
func: Callable[..., T],
*args: Any,
**kwargs: Any,
) -> T:
...
) -> T: ...
def warns(
@ -336,7 +332,9 @@ class WarningsChecker(WarningsRecorder):
@staticmethod
def _validate_message(wrn: Any) -> None:
if not isinstance(msg := wrn.message.args[0], str):
if type(wrn.message) is UserWarning and not isinstance(
msg := wrn.message.args[0], str
):
raise TypeError(
f"Warning message must be str, got {msg!r} (type {type(msg).__name__})"
)