gh-108271, gh-108270: Argument Clinic: parameter aliases and deprecation - #155248
Open
serhiy-storchaka wants to merge 2 commits into
Open
gh-108271, gh-108270: Argument Clinic: parameter aliases and deprecation#155248serhiy-storchaka wants to merge 2 commits into
serhiy-storchaka wants to merge 2 commits into
Conversation
…and deprecation
A parameter can be given an alternative name by declaring a keyword-only
parameter with a default value which shares the C name of a preceding one:
a: object = None
*
b as a: object = None
Only one of the alternative names can be used in a call; passing both is
a TypeError. An alias is not shown in the signature.
The `[until X.Y]` prefix marks a parameter which will be removed in that
release. Passing it emits a DeprecationWarning, and the generated code
warns at compile time when that release is reached. A deprecated
parameter must have a default value, and only the last positional-only
parameters can be deprecated, because removing one would leave no way to
pass those which follow it.
serhiy-storchaka
requested review from
AA-Turner,
ericsnowcurrently and
erlend-aasland
as code owners
August 5, 2026 15:22
serhiy-storchaka
requested review from
gpshead
and removed request for
erlend-aasland
August 5, 2026 15:35
It re-emits the warnings which do not match, so the warning for the other parameter was raised as an error.
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.
A parameter can be given an alternative name by declaring a keyword-only parameter with a default value which shares the C name of a preceding one:
Only one of the alternative names can be used in a call; passing both is a
TypeError. An alias is not shown in the signature.The
[until X.Y]prefix marks a parameter which will be removed in that release. Passing it emits aDeprecationWarning, and the generated code warns at compile time when that release is reached. A deprecated parameter must have a default value, and only the last positional-only parameters can be deprecated, because removing one would leave no way to pass those which follow it.Combining the two deprecates an alias, which renames a parameter: