Common: Ignore arg-type error in DIContainer.register()

This commit is contained in:
Mike Salvatore 2022-08-29 14:16:57 -04:00
parent 599676c496
commit b1f15b59f7
1 changed files with 7 additions and 2 deletions

View File

@ -35,10 +35,15 @@ class DIContainer:
:raises TypeError: If `concrete_type` is not a class, or not a subclass of `interface`
"""
if not inspect.isclass(concrete_type):
# Ignoring arg-type error because this if clause discovers that concrete_type is not the
# type that mypy expects.
formatted_type_name = DIContainer._format_type_name(
concrete_type.__class__ # type: ignore[arg-type]
)
raise TypeError(
"Expected a class, but received an instance of type "
f'"{DIContainer._format_type_name(concrete_type.__class__)}"; Pass a class, not an '
"instance, to register(), or use register_instance() instead"
f'"{formatted_type_name}"; Pass a class, not an instance, to register(), or use'
"register_instance() instead"
)
if not issubclass(concrete_type, interface):