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

🐛 Fix: Flexibly import _no_init, _no_init_or_replace_init from typing #48

Merged

Conversation

fennel-akunesh
Copy link
Contributor

@fennel-akunesh fennel-akunesh commented Dec 1, 2023

This PR resolves the following error:

  File ".../.venv/lib/python3.9/site-packages/rodi/__init__.py", line 31, in <module>
    from typing import _no_init_or_replace_init as _no_init
ImportError: cannot import name '_no_init_or_replace_init' from 'typing' (/Users/apkunesh/.pyenv/versions/3.9.7/lib/python3.9/typing.py)

which I'm encountering with Python 3.9.7 😞

@lucas-labs mentions that _no_init ➡️ _no_init_or_replace_init in Python 3.9(.0?), but I think it must be between 3.9.7 and 3.9.13. An alternative which would solve my problem is just modifying line 24 of __init__.py to if sys.version_info >= (3, 10): # pragma: no cover

Thanks for making / maintaining such a cool package!

Resolves issue #49

@fennel-akunesh
Copy link
Contributor Author

Update: I should also be able to resolve this issue by bumping my own Python version to 3.9.13. I'll leave this open, as it could still be an issue for folks pinned to earlier sub-versions of Python 3.9.

@lucas-labs
Copy link
Contributor

Update: I should also be able to resolve this issue by bumping my own Python version to 3.9.13. I'll leave this open, as it could still be an issue for folks pinned to earlier sub-versions of Python 3.9.

Nice catch! That explains why the github action passed for 3.9!

I downloaded both 3.8 and 3.9 to check when it changed but I downloaded 3.9.18 and wrongly assumed it changed from >= 3.9.
My bad 🤭... I forgot we were dealing with an internal function that can change over minor releases. The _ was there for a reason haha

I think yours is a reasonable solution. Let's see what @RobertoPrevato thinks

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (2f9d7a1) 99.82% compared to head (78a678b) 99.82%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #48   +/-   ##
=======================================
  Coverage   99.82%   99.82%           
=======================================
  Files           2        2           
  Lines         565      565           
=======================================
  Hits          564      564           
  Misses          1        1           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@RobertoPrevato
Copy link
Member

Hi @fennel-akunesh and @lucas-labs
Thank You for helping - and sorry for missing this bug, we were indeed bitten by the tests with 3.9 passing.
I like it more indeed with the try catch version; it is more in line with EAFP.
I'm willing to merge this change. Any last thoughts on this?

@RobertoPrevato RobertoPrevato merged commit 3e35824 into Neoteroi:main Dec 2, 2023
6 checks passed
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

Successfully merging this pull request may close these issues.

5 participants