Clarify prefix-match suffix errors#1188
Open
Sean-Kenneth-Doherty wants to merge 1 commit into
Open
Conversation
This comment was marked as low quality.
This comment was marked as low quality.
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
Improve the parser error for requirement specifiers such as
name == 1.0a1.*, where prefix matching uses a valid==or!=operator but is not allowed after a pre-release, post-release, developmental release, or local version label.Previously these cases fell through to the generic message that
.*can only be used with==or!=, even though the operator was already valid. The new message points to the actual invalid part of the version.Addresses the error-message portion of #831.
Validation
uv run --isolated --group test --with-editable . python -m pytest -q tests/test_requirements.py::TestRequirementParsing::test_error_when_prefix_match_is_used_after_version_suffix tests/test_requirements.py::TestRequirementParsing::test_error_when_prefix_match_is_used_incorrectly tests/test_specifiers.py::TestSpecifier::test_specifiers_invaliduv run --isolated --group test --with-editable . python -m pytest -quv run --isolated --with ruff==0.15.12 ruff check src/packaging/_parser.py tests/test_requirements.pyuv run --isolated --with ruff==0.15.12 ruff format --check src/packaging/_parser.py tests/test_requirements.pyuv run --isolated --with mypy==1.20.2 --with hypothesis --with nox --with orjson --with pytest<9 --with tomli --with tomli_w --with types-invoke --with httpx --with-editable . mypy src/packaging/_parser.py tests/test_requirements.pypython -m compileall -q src/packaging/_parser.py tests/test_requirements.pygit diff --check origin/main...HEAD && git diff --check