-
Notifications
You must be signed in to change notification settings - Fork 131
FIX: DeprecationWarning emitted by how line_profiler.toml_config uses importlib.resources
#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
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
importlib_resources-related edge casesimportlib.resources-related edge cases
tests/test_toml_config.py
- Removed venv setup code
- Refactored `test_backported_importlib_resources()` into
`test_importlib_resources_deprecation()`, which now just uses the
vanilla `importlib.resources`;
test fails for Python 3.11 pre-PR, as it should
importlib.resources-related edge casesDeprecationWarning emitted by how line_profiler.toml_config uses importlib.resources
|
Sorry, was sleeping like a log, so I didn't see your message. Just gave it one last look, rewrote a wrong comment, and I think it's ready to go. Thanks for the review! |
Closes #405.
Summary
This fixes the edge cases which occur for Python 3.11 (and older patch versions of 3.12; see e.g.: python/cpython#116608; python/cpython#132206) where
line_profiler.toml_configemits aDeprecationWarning(example in pipeline) because we usedimportlib.resources.path(). Now the code is reworked to prefer the newerimportlib.resources.files()wherever available (i.e. not on Python 3.8).A test (
tests/test_toml_config.py::test_importlib_resources_deprecation()) is also added to ensure that the warning is not emitted; the test fails on Python 3.11 onmain, as it should.Acknowledgements
Thanks to @user202729 and @JostMigenda for correcting my mis-construal of the original issue and misconceptions about
importlib.resourcesand its history.Thanks to @Erotemic as always for discussions regarding general maintenance of the repo (versioning, legacy-version support, etc.), and probably later reviewing this PR ;)
Note
The PR has been significantly rewritten; see commit and edit histories.