Skip to content

PEP 3102 and PEP 570 should say **Keyword-Only Parameters** instead of **Keyword-Only Arguments** #133438

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
hyperkai opened this issue May 5, 2025 · 8 comments
Labels
docs Documentation in the Doc dir

Comments

@hyperkai
Copy link

hyperkai commented May 5, 2025

PEP 3102 and PEP 570 say Keyword-Only Arguments but they should say Keyword-Only Parameters because a keyword-only parameter is the parameter which only accepts a keyword argument.

Actually, PEP 570 correctly says Positional-Only Parameters because a positional-only parameter is the parameter which only accepts a positional argument.

Glossary explains a keyword argument and positional argument.

Linked PRs

@hyperkai hyperkai added the docs Documentation in the Doc dir label May 5, 2025
@picnixz
Copy link
Member

picnixz commented May 5, 2025

PEPs are historical documents that won't get updates like that and thus they may contain typos or errors. We don't have a policy of publishing erratas though (@AA-Turner maybe it'd be good to have an errata policy?)

@picnixz picnixz added the pending The issue will be closed if no feedback is provided label May 5, 2025
@AA-Turner
Copy link
Member

Is there anywhere that the error appears in the current documentation? As Ben says, as a
rule we don't tend to update Final PEPs.

A

@StanFromIreland
Copy link
Contributor

All occurrences in Cpython:

Modules/_testcapi/getargs.c:/* test PyArg_ParseTupleAndKeywords keyword-only arguments */
Doc/c-api/arg.rst:   keyword-only.  Currently, all keyword-only arguments must also be optional
Doc/whatsnew/3.0.rst:* :pep:`3102`: Keyword-only arguments.  Named parameters occurring
Doc/whatsnew/3.0.rst:  argument list, but you do have keyword-only arguments.
Doc/whatsnew/3.4.rst:keyword-only arguments.  It also provides some efficiency improvements.
Doc/whatsnew/3.4.rst:* Defaults for keyword-only arguments are now evaluated *after* defaults for
Doc/library/unittest.mock.rst:           Added two keyword-only arguments to the reset_mock function.
Doc/library/exceptions.rst:   The optional *name* and *path* keyword-only arguments
Doc/library/functions.rst:   There are two optional keyword-only arguments. The *key* argument specifies
Doc/library/functions.rst:   There are two optional keyword-only arguments. The *key* argument specifies
Doc/library/inspect.rst:      Example: print all keyword-only arguments without default values:
Doc/library/collections.rst:       :ref:`keyword-only arguments <keyword-only_parameter>`.
Doc/library/stdtypes.rst:      (:ref:`keyword-only arguments <keyword-only_parameter>`):
Doc/library/ast.rst:   * ``kw_defaults`` is a list of default values for keyword-only arguments. If
Doc/library/pickle.rst:   class requires keyword-only arguments.  Otherwise, it is recommended for
Doc/library/subprocess.rst:   be set by passing them as keyword-only arguments.
Doc/tutorial/controlflow.rst:Keyword-Only Arguments
Misc/HISTORY:  missing keyword-only arguments. Patch by Jeremiah Lowin.
Misc/HISTORY:- Issue #20619: Give the AST nodes of keyword-only arguments a column and line
Misc/HISTORY:- Issue #14607: Fix keyword-only arguments which started with ``__``.
Misc/HISTORY:- Issue #12356: When required positional or keyword-only arguments are not
Misc/HISTORY:- PEP 3102: keyword-only arguments.
Misc/NEWS.d/3.5.0a3.rst:of instances of classes whose __new__ method takes keyword-only arguments.
Misc/NEWS.d/3.12.0a1.rst:missing keyword-only arguments.
Misc/NEWS.d/3.10.0b1.rst:will become keyword-only arguments to the generated __init__.
Misc/NEWS.d/3.5.0a1.rst:keyword-only arguments. Patch by Jeremiah Lowin.
Lib/_ast_unparse.py:        # varargs, or bare '*' if no varargs but keyword-only arguments present
Lib/_ast_unparse.py:        # keyword-only arguments
Lib/pydoc_data/topics.py:      keyword (keyword-only arguments):
Lib/test/test_positional_only_arg.py:        with self.assertRaisesRegex(TypeError, r"missing 2 required keyword-only arguments: 'd' and 'e'"):
Lib/test/test_positional_only_arg.py:                                               r"\(and 2 keyword-only arguments\) were given"):
Lib/test/test_extcall.py:    TypeError: f() takes 0 positional arguments but 3 positional arguments (and 2 keyword-only arguments) were given
Lib/test/test_extcall.py:    TypeError: f() missing 5 required keyword-only arguments: 'a', 'b', 'c', 'd', and 'e'
Lib/test/test_keywordonlyarg.py:        # more than 255 keyword-only arguments, should compile ok
Lib/inspect.py:    'args' is the list of argument names. Keyword-only arguments are
Lib/inspect.py:    # keyword-only arguments
Lib/inspect.py:        Parameter objects (keyword-only arguments are in the same order
Lib/inspect.py:                # a '*' to separate keyword-only arguments
Lib/copyreg.py:    keyword-only arguments to be pickled correctly.
Python/ast_unparse.c:    /* vararg, or bare '*' if no varargs but keyword-only arguments present */
Python/ast_unparse.c:    /* keyword-only arguments */

There are some that should be fixed.

@terryjreedy
Copy link
Member

I think we should generally continue the policy of leaving PEPs as historical docs. In particular, I don't think this issue should be an exception. So either 1) this issue should be closed and a new one opened, with Stan's list copied over; or 2) the title and initial comment should be revised (but then following comments, including this, would not fit). I suggest 1).

@terryjreedy
Copy link
Member

For the revised or new issue: in some cases, '-only' should be removed, resulting in 'keyword argument'; in others, s/argument/parameter, as proposed.

@StanFromIreland
Copy link
Contributor

  1. the title and initial comment should be revised (but then following comments, including this, would not fit). I suggest 1).

IMO either is fine as for 2), the comments can be marked as "resolved" (or similar) hiding them.

serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this issue Jun 5, 2025
serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this issue Jun 5, 2025
@serhiy-storchaka
Copy link
Member

There are many other cases of misusing "argument" and "parameter".

#135160 fixes the use of the terms "argument" and "parameter" in the documentation. A following PR will fix also error messages and output.

@encukou
Copy link
Member

encukou commented Jun 5, 2025

FWIW, I'd keep the phrase keyword-only argument in (most) places where we're really talking about arguments, like “This function accepts a keyword-only foo argument.”
The only is redundant, but it makes it clearer that you can't pass the value positionally.

@picnixz picnixz removed the pending The issue will be closed if no feedback is provided label Jun 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir
Projects
Status: Todo
Development

No branches or pull requests

7 participants