Skip to content

Commit d7f6f39

Browse files
authored
Fix for Python 3.10 (#193)
Makes GreenWithEnvy work again. Fixes errors like Traceback (most recent call last): File "/Users/user/projects/injector/injector_test.py", line 1398, in test_newtype_integration_works injector = Injector([configure]) File "/Users/user/projects/injector/injector/__init__.py", line 904, in __init__ self.binder.install(module) File "/Users/user/projects/injector/injector/__init__.py", line 573, in install instance(self) File "/Users/user/projects/injector/injector_test.py", line 1396, in configure binder.bind(UserID, to=123) File "/Users/user/projects/injector/injector/__init__.py", line 474, in bind self._bindings[interface] = self.create_binding(interface, to, scope) File "/Users/user/projects/injector/injector/__init__.py", line 578, in create_binding provider = self.provider_for(interface, to) File "/Users/user/projects/injector/injector/__init__.py", line 640, in provider_for raise UnknownProvider('couldn\'t determine provider for %r to %r' % (interface, to)) injector.UnknownProvider: couldn't determine provider for injector_test.UserID to 123 Fixes GH-192
1 parent bbaac17 commit d7f6f39

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

injector/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ def _is_specialization(cls: type, generic_class: Any) -> bool:
699699

700700

701701
def _punch_through_alias(type_: Any) -> type:
702-
if getattr(type_, '__qualname__', '') == 'NewType.<locals>.new_type':
702+
if type(type_).__module__ == 'typing' and type(type_).__name__ == 'NewType':
703703
return type_.__supertype__
704704
else:
705705
return type_

0 commit comments

Comments
 (0)