python / python/importlib_metadata

Accept `types.ModuleType` as a distribution identifier

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

Nobody has claimed this yet.

enhancement feature help wanted
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

  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.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.