gh-108271, gh-108270: Argument Clinic: parameter aliases and deprecat… · python/cpython@01399a3 · GitHub
Skip to content

Commit 01399a3

Browse files
gh-108271, gh-108270: Argument Clinic: parameter aliases and deprecation (GH-155248)
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.
1 parent ce32912 commit 01399a3

11 files changed

Lines changed: 782 additions & 13 deletions

File tree

Lib/test/test_clinic.py

Lines changed: 195 additions & 0 deletions
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Argument Clinic: add support for parameter aliases.
2+
A keyword-only parameter with a default value which shares the C name of a
3+
preceding parameter declares an alternative name for it.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Argument Clinic: add support for deprecating a parameter with the ``[until
2+
X.Y]`` marker.
3+
Passing such argument emits a :exc:`DeprecationWarning`.

Modules/_testclinic.c

Lines changed: 73 additions & 0 deletions

0 commit comments

Comments
 (0)