-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
expression-not-assigned should not be emitted for ternary operator #2380
Comments
@sushobhit27 I think it's reasonable that this check gets emitted here. This would be better written as an if statement, which is a bit clearer and easier to follow.
|
@PCManticore here is another use case where this check should not be emitted IMO
I know it can be re-written as
but that increases the indentation and this particular style I have seen in some third party packages also, e.g |
But in your case you are creating a transient list that just gets thrown away after you're done with the iteration. It's more efficient to just use the |
Steps to reproduce
Current behavior
************* Module sample
sample.py:8:4: W0106: Expression "goo(True) if True else bar(False)" is assigned to nothing (expression-not-assigned)
Your code has been rated at 8.33/10 (previous run: 8.33/10, +0.00)
Expected behavior
There should be no warning when some functionality has to be executed using ternary operator.
Actuall use case, where this message is being raised: https://github.com/sushobhit27/bimap/blob/8b28e6501b96872c109e0a51e4f7e6081bec0c8f/bimap/bimap.py#L57
pylint --version output
$ pylint --version
pylint 2.0.0
astroid 2.0.1
Python 3.6.4 (default, Jan 7 2018, 15:53:53)
[GCC 6.4.0]
The text was updated successfully, but these errors were encountered: