Skip to content

Conversation

@pulkitgoyal56
Copy link

@pulkitgoyal56 pulkitgoyal56 commented Oct 28, 2025

Summary

Prefer stdlib importlib.resources to locate sacred/data/mime.types and fall back to pkg_resources only if necessary. This avoids UserWarning about pkg_resources deprecation when importing sacred.observers.mongo.

./.venv/lib/python3.13/site-packages/sacred/dependencies.py:11: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.

This adds support for Python 3.13/14.

Rationale

pkg_resources is deprecated as an API; importlib.resources is the modern replacement in the stdlib and available in most supported Python versions.

This change is backwards-compatible and preserves previous behavior by falling back to pkg_resources when importlib.resources is not available.

Files Changed

sacred/observers/mongo.py

Testing

Smoke-tested import and mime detection locally.

Follow-up

Consider removing other uses of pkg_resources (e.g., sacred/dependencies.py).

@thequilo
Copy link
Collaborator

thequilo commented Nov 6, 2025

Hi @pulkitgoyal56! Thanks for addressing this issue! It seems like your modification is not backward-compatible, can you fix it for Python <=3.9?

Also, we use black formatting, please run the pre-commit hook. It will fix the test_pre_commit test case.

@pulkitgoyal56
Copy link
Author

Hey, thanks for your reply. I'll fix it and apply the formatting.

@pulkitgoyal56 pulkitgoyal56 marked this pull request as draft November 6, 2025 15:07
@pulkitgoyal56
Copy link
Author

I'd like to finish this issue, but keeping support for Python <= 3.9 is just hacky. Given that they have reached EOL, maybe this is not really required?

But if you still want to keep support for it, I'll cancel this pull request.

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