Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pylint warning: Possible unbalanced tuple unpacking with sequence

I have a piece of Python code:

def func1():                                                                                                                  
    a=set()
    b = ','.join(map(str, list(a)))
    return  b, []

def func2():
    d = 1
    e = 2
    return func1() + (d, e,)

def main():
    a,b,c,d = func2()

if __name__ == '__main__':
    main()

When I run it through pylint (1.4.0), I receive the warning:

W: 12, 4: Possible unbalanced tuple unpacking with sequence: left side has 4 label(s), right side has 3 value(s) (unbalanced-tuple-unpacking)

It seems that func2 will always return four results. What does the error mean and why?

like image 472
user1659464 Avatar asked Jan 16 '15 08:01

user1659464


1 Answers

If the warning is erroneous, it can be disabled by appending # pylint: disable=unbalanced-tuple-unpacking to the line.

like image 137
The Chess Guy 20 Avatar answered Nov 05 '22 13:11

The Chess Guy 20