fix(dependency_groups): collect InvalidRequirement instead of leaking it#1302
Open
r266-tech wants to merge 1 commit into
Open
fix(dependency_groups): collect InvalidRequirement instead of leaking it#1302r266-tech wants to merge 1 commit into
r266-tech wants to merge 1 commit into
Conversation
In DependencyGroupResolver._parse_group, the str-item branch built Requirement(item) and let InvalidRequirement propagate raw -- the only branch in that loop that does not route through the error collector. A single malformed PEP 508 string therefore (a) escaped the documented aggregated '[dependency-groups] data for <group> was malformed' ExceptionGroup as a bare InvalidRequirement, and (b) short-circuited the loop, dropping every sibling error already collected for that group. Wrap the requirement parse in errors.collect(InvalidRequirement) (the collector's documented in-loop helper) so malformed-data diagnostics are uniform and complete. Add a regression test asserting a bad requirement string is reported together with a co-occurring sibling error.
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.
Follow-up to #1248. In
DependencyGroupResolver._parse_group, the string-item branch buildsRequirement(item)and letsInvalidRequirementpropagate raw — the only branch in that loop that doesn't route through the error collector.A single malformed PEP 508 requirement string therefore:
if errors.errors: return ()is never reached and any error collected earlier in the same loop (an invalid object{}, a non-stringinclude-group, an unknown item type) is lost; and[dependency-groups] data for <group> was malformedExceptionGroupas a bareInvalidRequirement.#1248 collected the adjacent include-group
TypeErrorin the same loop but left this branch raw. The fix wraps the parse inerrors.collect(InvalidRequirement)— the collector's own documented in-loop helper (InvalidRequirementsubclassesValueError, so it's collectible) — so all malformed-group diagnostics are uniform and complete.lookup()/resolve()document the aggregated-ExceptionGroupcontract (not:raises InvalidRequirement), so this aligns the string branch with the port's actual contract rather than changing it. The regression test asserts a bad requirement string is now reported together with a co-occurring sibling error instead of dropping it.