lib.Types: Exception log beautification

Be a bit more verbose if a broken (i.e. non-class-type) type filter
parameter gets passed.

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2026-07-15 17:46:27 +02:00
commit 7f19432360
Signed by: Jan Lindemann
GPG key ID: 3750640C9E25DD61

View file

@ -7,7 +7,7 @@ import sys
from typing import TYPE_CHECKING, Generic, Iterable, TypeVar
from .log import OFF, log, parse_log_level
from .log import ERR, OFF, log, parse_log_level
if TYPE_CHECKING:
from collections.abc import Iterator
@ -43,7 +43,7 @@ class LoadTypes(Types[T]): # export
def __init__(
self,
mod_names: list[str],
mod_names: Iterable[str],
type_name_filter: str | None = None,
type_filter: Sequence[type[Any]] | None = None,
debug_level = None,
@ -99,8 +99,15 @@ class LoadTypes(Types[T]): # export
continue
if self.__type_filter:
for tp in self.__type_filter:
if issubclass(c, tp):
break
try:
if issubclass(c, tp):
break
except Exception as e:
log(
ERR,
f'Failed to check if {c} inherits from {tp} ({e})'
)
raise
self._debug(f'o "{name}" is not of type {tp}')
else:
self._debug(f'o "{name}" doesn\'t match type filter')