FIX: DeprecationWarning emitted by how line_profiler.toml_config uses importlib.resources#406
Merged
Erotemic merged 14 commits intopyutils:mainfrom Nov 20, 2025
Merged
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
Member
Collaborator
Author
|
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! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.