Skip to content

Drop use of importlib_metadata #2054

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

mattwthompson
Copy link
Member

@mattwthompson mattwthompson commented May 22, 2025

importlib-metadata is a third-party package which backports features of importlib.metadata (which is in the standard library) to older Python versions. We were using it as a bridge while it was "provisional" but that ship has long passed.

This change is likely 3.10+ based on my reading of the docs, but I haven't pinned it down completely: https://docs.python.org/3/library/importlib.metadata.html

This was not declared as a dependency in test environments - it probably should have been - but is a requirement in packaging. This change would allow that to be dropped from the conda recipe.

Copy link

codecov bot commented May 22, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.60%. Comparing base (713cfa9) to head (9e2f04a).

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@@ -13,6 +13,7 @@
import logging
import os
import pathlib
from importlib.metadata import entry_points
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is arguably a style change but I will defend it on a few points

  • I question whether or not it makes sense to have standard library imports guarded
  • The code paths are pretty hot with respect to each module, i.e. almost all functionality that requires importing from these files will end up calling one of these code paths
  • It's a pretty quick import, not counting anything else that's already brought in by other imports
$ time python -c ""                                                                        16:11:52  ☁  stdlib-entry-points ☂ ✭
python -c ""  0.01s user 0.01s system 51% cpu 0.049 total
(bespokefit-test) [openff-toolkit]
$ time python -c "from importlib.metadata import entry_points"                             16:12:22  ☁  stdlib-entry-points ☂ ✭
python -c "from importlib.metadata import entry_points"  0.05s user 0.02s system 67% cpu 0.105 total

@mattwthompson mattwthompson marked this pull request as ready for review May 22, 2025 21:14
@mattwthompson mattwthompson requested a review from j-wags as a code owner May 22, 2025 21:14
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.

1 participant
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy