Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3.10 regression: injector.UnknownProvider: couldn't determine provider #192

Closed
leinardi opened this issue Nov 6, 2021 · 17 comments
Closed

Comments

@leinardi
Copy link

leinardi commented Nov 6, 2021

Some users of Fedora 35 reported that an app I developed doesn't work anymore after upgrading from Fedora 43.

After some investigation it seems related to the upgrade to Python 3.10. I was able to reproduce the same issue on Ubuntu 21.10 after installing Python 3.10 and running the app on a venv that uses it.

This is the relevant traceback:

Traceback (most recent call last):
  File "/home/leinardi/Workspace/gitlab/gwe/venv/lib/python3.10/site-packages/injector/__init__.py", line 658, in get_binding
    return self._get_binding(interface, only_this_binder=is_scope)
  File "/home/leinardi/Workspace/gitlab/gwe/venv/lib/python3.10/site-packages/injector/__init__.py", line 653, in _get_binding
    raise KeyError
KeyError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/leinardi/Workspace/gitlab/gwe/.pycharm/gwe", line 43, in <module>
    from gwe import __main__
  File "/home/leinardi/Workspace/gitlab/gwe/gwe/__main__.py", line 33, in <module>
    from gwe.model.current_fan_profile import CurrentFanProfile
  File "/home/leinardi/Workspace/gitlab/gwe/gwe/model/__init__.py", line 19, in <module>
    from gwe.model.overclock_profile import OverclockProfile
  File "/home/leinardi/Workspace/gitlab/gwe/gwe/model/overclock_profile.py", line 29, in <module>
    OVERCLOCK_PROFILE_CHANGED_SUBJECT = INJECTOR.get(OverclockProfileChangedSubject)
  File "/home/leinardi/Workspace/gitlab/gwe/venv/lib/python3.10/site-packages/injector/__init__.py", line 952, in get
    binding, binder = self.binder.get_binding(interface)
  File "/home/leinardi/Workspace/gitlab/gwe/venv/lib/python3.10/site-packages/injector/__init__.py", line 667, in get_binding
    binding = self.create_binding(interface)
  File "/home/leinardi/Workspace/gitlab/gwe/venv/lib/python3.10/site-packages/injector/__init__.py", line 582, in create_binding
    provider = self.provider_for(interface, to)
  File "/home/leinardi/Workspace/gitlab/gwe/venv/lib/python3.10/site-packages/injector/__init__.py", line 644, in provider_for
    raise UnknownProvider('couldn\'t determine provider for %r to %r' % (interface, to))
injector.UnknownProvider: couldn't determine provider for gwe.di.OverclockProfileChangedSubject to None

The code that is triggering the issue is this one:

OVERCLOCK_PROFILE_CHANGED_SUBJECT = INJECTOR.get(OverclockProfileChangedSubject)

where OverclockProfileChangedSubject is defined as:

OverclockProfileChangedSubject = NewType('OverclockProfileChangedSubject', Subject)

This code worked fine for several versions of Python and version 3.10 seems to be the only one affected.

@leinardi
Copy link
Author

leinardi commented Dec 3, 2021

Is there any know workaroud (beside downgrading Python) for this issue?

@leinardi
Copy link
Author

@jstasiak any suggestion?

@marvic2409
Copy link

Yep this issue is also affecting me.

@jstasiak
Copy link
Collaborator

No suggestions, sorry, pull requests fixing this are welcome though.

PS. Please provide the exact Python and Injector versions where this happens, for clarity.

@gardotd426
Copy link

This is now also an issue on Arch Linux, as it's been moved to 3.10 as well. It's going to be an issue everywhere eventually.

@Lamieur
Copy link

Lamieur commented Dec 16, 2021

PS. Please provide the exact Python and Injector versions where this happens, for clarity.

On Fedora 35 I've tested:

  • Python 3.10.0 and Injector 0.18.4 (latest release)
  • Python 3.10.0 and current git master branch of Injector,
  • Python 3.10.1 (currently in updates-testing) and current git of Injector.

All these with gwe's git.

Every combination gives the same result.

@d4mler
Copy link

d4mler commented Dec 17, 2021

Same problem on Arch.

@WickedLukas
Copy link

I found this issue with a similar error message and appearently someone also found a solution for it : #175
Unfortunately I am not knowledgeable enough, but maybe someone else can review it.

@Lamieur
Copy link

Lamieur commented Dec 18, 2021

No, #175 is unrelated. I had the same thought as you, so when I was testing with git branch of injector (my previous comment), I have in fact rebuilt injector with #188 - that didn't do a thing for our case. It was faster to check than to think on what Injector does or what Subject is, but apparently it's not "generic", whatever that is! ;)

Anyways, this is completely different, a regression caused by something in Python 3.10 for something which worked before.

(or RxPY 3.2.0, as that was on 3.1.1 in Fedora 34. 3.1.1 doesn't build with Python 3.10 so I can't check :))

@gardotd426
Copy link

RxPY was on 3.2.0 on Arch before Arch moved to 3.10, and this issue wasn't present, so it's not RxPY.

@Lamieur
Copy link

Lamieur commented Dec 18, 2021

Good to know, I wanted to confirm but couldn't easily, thanks :)

@leinardi
Copy link
Author

@jstasiak please have a look at #193

@leinardi
Copy link
Author

@jstasiak Thank you for merging the fix 👍

Is there an ETA for the next release that will include this fix?

@gardotd426
Copy link

@leinardi I will say that I installed python-injector-git from the AUR (I had to edit the PKGBUILD because the writer of it has it in a broken state but it was a quick fix) and after installing that, GWE works perfectly.

@abend-arg
Copy link

Just did exactly the same as @gardotd426. Edited the PKGBUILD in order to solve the issue. GWE started to work again. The hotfix did it.

@gardotd426
Copy link

It's no longer needed, after I reported the issue, the maintainer updated the PKGBUILD so all is good now. No editing of PKGBUILDs necessary. So anyone not able to wait can just use python-injector-git from the AUR (if they're on an Arch-based distro). Beyond that, I'd say this is probably venturing into off-topic territory from here on out

@jstasiak
Copy link
Collaborator

@jstasiak Thank you for merging the fix 👍

Is there an ETA for the next release that will include this fix?

No worries. It's just been released as version 0.19.0, enjoy.

jstasiak pushed a commit that referenced this issue Jun 14, 2022
NoInject[T] = None has the runtime typehint NoInject[T] | None,
instead of the expected NoInject[T | None].
NoInject[str] = 'blarb' works as expected

Resolves #192
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants