python / python/importlib_metadata
Accept `types.ModuleType` as a distribution identifier
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 142
- Forks
- 97
- PR merge metrics
- No merged PRs in 30d
Description
I have recently ran into the issue where the importable module did not come from the distribution metadata found by importlib.metadata. This was because the distribution modules were shadowed in sys.path, which can happen often in test environments.
It would be nice if we could pass a module to importlib.metadata.distribution(), and have it find the distribution where that module originates from, if any.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the importlib.metadata.distribution() entry point and inspect how distribution identifiers are resolved, with attention to types.ModuleType and shadowed modules in sys.path. Determine how the originating distribution should be found when a module is passed, including the no-distribution case. Done means a module can be accepted as an identifier and the behavior is covered by tests for shadowed modules.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100