Skip to content

expression-not-assigned should not be emitted for ternary operator #2380

Closed
@sushobhit27

Description

@sushobhit27

Steps to reproduce

  1. cat sample.py
def goo(var):
    pass

def bar(var):
    pass

def foo():
    goo(True) if True else bar(False)
  1. $ pylint sample.py --disable=blacklisted-name,unused-argument,using-constant-test

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]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions