Repository navigation
remove unreachable pkg_resources fallback from example tests - #153
Merged
Merged
Conversation
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.
What
tests/test_examples.pyimportedimportlib.resources.filesinside atry/except ImportErrorthat fell back topkg_resources.resource_filename, and_run_examplebranched on aUSING_IMPORTLIBflag. This removes the fallback and the flag, leaving a plainfrom importlib.resources import filesand the singlefiles('nagiosplugin.examples') / programform.Why
importlib.resources.fileshas been in the standard library since 3.9, so theexcept ImportErrorbranch cannot be reached on any supported interpreter.pkg_resourceswas removed from setuptools in 82.0.0, so the fallback would not import on a current setuptools anyway.This was the only use of
pkg_resourcesin the repository; the only remaining mention is the historical 1.4.0 changelog entry (#50).Verified locally (macOS)
uv run tox -e py311,py312,py313,py314,py315: all pass (140 passed, 1 skipped per environment).uv run tox -e ruff: exits non-zero on the same 137 findings thatmainalready has; this change adds none.files('nagiosplugin.examples') / 'check_load.py'resolves to an existing file.Left to CI
test_check_loadskips on non-Linux platforms, so the local runs did not executecheck_load.pythrough_run_example. The Linux CI matrix on this PR is the real check for that test.Not included
The same file has a second fallback,
try: import unittest2 as unittest/except ImportError: import unittest. It is left untouched here and is a candidate for a separate cleanup.