diff --git a/spinn_utilities/overrides.py b/spinn_utilities/overrides.py index 70076256..02bb3271 100644 --- a/spinn_utilities/overrides.py +++ b/spinn_utilities/overrides.py @@ -133,8 +133,8 @@ def __is_similar_type(self, method_type, super_type, arg): return True # If one is generic they must be the exact same object - if (isinstance(method_type, _BaseGenericAlias) or - isinstance(super_type, _BaseGenericAlias)): + if (isinstance(method_type, (TypeVar, _BaseGenericAlias)) or + isinstance(super_type, (TypeVar, _BaseGenericAlias))): if arg == "return": if self._return_narrowing: return True @@ -172,8 +172,11 @@ def __is_similar_type(self, method_type, super_type, arg): f"Method {self._override_name} has {arg} typed as " f"{method_type} while super is typed as {super_type}. " f"For None imported types they must be exactly the same") - - return issubclass(method_type, super_type) + try: + return issubclass(method_type, super_type) + except TypeError as ex: + raise TypeError (f"Unable to subtype {super_type}" + f" {type(super_type)} for {arg}") from ex def __verify_method_types(self, method: Method): try: