fix: clarify "Extra argument from **args" as "from **TypedDict"#21127
Open
nuglifeleoji wants to merge 1 commit intopython:masterfrom
Open
fix: clarify "Extra argument from **args" as "from **TypedDict"#21127nuglifeleoji wants to merge 1 commit intopython:masterfrom
nuglifeleoji wants to merge 1 commit intopython:masterfrom
Conversation
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
Contributor
|
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]
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #20986.
When a
TypedDictis unpacked with**and contains keys the calleedoes not accept, the error message was:
**argslooks like a*args/**kwargsvariable name, which isconfusing. Since this code path (
too_many_arguments_from_typed_dict)is only reached when the source is a
TypedDict, the message isupdated to:
Changed
mypy/messages.pyand updated the four matching test fixturesin
test-data/unit/.Made with Cursor