You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is now possible to deprecate passing keyword arguments for
keyword-or-positional parameters with Argument Clinic, using the new
'/ [from X.Y]' syntax.
(To be read as "positional-only from Python version X.Y")
Co-authored-by: Erlend E. Aasland <[email protected]>
Co-authored-by: Alex Waygood <[email protected]>
The generated code will now emit a :exc:`DeprecationWarning`
1983
-
when an :term:`argument` for the :term:`parameter` *b* is passed positionally.
1997
+
when an :term:`argument` for the :term:`parameter` *d* is passed positionally
1998
+
(e.g ``myfunc(1, 2, 3, 4, e=5)``) or an argument for the parameter *b* is
1999
+
passed by keyword (e.g ``myfunc(1, b=2, c=3, d=4, e=5)``).
1984
2000
C preprocessor directives are also generated for emitting
1985
-
compiler warnings if the ``* [from ...]`` line has not been removed
2001
+
compiler warnings if the ``[from ...]`` lines have not been removed
1986
2002
from the Argument Clinic input when the deprecation period is over,
1987
2003
which means when the alpha phase of the specified Python version kicks in.
1988
2004
@@ -1995,21 +2011,26 @@ Luckily for us, compiler warnings are now generated:
1995
2011
.. code-block:: none
1996
2012
1997
2013
In file included from Modules/foomodule.c:139:
1998
-
Modules/clinic/foomodule.c.h:139:8: warning: In 'foomodule.c', update parameter(s) 'a' and 'b' in the clinic input of 'mymod.myfunc' to be keyword-only. [-W#warnings]
1999
-
# warning "In 'foomodule.c', update parameter(s) 'a' and 'b' in the clinic input of 'mymod.myfunc' to be keyword-only. [-W#warnings]"
2014
+
Modules/clinic/foomodule.c.h:139:8: warning: In 'foomodule.c', update the clinic input of 'mymod.myfunc'. [-W#warnings]
2015
+
# warning "In 'foomodule.c', update the clinic input of 'mymod.myfunc'. [-W#warnings]"
2000
2016
^
2001
2017
2002
-
We now close the deprecation phase by making *b* keyword-only;
2003
-
replace the ``* [from ...]`` line above *b*
2004
-
with the ``*`` from the line above *c*::
2018
+
We now close the deprecation phase by making *a* positional-only and *c*
2019
+
keyword-only;
2020
+
replace the ``/ [from ...]`` line below *b* with the ``/`` from the line
2021
+
below *a* and the ``* [from ...]`` line above *d* with the ``*`` from
2022
+
the line above *e*::
2005
2023
2006
2024
/*[clinic input]
2007
2025
module foo
2008
2026
myfunc
2009
2027
a: int
2010
-
*
2011
2028
b: int
2029
+
/
2012
2030
c: int
2031
+
*
2032
+
d: int
2033
+
e: int
2013
2034
[clinic start generated output]*/
2014
2035
2015
2036
Finally, run ``make clinic`` to regenerate the Argument Clinic code,
0 commit comments