Skip to content

Clarify prefix-match suffix errors#1188

Open
Sean-Kenneth-Doherty wants to merge 1 commit into
pypa:mainfrom
Sean-Kenneth-Doherty:codex/post-prefix-error
Open

Clarify prefix-match suffix errors#1188
Sean-Kenneth-Doherty wants to merge 1 commit into
pypa:mainfrom
Sean-Kenneth-Doherty:codex/post-prefix-error

Conversation

@Sean-Kenneth-Doherty
Copy link
Copy Markdown

@Sean-Kenneth-Doherty Sean-Kenneth-Doherty commented May 17, 2026

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_invalid
  • uv run --isolated --group test --with-editable . python -m pytest -q
  • uv run --isolated --with ruff==0.15.12 ruff check src/packaging/_parser.py tests/test_requirements.py
  • uv run --isolated --with ruff==0.15.12 ruff format --check src/packaging/_parser.py tests/test_requirements.py
  • uv 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.py
  • python -m compileall -q src/packaging/_parser.py tests/test_requirements.py
  • git diff --check origin/main...HEAD && git diff --check

@Sean-Kenneth-Doherty

This comment was marked as low quality.

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.

1 participant