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:
parent
db09928ffa
commit
7f19432360
1 changed files with 11 additions and 4 deletions
|
|
@ -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')
|
||||
|
|
|
|||
Loading…
Reference in a new issue