Skip to content

gh-108271, gh-108270: Argument Clinic: parameter aliases and deprecation - #155248

Open
serhiy-storchaka wants to merge 2 commits into
python:mainfrom
serhiy-storchaka:clinic-param-aliases
Open

gh-108271, gh-108270: Argument Clinic: parameter aliases and deprecation#155248
serhiy-storchaka wants to merge 2 commits into
python:mainfrom
serhiy-storchaka:clinic-param-aliases

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Aug 5, 2026

Copy link
Copy Markdown
Member

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.

Combining the two deprecates an alias, which renames a parameter:

a: object = None
*
[until 3.20] b as a: object = None

…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.
It re-emits the warnings which do not match, so the warning for the other
parameter was raised as an error.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant