refactor(version): use explicit keywords in __replace__ - #1378
Open
henryiii wants to merge 1 commit into
Open
Conversation
Replace the **kwargs / Unpack[TypedDict] signature with explicit keyword-only parameters and a sentinel default. Unknown keyword arguments now raise TypeError instead of being silently ignored, the signature is introspectable, and the _VersionReplace TypedDict and typing_extensions Unpack import are no longer needed. None keeps its meaning of clearing a field. Assisted-by: ClaudeCode:claude-fable-5
henryiii
marked this pull request as ready for review
August 10, 2026 05:40
shinzoxD
approved these changes
Aug 11, 2026
shinzoxD
left a comment
There was a problem hiding this comment.
Verified head b5c3f08. The explicit sentinel-backed keyword-only signature preserves no-op identity, clearing semantics, normalization/validation, and copy.replace behavior while rejecting unknown keywords. Locally, tests/test_version.py completed with 51,524 passed; Nox's final nonzero status was only the expected repository-wide 100% coverage gate after selecting one test file. git diff --check is clean, and all upstream CI checks are green. The versionchanged 26.4 note documents the observable behavior.
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.
Using an explicit sentinel instead of kw-only args.
🤖 AI text below 🤖
Benefits:
TypeError. Before, a typo such asv.__replace__(prerelease=("a", 1))was silently ignored.help(), IDEs) without the**kwargsindirection. The docstring signature line is kept so autodoc does not render the sentinel default._VersionReplaceTypedDict and thetyping_extensions.Unpackimport are removed.Nonekeeps its meaning of clearing a field, and the no-changereturn selfshort-circuit is unchanged. The pre-3.13replace()test shim no longer uses aProtocol, since a method with named keyword-only parameters does not satisfy a**kwargsprotocol.