Skip to content
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

Don't map actual **kwargs to formal *args #6096

Merged
merged 2 commits into from
Dec 20, 2018
Merged

Don't map actual **kwargs to formal *args #6096

merged 2 commits into from
Dec 20, 2018

Conversation

JukkaL
Copy link
Collaborator

@JukkaL JukkaL commented Dec 20, 2018

The fix was originally proposed by @elazarg.

Fixes #1969.

The fix was originally proposed by @elazarg.

Fixes #1969.
Copy link
Member

@ilevkivskyi ilevkivskyi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! I have just one test suggestion.


m = {} # type: Mapping[str, object]
f(**m)
[builtins fixtures/dict.pyi]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe also add the second test case mentioned in the issue? The one with:

def b(arg: str='', **kw: int) -> None:
    pass

Copy link
Member

@sobolevn sobolevn Nov 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Three years later we have a similar error: #11583

But, calling b (in this case) with b(**{'x': 1}) will work in runtime. It will result in arg = '' (default value) and kw = {'x': 1}.
Not sure why this was explictly forbidden.

Do you remember why this was a problem?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My PR with the alternative solution: #11589

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.

**kwargs checked against wrong type with defaults or *args
3 participants