Skip to content

Commit

Permalink
Fix for Python 3.10 (#193)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
openglfreak committed Dec 20, 2021
1 parent bbaac17 commit d7f6f39
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion injector/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ def _is_specialization(cls: type, generic_class: Any) -> bool:


def _punch_through_alias(type_: Any) -> type:
if getattr(type_, '__qualname__', '') == 'NewType.<locals>.new_type':
if type(type_).__module__ == 'typing' and type(type_).__name__ == 'NewType':
return type_.__supertype__
else:
return type_
Expand Down

0 comments on commit d7f6f39

Please sign in to comment.