Repository navigation
Align more error messages with CPython 3.14.5 #7928
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
4ec7e61
Cleanup
ShaharNaveh b5b2c92
Merge remote-tracking branch 'upstream/main' into ruff-error-msg
ShaharNaveh fc0c75b
fixes after merge
ShaharNaveh 95fb51f
Fixed repeated keyword error message
ShaharNaveh e3ab7bc
fix `not` error message
ShaharNaveh 97a5659
Trailing comma
ShaharNaveh b0f24c4
fix more
ShaharNaveh eb83c13
Fix more
ShaharNaveh a14e54b
More
ShaharNaveh 3ea23c9
Merge remote-tracking branch 'upstream/main' into ruff-error-msg
ShaharNaveh bfec825
clippy
ShaharNaveh 91147a8
unmark passing tests
ShaharNaveh 666443d
Fix more
ShaharNaveh 42005e7
Fix more
ShaharNaveh 0327d32
cfg gate
ShaharNaveh 73cb383
Unmark more passing tests
ShaharNaveh 6a94654
Fix logic error
ShaharNaveh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
More
- Loading branch information
commit a14e54b00e613079a0690321b06c601499013418
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: RustPython/RustPython
Length of output: 2004
🏁 Script executed:
Repository: RustPython/RustPython
Length of output: 867
🏁 Script executed:
Repository: RustPython/RustPython
Length of output: 335
🌐 Web query:
CPython 3.14 "named parameters must follow bare *" syntax error message💡 Result:
In CPython, the SyntaxError message “named parameters must follow bare ” is raised when you put a bare asterisk () in a function parameter list in a way that does not allow any following keyword-only parameters. In other words, the grammar requires that “” be followed by keyword-only parameter definitions (e.g., “def f(, kwonly):...”); if “” is the last token (no keyword-only parameters after it), CPython reports this syntax error. Example that triggers it: >>> def f():... pass... SyntaxError: named arguments must follow bare * [1][2] Why this happens: a bare “” marks the transition to keyword-only parameters, so “” must be immediately followed by at least one keyword-only parameter (or otherwise the signature is incomplete/invalid). [1][2] Notes: - The error text you cited can appear in tooling with slightly different wording (“named arguments” vs “named parameters”), but the underlying CPython syntax rule is the same: after a bare “*”, you must have keyword-only parameters. [3][1] If you want, paste the exact CPython 3.14 source code snippet (and how you’re running it—REPL/file) and I can identify the specific invalid signature form that produces the error in that case.
Citations:
*to an empty parameter list gets a wrong error message saying "arguments" instead of "parameters" python/mypy#21003🌐 Web query:
CPython "var-positional parameter cannot have default value" error message💡 Result:
In CPython/Python, you cannot give a default value to a var-positional parameter (*args). What you likely ran into is the generic “non-default/required parameter follows default” class of syntax checks: required parameters (those without defaults) must not appear after parameters that have defaults, and the *args position determines which parameters are “required”. In particular, a parameter list like
def f(a=1, *args, b): ...is rejected becausebis required but appears after a defaulted parameter, and the parser surfaces it as the “parameter without a default follows parameter with a default” SyntaxError [1]. A related CPython issue also discusses how this error applies to keyword-only parameters and how signatures involving*argscan appear confusing in terms of whether a later parameter is treated as positional or keyword-only [2]. If your concrete code snippet is something likedef func(*args=...):then the correct mental model is simply: the*argsparameter is always the “collect remaining positional arguments” slot, so it’s not legal syntax to attach a default initializer to it (unlike normal named positional-or-keyword parameters).Citations:
SyntaxError: parameter without a default follows parameter with a defaultis inaccurate python/cpython#129545*argspython/cpython#129810🌐 Web query:
CPython "at least one parameter must precede /" syntax error💡 Result:
The SyntaxError text “at least one parameter must precede /” is raised when you use the positional-only separator “/” in a function parameter list without any parameters before it (i.e., an invalid signature like def f(/,...):...). Python’s syntax rule for positional-only parameters uses “/” to separate positional-only parameters (to the left) from the rest (to the right) [1][2]. PEP 570 defines that all parameters before “/” are positional-only, and that “/” is the delimiter between the left-hand parameter group and following parameters [1]. Therefore, the delimiter cannot appear as the very first element of the parameter list; at least one parameter must appear on the left side of “/”. Evidence in the official docs: - The tutorial section explains that positional-only parameters are placed before a “/”, and that “/” logically separates them from the rest of the parameters [2]. - PEP 570 similarly states that parameters left of “/” are treated as positional-only, implying “/” can only function as a separator after that left-hand parameter group [1]. If you share the exact snippet you’re running (including the full def statement), I can pinpoint precisely which part triggers the error.
Citations:
🌐 Web query:
CPython 3.14 test_syntax.py "named parameters" "var-positional parameter"💡 Result:
In CPython’s syntax tests, a “var-positional” parameter is the
*namepart of a function signature. CPython rejects giving it a default value:SyntaxError: var-positional parameter cannot have default valueis asserted inLib/test/test_syntax.py(e.g.def foo(a,*b=3,c): ...). [1] This is consistent with how the grammar defines*args-style parameters: a var-positional parameter collects an arbitrary number of positional arguments, so it cannot simultaneously represent a single optional value via a default. The syntax test explicitly treats*b=3(and alsolambda a,*b=3,c: ...) as a syntax error. [1] Notes on “named parameters” (keyword arguments): what you can name in calls is separate from whether you may put a default on the*argsparameter in the function definition. The test coverage for keyword argument behavior is different from the parser rule that disallows defaults on var-positional parameters. [1] Authoritative source inspected: CPython’s own test fileLib/test/test_syntax.py, which includes the exact SyntaxError cases for*b=3/var-positional parameter cannot have default value. [1]Citations:
🌐 Web query:
site:github.com cpython "named parameters must follow bare" 3.14💡 Result:
In CPython 3.14, “named parameters must follow bare *” refers to a syntax rule for function parameter lists: once you include a bare * (meaning “start of keyword-only parameters”), any following parameters that are allowed after that * must be keyword-only parameters, and those keyword-only parameters must appear in the form “name[=default]” (i.e., named parameters). If you put something other than a keyword-only named parameter after the bare *, the parser raises a SyntaxError with that message. This message is part of CPython’s general validation of parameter lists around the * / keyword-only boundary (PEP 3102 describes the semantics of keyword-only parameters introduced via the bare * marker). [1] Relevant CPython issues discuss adjacent wording and related parser constraints around this exact error message: - CPython issue reports an error message specifically about “Named parameters must follow bare *” when defining a signature like
def func(*): ...and notes the message should be corrected from “arguments” to “parameters” (mypy reproduces the CPython-derived message text). [2] - CPython issues discuss the accuracy and phrasing of parameter-related SyntaxError messages in this area (e.g., “non-default argument follows default argument” vs “parameter”). These indicate that CPython has been actively refining the precise text of such syntax errors, including those near the * / keyword-only syntax. [3][4] If you want, paste the exact function definition you’re compiling/running and I can tell you which specific token after*triggers the “must follow bare *” SyntaxError in CPython 3.14.Citations:
*to an empty parameter list gets a wrong error message saying "arguments" instead of "parameters" python/mypy#21003SyntaxError: parameter without a default follows parameter with a defaultis inaccurate python/cpython#129545🌐 Web query:
site:raw.githubusercontent.com/python/cpython "named parameters must follow bare" test_syntax💡 Result:
I couldn’t find any authoritative technical source that actually contains the specific phrase “named parameters must follow bare test_syntax”. The web results I retrieved look unrelated (for example, Python docs about doctest and a sqlite3 note about named placeholders), and none describe a rule with that wording. If you meant a common Python syntax error rule, the relevant one is usually phrased as: positional/non-default arguments must come before default arguments (e.g., you can get “SyntaxError: non-default argument follows default argument”). However, that’s not the same as “named parameters must follow bare … test_syntax”, and I did not find a matching source for your exact query. Please paste the exact code snippet and the exact error message (and the language/tool name), and I’ll re-research specifically for that scenario.
Citations:
🌐 Web query:
site:raw.githubusercontent.com/python/cpython "at least one parameter must precede" test_syntax💡 Result:
The phrase "at least one parameter must precede" is not a standard error message in Python's core libraries or common testing frameworks like pytest. Based on a search of Python's source code and documentation, this specific string does not appear as a defined error message. It is possible that the phrase is: 1. A misremembered or slightly altered version of a different error message (e.g., related to argument parsing or function signatures). 2. A specific error message from a third-party library or a custom application not indexed in general technical documentation. 3. A misunderstanding of a technical requirement, such as the rule in Python's typing module where a Union must contain at least one type [1], or requirements for positional arguments in functions [2]. If you are encountering this error in a specific context, please check the stack trace to identify the library or module raising the exception, as it is likely specific to that codebase.
Citations:
🌐 Web query:
CPython github.com/python/cpython "named parameters must follow bare *" OR "var-positional parameter cannot have default value" OR "at least one parameter must precede"💡 Result:
In Python, function parameter syntax is strictly governed by rules designed to ensure unambiguous argument binding. The error messages you referenced correspond to specific violations of these rules: 1. Named parameters must follow bare *: This error occurs when you attempt to define a parameter without a default value after a bare * (which denotes the start of keyword-only parameters) without providing a default value, or more generally, when the structure of keyword-only arguments is violated [1][2]. A bare * indicates that all subsequent parameters must be passed as keyword arguments [3]. 2. Var-positional parameter cannot have default value: A var-positional parameter (defined as *args) collects any number of positional arguments into a tuple [4]. Because it consumes all remaining positional arguments, it cannot have a default value; assigning one would be syntactically meaningless as there is no scenario where the parameter would be "missing" to trigger the default [4]. 3. At least one parameter must precede: This error typically arises when using the positional-only parameter separator (/). The / must be preceded by at least one positional-only parameter [5]. Similarly, if you were to use other markers incorrectly, the parser requires them to be placed in a valid context relative to other parameters [6]. In summary, Python requires that: - Positional-only parameters (before /) must be defined first [3][7]. - Positional-or-keyword parameters follow [3][7]. - Var-positional parameters (*args) collect remaining positional arguments [4]. - Keyword-only parameters (after * or *args) must be passed by name [1][3]. - Var-keyword parameters (kwargs) collect remaining keyword arguments [8]. Violating the order of these categories or attempting to assign defaults to variadic parameters results in a SyntaxError during the parsing of the function definition [4][9][5].
Citations:
🌐 Web query:
CPython compile.c "named parameters must follow" OR "named arguments must follow"💡 Result:
In CPython the message is
"named arguments must follow bare *"(not “named parameters must follow …”), and it’s not emitted fromcompile.c.Where it lives / how to find it:
Grammar/python.gram, e.g.invalid_star_etc/invalid_lambda_star_etcwhich raisesRAISE_SYNTAX_ERROR("named arguments must follow bare *"). (git.joshthomas.dev)Python/ast.c, where the AST builder raisesast_error(..., "named arguments must follow bare *")when*appears in a parameter list without any following keyword-only parameters. (chromium.googlesource.com)Background/history: this exact SyntaxError wording dates back to the introduction of keyword-only parameters (PEP 3102 era); see the historical tracker discussion (migrated to GitHub) showing the same message. (bugs.python.org)
Citations:
🌐 Web query:
CPython grammar "var-positional parameter" "default value" error message💡 Result:
In CPython grammar, the syntax for a var-positional parameter is “” followed by a parameter name, optionally with a type annotation, and there is no provision for a default value for that parameter. The grammar rule for star_etc only allows “'' param_no_default …” or “'' param_no_default_star_annotation …” (and other forms like ','), i.e., no “'=' expression” is allowed on that branch. [1] When you write code like
def f(*args='Hello'): ..., CPython raises a SyntaxError with the message “var-positional argument cannot have default value”. This is documented in a CPython issue that includes the exact error text. [2] So the key points are: 1) Grammar:*args(var-positional) is defined withoutdefault(no “= expression” for that form). [1] 2) Error: trying to attach a default to*argsyields “SyntaxError: var-positional argument cannot have default value”. [2] If you need the exact grammar section name in the official docs: the var-positional part appears understar_etcin the full grammar specification. [1]Citations:
def func(*args='Hello'): passanddef func(**kwargs='Hello'): passshould explain more clearly python/cpython#137786🌐 Web query:
CPython 3.14 syntax error messages "parameter" changes from "argument"💡 Result:
In CPython 3.14, there is (or was) a parser error-message wording inconsistency around function definition “parameter lists”: some SyntaxError messages say “argument” when the formal construct is a “parameter”. A CPython issue documents the proposed/desired change to use “parameter” / “parameters” wording (e.g., “duplicate parameter …” and “named parameters …”) and notes that this kind of change is only made in the latest version to reduce breakage and may not be backported.[1] Specifically, the issue reports these current messages and proposed replacements: - It reports
def func(param, param): ...raisingSyntaxError: duplicate argument 'param' in function definition, and suggests it should beSyntaxError: duplicate parameter 'param' in function definition.[1] - It reportsdef func(param1, param2, *): ...raisingSyntaxError: named arguments must follow bare *, and suggests it should beSyntaxError: named parameters must follow bare *.[1] So the answer to your query is: yes—CPython’s 3.14 SyntaxError strings for certain function-parameter-list problems have been observed/targeted for replacement of “argument” with “parameter”, but the CPython issue indicates the wording change is treated as a last-mile polish and may be limited to newer versions (not necessarily backported broadly).[1] (Your query mentions “today is 2026-05-19”; the issue is dated 2025 and discusses behavior around current development/later versions, not necessarily guaranteeing that every 3.14.x build already uses the new wording.)Citations:
argumentinstead ofparameterpython/cpython#133379🌐 Web query:
CPython "at least one" "parameter" "precede" "/" positional-only💡 Result:
In CPython/Python syntax, the forward-slash marker “/” for positional-only parameters must be preceded by at least one parameter (i.e., you cannot start a function signature with “/”). This is expressed by the rule that “All parameters left of the / are treated as positional-only”, and by the grammar/usage rule that “at least one argument must precede /” (and also that “/ may appear only once”). [1][2] Practical consequence: a signature like def f(/, x): is invalid, while def f(x, /): is valid. [1][2]
Citations:
Align error messages with CPython 3.14 by using
parameterinstead ofargument.CPython 3.14 has updated these error messages to use "parameter" wording for consistency. Update the three occurrences across lines 115–132 and 175–180.
Suggested changes
🤖 Prompt for AI Agents