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

E0112: too-many-star-expressions triggers on valid code #2513

Closed
njsmith opened this issue Sep 22, 2018 · 2 comments
Closed

E0112: too-many-star-expressions triggers on valid code #2513

njsmith opened this issue Sep 22, 2018 · 2 comments

Comments

@njsmith
Copy link

njsmith commented Sep 22, 2018

Steps to reproduce

Here's some legal python code:

(a, *b), *c = ((1, 2, 3), 4, 5)
print(a)  # 1
print(b)  # (2, 3)
print(c)  # (4, 5)

For example, this can be used to unpack the complicated return value from socket.getaddrinfo.

Current behavior

Running pylint on the above code reports E0112: too-many-star-expressions:

/tmp/stars.py:1:0: E0112: More than one starred expression in assignment (too-many-star-expressions)

Expected behavior

Don't report this error on valid code.

pylint --version output

pylint 2.1.1
astroid 2.0.4
Python 3.6.5 (default, Apr  1 2018, 05:46:30) 
[GCC 7.3.0]
@njsmith
Copy link
Author

njsmith commented Sep 23, 2018

Not that anyone asked me, but if that commit were a PR I was reviewing, I'd also have added tests for

(*a, *b), c = ...    # should trigger a message
((*a, b), *c), *d = ... # shouldn't trigger a message

And I'm pretty sure the second test would fail, because the fix as written seems to hardcode exactly one level of traversal and then revert to the old buggy behavior.

@PCManticore
Copy link
Contributor

Thanks for the suggestion though! I'll take a look tomorrow for making that code handle more traversal levels.

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

No branches or pull requests

2 participants