lib.Types.LoadTypes: Loosen type_filter type

In LoadTypes' constructor, allow the type_filter parameter to be of type Sequence[type[Any]] instead of list[type[T]]. a) Sequence is more generic than list, and b) with T instead of Any, trying to instantiate with an abstract class has mypy complain:

# E: Only concrete class can be given where "type[MyClass]" is expected [type-abstract]

- type_filter: list[type[T]] = [], + type_filter: Sequence[type[Any]] | None = None,

Not that this makes mypy complain that it needs an annotation at the places where LoadTypes is used.

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2026-06-13 12:51:36 +02:00
commit fd008b0a73
Signed by: Jan Lindemann
GPG key ID: 3750640C9E25DD61
2 changed files with 7 additions and 4 deletions

View file

@ -137,7 +137,7 @@ class App: # export
log(DEBUG, '-------------- Running: >' + ' '.join(sys.argv) + '<')
cmd_classes = LoadTypes(
cmd_classes: LoadTypes[AbstractCmd] = LoadTypes(
modules if modules else ['__main__'],
type_name_filter = name_filter,
type_filter = [AbstractCmd], # type: ignore[type-abstract]