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 pkg resources import #647

Closed
wants to merge 4 commits into from
Closed

Fix pkg resources import #647

wants to merge 4 commits into from

Conversation

ldallmayr
Copy link

Description

The use of pkg_resources is deprecated in favor of its importlib equivalents. Running the pre-commit hook with Python 3.12 fails because pkg_resources cannot be found.

ModuleNotFoundError: No module named 'pkg_resources'

Related Issue

#646

Motivation and Context

This pull request fixes the error ModuleNotFoundError: No module named 'pkg_resources' when ran by pre-commit

How Has This Been Tested?

Ran all tests with pytest locally

Failed tests

FAILED tests/profiles/test_profile.py::TestProfileInheritance::test_module_file_inheritance - prospector.profiles.exceptions.ProfileNotFound
FAILED tests/profiles/test_profile.py::TestProfileInheritance::test_module_inheritance - prospector.profiles.exceptions.ProfileNotFound
FAILED tests/tools/pyroma/test_pyroma_tool.py::test_forced_include - assert 12 == 10

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • My change requires a change to the dependencies
  • I have updated the dependencies accordingly
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@ldallmayr ldallmayr marked this pull request as ready for review November 26, 2023 17:16
@ldallmayr
Copy link
Author

The resources.files api was introduced in Python 3.9, therefore I had to use the function resources.read_text. This function has been marked deprecated since Python 3.11. As soon as the minimum requirement for prospector is Python 3.9 one could change to the resources.files api.

@ldallmayr ldallmayr closed this Nov 26, 2023
@ldallmayr
Copy link
Author

importlib.metadata was introduced in Python 3.8, so either the backports of those tools have to be used or this change has to be postponed until the minimum requirement is greater than Python 3.8

@Pierre-Sassoulas
Copy link
Collaborator

Python 3.9 is not yet EOL, we should probably use both with a if sys.version_info(...) guard until then.

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.

2 participants