diff --git a/injector/__init__.py b/injector/__init__.py index 7fcfcba..d74fe2a 100644 --- a/injector/__init__.py +++ b/injector/__init__.py @@ -700,7 +700,13 @@ def _is_specialization(cls: type, generic_class: Any) -> bool: def _punch_through_alias(type_: Any) -> type: - if type(type_).__module__ == 'typing' and type(type_).__name__ == 'NewType': + if ( + sys.version_info < (3, 10) + and getattr(type_, '__qualname__', '') == 'NewType..new_type' + or sys.version_info >= (3, 10) + and type(type_).__module__ == 'typing' + and type(type_).__name__ == 'NewType' + ): return type_.__supertype__ else: return type_