Skip to content

False positive no-value-for-parameter due to inference edge case #8544

@tushar-deepsource

Description

@tushar-deepsource

Bug description

Due to incorrect inference, E1120 can be raised on code that is functional.

Example code:

def get_nums():
    nums = ()
    if input() == '1':
        nums = (1, 2)
    return nums

def add(x, y):
    return x + y

nums = get_nums()
if nums:
    add(*nums)  # issue raised here, pylint thinks `nums` will always be `()`

Command used

pylint asd.py --disable=all --enable=E1120

Pylint output

************* Module asd
asd.py:12:4: E1120: No value for argument 'x' in function call (no-value-for-parameter)
asd.py:12:4: E1120: No value for argument 'y' in function call (no-value-for-parameter)

Expected behavior

No issues raised.

Pylint version

pylint 2.17.2
astroid 2.15.2
Python 3.11.2 (main, Feb 16 2023, 02:55:59) [Clang 14.0.0 (clang-1400.0.29.202)]

OS / Environment

MacOS Ventura, 13.2.1

Additional dependencies

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    AstroidRelated to astroidFalse Positive 🦟A message is emitted but nothing is wrong with the codeNeeds PRThis issue is accepted, sufficiently specified and now needs an implementation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions