Skip to content

Do not crash in "too few arguments" error with anon argument #3313

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 5 commits into from
May 3, 2017

Conversation

sixolet
Copy link
Collaborator

@sixolet sixolet commented May 3, 2017

This should fix #3312

Copy link
Member

@gvanrossum gvanrossum left a comment

Choose a reason for hiding this comment

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

It's fine as is but if you have a sec here are some style nits.

@@ -2039,3 +2039,8 @@ l: List[int] = make_list()

bad = make_list() # E: Need type annotation for variable
[builtins fixtures/list.pyi]

[case testAnonymousArgumentError]

Copy link
Member

Choose a reason for hiding this comment

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

Don't need this blank line.

mypy/messages.py Outdated
@@ -575,7 +575,7 @@ def too_few_arguments(self, callee: CallableType, context: Context,
msg = 'Missing positional argument'
else:
msg = 'Missing positional arguments'
if callee.name and diff:
if callee.name and [d for d in diff if d is not None]:
Copy link
Member

Choose a reason for hiding this comment

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

This could just be if callee.name and any(diff): ... Or if that's too cryptic use any(d is not None for d in diff).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Heh. Should be all, thanks for the collaborative catch.

@sixolet
Copy link
Collaborator Author

sixolet commented May 3, 2017

... wow, who'd have thunk I'd get something so simple wrong so many times.

@gvanrossum gvanrossum merged commit 09e7b12 into python:master May 3, 2017
@gvanrossum
Copy link
Member

... wow, who'd have thunk I'd get something so simple wrong so many times.

It's the release pressure. Happens to me all the time. Also, this logic is pretty subtle. And thanks for fixing this under pressure!

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.

Crash when a function with anonymous args is missing an argument
2 participants