Fix #100: strip lines before parsing with Requirement() - #101
Merged
Conversation
packaging 26.3 rejects requirement strings with trailing whitespace. process_line() passes the raw line including its newline to Requirement(), the resulting InvalidRequirement is silently swallowed, and source packages are no longer commented out in the generated constraints.
packaging 26.3 made requirement parsing strict: a trailing newline now raises InvalidRequirement. process_line() parsed the raw line straight from file iteration, the error was silently swallowed, and source packages stayed pinned in the generated constraints. Parse the stripped line instead, and log unparseable lines at debug level so parser-behavior changes surface under -v instead of silently producing downstream resolver errors.
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.
Bug
With packaging >= 26.3,
Requirement()rejects strings with trailing whitespace.process_line()insrc/mxdev/processing.pyparses the raw line including its trailing newline; the raisedInvalidRequirementis swallowed by the bareexcept, so packages configured as sources are no longer commented out in the generated requirements/constraints, and pip/uv resolution fails downstream (see #100).Failing test
This PR first adds regression tests that pass lines with trailing
\n/\r\nthroughprocess_line()andresolve_dependencies()— they fail on packaging >= 26.3 with the current code.Next steps
Fixes #100