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

Accept empty list unpacking for function without parameter #7392

Merged
merged 4 commits into from Aug 29, 2019

Conversation

@onlined
Copy link
Contributor

commented Aug 26, 2019

Fixes #4997.

Copy link
Collaborator

left a comment

Thanks for fixing this! The fix looks good, just a few small comments.

@@ -3833,9 +3833,9 @@ def is_async_def(t: Type) -> bool:
return isinstance(t, Instance) and t.type.fullname() == 'typing.Coroutine'


def is_empty_tuple(t: Type) -> bool:
def is_not_empty_tuple(t: Type) -> bool:

This comment has been minimized.

Copy link
@JukkaL

JukkaL Aug 26, 2019

Collaborator

I was a little confused by the name at first. What about renaming this to is_non_empty_tuple?

This comment has been minimized.

Copy link
@onlined

onlined Aug 27, 2019

Author Contributor

Fixed.

@@ -448,6 +447,15 @@ def f(x: int, *, y: str) -> None: pass
f(y='x', *(1,))
[builtins fixtures/list.pyi]

[case testVarArgsEmptyList]

This comment has been minimized.

Copy link
@JukkaL

JukkaL Aug 26, 2019

Collaborator

I assume that there's an existing test case that covers the empty tuple case?

This comment has been minimized.

Copy link
@onlined

onlined Aug 27, 2019

Author Contributor

Actually, there is not. I thought that a tuple test is not in the scope of this PR.

This comment has been minimized.

Copy link
@JukkaL

JukkaL Aug 27, 2019

Collaborator

Since this changes the code related to handling empty/non-empty tuples as *args, it would be good to add a test case for this in case one doesn't exist already. This would validate that the change hasn't introduced a regression.

This comment has been minimized.

Copy link
@onlined

onlined Aug 27, 2019

Author Contributor

Added.

@@ -1233,7 +1233,7 @@ def check_for_extra_actual_arguments(self,
for i, kind in enumerate(actual_kinds):
if i not in all_actuals and (
kind != nodes.ARG_STAR or
not is_empty_tuple(actual_types[i])):
is_not_empty_tuple(actual_types[i])):

This comment has been minimized.

Copy link
@JukkaL

JukkaL Aug 26, 2019

Collaborator

Here it would be nice to add a comment about list and Any star args potentially being empty, so we don't complain about them.

This comment has been minimized.

Copy link
@onlined

onlined Aug 27, 2019

Author Contributor

I added the comment.

@JukkaL
JukkaL approved these changes Aug 29, 2019
Copy link
Collaborator

left a comment

Thanks!

@JukkaL JukkaL merged commit 8954045 into python:master Aug 29, 2019
2 checks passed
2 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.