-
Notifications
You must be signed in to change notification settings - Fork 130
FIX: importlib_resources-related edge cases
#406
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
base: main
Are you sure you want to change the base?
Conversation
importlib_resources-related edge casesimportlib_resources-related edge cases
importlib_resources-related edge casesimportlib_resources-related edge cases
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #406 +/- ##
==========================================
+ Coverage 87.56% 90.28% +2.71%
==========================================
Files 18 20 +2
Lines 1641 2080 +439
Branches 348 447 +99
==========================================
+ Hits 1437 1878 +441
- Misses 149 151 +2
+ Partials 55 51 -4
... and 4 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
importlib_resources-related edge casesimportlib_resources-related edge cases
Closes #405.
Summary
This fixes edge/corner cases which occur when
importlib.resourcesis superseded during runtime byimportlib_resources:importlib_resources >= 6, < 6.4,line_profilerfails to import becauseline_profiler.toml_config.ConfigSource.from_default()can no longer use the now-nonexistentimportlib.resources.path().importlib_resourcesis even older,line_profilergenerates aDeprecationWarningon import becauseimportlib_resources.path()was deprecated in favor ofimportlib_resources.files().(Such cases may happen e.g. when another package in the user's environment tries to be "smart" and replaces
importlib.resourceswithimportlib_resourcesin both theimportlibnamespace andsys.modules, via either explicit overwrites or tempering with the import machinery. Granted, this is probably a bad idea and most definitely not our problem, but the very fact that the issue exists shows that there may be a non-negligible amount of code out there which does this.)A test (
tests/test_toml_config.py::test_backported_importlib_resources()) has also been added to check thatline_profiler.toml_configoperates smoothly for:importlib.resourcesimportlib_resourcesversions:>= 6, < 6.4< 6Caveats
importlib_resourcesin the repo.line_profilerin a fresh venv where all the shenanigans withimportlib_resourcescan happen.Feel free to close if it's deemed that this is too much and we can just WONTFIX the original issue.