Fix extras with underscores not matching hyphenated metadata#3727
Merged
gaborbernat merged 3 commits intotox-dev:mainfrom Feb 17, 2026
Merged
Fix extras with underscores not matching hyphenated metadata#3727gaborbernat merged 3 commits intotox-dev:mainfrom
gaborbernat merged 3 commits intotox-dev:mainfrom
Conversation
…#3433) Normalize extra names using canonicalize_name() when matching extras from tox.ini against extra markers in package metadata. This ensures that e.g. "snake_case" in tox.ini matches "snake-case" in wheel Provides-Extra headers and dependency markers. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
for more information, see https://pre-commit.ci
1b8c269 to
379551f
Compare
gaborbernat
approved these changes
Feb 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #3433 — extras with underscores in
tox.ini(e.g.snake_case) were not matching hyphenated extra names in package metadata (e.g.Provides-Extra: snake-case), causing their dependencies to be silently skipped.Root cause
dependencies_with_extras_from_markers()comparedtodo(from tox.ini extras) againstextra_markers(from metadata markers) using set intersection, but neither side was normalized. When setuptools normalizes underscores to hyphens in wheel metadata,"snake_case" & {"snake-case"}produces an empty set, skipping all dependencies for that extra.Fix
Normalize extra names using
canonicalize_name()(frompackaging.utils, already imported) at three points:todosetreq.extras— normalized when discovered during resolutionThis ensures underscore/hyphen equivalence throughout the resolution process, consistent with PEP 685.
Tests
Added three test cases:
test_extras_underscore_hyphen_matching— underscores in extras match hyphens in markerstest_extras_underscore_in_markers— hyphens in extras match underscores in markerstest_extras_normalization_with_recursive— recursive extras with underscore/hyphen mismatchAll existing tests pass (the
test_load_dependency_no_extraordering failure is pre-existing on main).