python-poetry / python-poetry/poetry

Validate dependency extras

Open
#6,319 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

kind/feature status/triage
Dominant language
Python
Stars
34.3k
Forks
2.5k
Avg merge
2d 19h
Merged PRs (30d)
30

Description

  • I have searched the issues of this repo and believe that this is not a duplicate.
  • I have searched the documentation and believe that my question is not covered.

Feature Request

Hello!

I've got a small improvement proposal - validation of dependency extras. This arose for me from https://github.com/python-poetry/poetry-plugin-export/issues/107, a bug specifically in export, but caused by my pyproject.toml not being entirely valid, an example is in https://github.com/mikicz/poetry-export-keyerror. The pyproject.toml in question has a single dependency with three different extras required, however two of them are not valid. Poetry itself does not warn about this at all.

IMO ideally the improvements would happen in two paths:

Adding dependency

When adding a dependency, the add command could check that the extras are valid for that dependency and warn if extra is invalid. This would prevent typos and such causing head-aches.

Currently no warning is given:

$ poetry add moto[iam,lambda,s3]
Using version ^4.0.1 for moto

Updating dependencies
Resolving dependencies... (0.3s)

Package operations: 22 installs, 0 updates, 0 removals
[...]
Existing dependencies

During lock or update commands Poetry could validate extras defined in pyproject.toml and warn about invalid dependencies. This would prevent two issues

  • typos when defining manually in pyproject.toml
  • new version of dependency no longer providing given extra

Currently no warning is given:

$ poetry lock
Updating dependencies
Resolving dependencies... (0.8s)

Writing lock file

Contributor guide

Open the contributing guide

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 with the add command and the lock/update commands described in the issue, tracing where dependency extras are resolved. Check how each command currently handles the example invalid extras, then add validation warnings for both newly added and existing dependencies. Done means invalid extras are reported in both paths without affecting valid dependencies.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.