Skip to content

fix: clarify "Extra argument from **args" as "from **TypedDict"#21127

Open
nuglifeleoji wants to merge 1 commit intopython:masterfrom
nuglifeleoji:fix/typeddict-extra-arg-message
Open

fix: clarify "Extra argument from **args" as "from **TypedDict"#21127
nuglifeleoji wants to merge 1 commit intopython:masterfrom
nuglifeleoji:fix/typeddict-extra-arg-message

Conversation

@nuglifeleoji
Copy link
Copy Markdown
Contributor

Fixes #20986.

When a TypedDict is unpacked with ** and contains keys the callee
does not accept, the error message was:

error: Extra argument "y" from **args for "func"

**args looks like a *args/**kwargs variable name, which is
confusing. Since this code path (too_many_arguments_from_typed_dict)
is only reached when the source is a TypedDict, the message is
updated to:

error: Extra argument "y" from **TypedDict for "func"

Changed mypy/messages.py and updated the four matching test fixtures
in test-data/unit/.

Made with Cursor

When a TypedDict is unpacked with ** and has extra keys that the
callee does not accept, the error message referred to "**args":

  Extra argument "y" from **args for "func"

The term "**args" is confusing because it looks like a *args/**kwargs
variable name.  Since the source is always a TypedDict (the function is
named `too_many_arguments_from_typed_dict`), the message now reads:

  Extra argument "y" from **TypedDict for "func"

Closes python#20986

Made-with: Cursor
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 1, 2026

Diff from mypy_primer, showing the effect of this PR on open source code:

discord.py (https://github.com/Rapptz/discord.py)
- discord/shard.py:380: error: Extra argument "shard_ids" from **args for "__init__" of "Client"  [misc]
+ discord/shard.py:380: error: Extra argument "shard_ids" from **TypedDict for "__init__" of "Client"  [misc]
- discord/ext/commands/help.py:1087: error: Extra argument "sort_commands" from **args for "__init__" of "HelpCommand"  [misc]
+ discord/ext/commands/help.py:1087: error: Extra argument "sort_commands" from **TypedDict for "__init__" of "HelpCommand"  [misc]
- discord/ext/commands/help.py:1378: error: Extra argument "sort_commands" from **args for "__init__" of "HelpCommand"  [misc]
+ discord/ext/commands/help.py:1378: error: Extra argument "sort_commands" from **TypedDict for "__init__" of "HelpCommand"  [misc]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"Extra argument ..." error of TypeDict should be more clear

1 participant