Skip to content

Infer tags from pyproject optional dependencies - #23691

Open
MaicoTimmerman wants to merge 2 commits into
pantsbuild:mainfrom
MaicoTimmerman:pyproject-toml-tags
Open

MaicoTimmerman wants to merge 2 commits into
pantsbuild:mainfrom
MaicoTimmerman:pyproject-toml-tags

Conversation

@MaicoTimmerman

@MaicoTimmerman MaicoTimmerman commented Oct 2, 2026 •

Copy link
Copy Markdown

Description
Associate requirements generated from project.optional-dependencies with their group names. Combine inferred tags with generator and override tags while preserving order and removing duplicates.

Wrap requirements from other parsers without inferred tags. Open to extension for Poetry dependency groups.

LLM notice:
Hand curated code and initial investigations with GPT‑5.6 Sol using Factory Droid harnass

Fixed #23690

Associate requirements generated from project.optional-dependencies with their
group names. Combine inferred tags with generator and override tags while
preserving order and removing duplicates.

Wrap requirements from other parsers without inferred tags to retain their
existing behavior.

Co-Authored-By: GPT‑5.6 Sol using Factory Droid harnass
Treat optional-dependency group tags as defaults, not mandatory metadata.
Without a tags override, combine and deduplicate generator tags and group
tags. When an override contains tags, use that value unchanged, including
an empty list to clear all default tags.

Check for the presence of the tags key rather than its truthiness so
tags=[] remains an intentional override. This keeps override behavior
consistent between optional and ordinary requirements and avoids forcing
inferred labels onto targets whose tags users explicitly configure.

Keep parsing separate from override handling: parsers carry inferred tags
in ParsedRequirement, and the shared generator applies field precedence.
Unlike the approach removed from PR pantsbuild#16932, parsing does not mutate the
overrides mapping. These tags are labels, not a lossless representation
of optional-dependency constraints for packaging metadata.

Extend the existing target-generation test to cover non-empty and empty
tag overrides while retaining multi-group inference coverage.

Validation: staged diff passes git diff --check. Pants tests and lint
could not run: bootstrap attempts encountered a shared-venv race, and
native bootstrap requires rustup, which is not on PATH.
@MaicoTimmerman

Copy link
Copy Markdown
Author

I'm hoping to get a review on this PR, would @Eric-Arellano / @stuhood have capacity for that? Since you both participated in the review of @bryanwweber's PR (#16932).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

python_requirements does not tag dependencies from project.optional-dependencies

2 participants