Skip to content

fix: validate include-group items as strings and accept Mapping items - #46

Merged
henryiii merged 2 commits into
pypa:mainfrom
henryiii:fix/include-group-validation
Aug 5, 2026
Merged

fix: validate include-group items as strings and accept Mapping items#46
henryiii merged 2 commits into
pypa:mainfrom
henryiii:fix/include-group-validation

Conversation

@henryiii

@henryiii henryiii commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

🤖 AI text below 🤖

Two small validation fixes in _parse_group:

  • A non-str include-group value (e.g. {"include-group": 5}) failed with a cryptic TypeError inside name normalization. It now raises a clear TypeError: Invalid include-group value, must be a string: ..., which the lint CLI catches.
  • Include items were checked with isinstance(item, dict), which rejected other Mapping types such as types.MappingProxyType, even though the type hints accept Mapping. The check now uses collections.abc.Mapping.

Regression tests and a changelog entry added.

The include-group value was not checked to be a str, so a non-str
value raised a cryptic TypeError deep in name normalization; it now
raises a clear ValueError. Also, include items were checked with
isinstance(item, dict), rejecting other Mapping types such as
MappingProxyType; the check now uses collections.abc.Mapping to
match the type hints.

Assisted-by: ClaudeCode:claude-fable-5
Comment thread src/dependency_groups/_implementation.py Outdated
A wrong type is a TypeError, not a ValueError; the lint CLI catches
both. Also add a changelog entry for both fixes.

Assisted-by: ClaudeCode:claude-fable-5
@henryiii
henryiii marked this pull request as ready for review August 5, 2026 22:20
@henryiii
henryiii merged commit 4026025 into pypa:main Aug 5, 2026
5 checks passed
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.

2 participants