feat: 10865 fix v2 for codecov

This commit is contained in:
Volodymyr Kochetkov 2024-02-05 18:48:13 +02:00
parent 9c4ffb5207
commit 48ded39b77
1 changed files with 8 additions and 5 deletions

View File

@ -332,8 +332,11 @@ class WarningsChecker(WarningsRecorder):
# Check warnings has valid argument type (#10865).
wrn: warnings.WarningMessage
for wrn in self:
if isinstance(wrn.message, Warning):
if not isinstance(msg := wrn.message.args[0], str):
raise TypeError(
f"Warning message must be str, got {msg!r} (type {type(msg).__name__})"
)
self._validate_message(wrn)
@staticmethod
def _validate_message(wrn: Any) -> None:
if not isinstance(msg := wrn.message.args[0], str):
raise TypeError(
f"Warning message must be str, got {msg!r} (type {type(msg).__name__})"
)