← 输入框|github.com|刷新
Skip to content

Fix empty-input validation in the prefixed version example - #514

Merged
tomschr merged 2 commits into
python-semver:masterfrom
anticipate218:fix/empty-prefixed-version-example
Nov 16, 2026
Merged

tomschr merged 2 commits into
python-semver:masterfrom
anticipate218:fix/empty-prefixed-version-example

Conversation

@anticipate218

Copy link
Copy Markdown
Contributor

The documented SemVerWithVPrefix subclass indexes the first character before checking its prefix. Empty input therefore raises IndexError, and the inherited is_valid("") also raises instead of returning False.

Use startswith(("v", "V")) so empty input follows the existing ValueError path. Add 12 regression cases against the actual documented subclass, covering invalid/empty input and valid full or abbreviated versions. The change is scoped to the documentation example and its tests.

Validation on Windows, CPython 3.13.5, using the frozen uv.lock with all extras:

  • New regressions on the unchanged example: 2 failed, 10 passed; the fixed example passes all 12.
  • Full tests and doctests: 549 passed.
  • Changed-file Ruff lint/format checks and strict Sphinx HTML build: passed.
  • Repository-wide Ruff still reports 159 existing diagnostics (161 on the baseline), with no new diagnostics. Mypy reports the same missing typing information for fast_semver_rs_backend on both trees.
  • Other Python versions and operating systems were not run locally.

AI assistance: OpenAI Codex (GPT-6) investigated the issue, implemented this change, and ran the checks above.

@tomschr tomschr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @anticipate218, your contribution improves the code! 👍

Ready to be merged to master. 🚀

@tomschr
tomschr merged commit 49a14e0 into python-semver:master Nov 16, 2026
17 checks passed
@anticipate218

Copy link
Copy Markdown
Contributor Author

Thank you for reviewing and merging this! I'm glad the fix is useful.

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