Accept `types.ModuleType` as a distribution identifier

Open
#511 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
python
Domain
tooling

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.

Description

enhancement feature help wanted

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.

Dominant language
Python
Stars
142
Forks
97
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from python/importlib_metadata

All issues in python/importlib_metadata

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.