fix(warnings-recorder): Add handling of rest

This commit is contained in:
Lesnek 2023-07-02 15:16:14 +02:00 committed by Milan Lesnek
parent 2706271f66
commit 7b7bd304aa
1 changed files with 5 additions and 0 deletions

View File

@ -217,6 +217,11 @@ class WarningsRecorder(warnings.catch_warnings): # type:ignore[type-arg]
__tracebackhide__ = True
raise AssertionError(f"{cls!r} not found in warning list")
(idx, best), *rest = matches
for i, w in rest:
if issubclass(w.category, best.category) and not issubclass(
best.category, w.category
):
idx, best = i, w
return self._list.pop(idx)
def clear(self) -> None: