python / python/importlib_metadata

Add a `Distribution.editable` property

Open
#510 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

Recently, when trying to check if a distribution is editable, I noticed doing so using the current API is very un-ergonomic. This information is available via the direct_url.json file of PEP 610, which is exposed in Distribution.origin.

When url refers to a local directory, the dir_info key MUST be present as a dictionary with the following key:

editable (type: boolean): true if the distribution was installed in editable mode, false otherwise. If absent, default to false.

So, to check if the distribution is editable, we can check Distribution.origin.dir_info.editable, however, Distribution.origin might be None (no direct_url.json), and Distribution.origin.dir_info might not be set (url in direct_url.json in not a local directory), which.

is_editable = distribution.origin and distribution.origin.dir_info and distribution.origin.dir_info.editable
try:
    is_editable = distribution.origin.dir_info.editable
except AttributeError:
    is_editable = False

It would be helpful to have this information available via a more ergonomic API.

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 by tracing the Distribution API and its origin data, then review PEP 610's direct_url.json rules for dir_info and editable. Done means the new property exposes a boolean and returns false when origin or editable information is absent.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 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.