Email [Python-projects] Pylint does not detect unpacking problems.

subject
[Python-projects] Pylint does not detect unpacking problems.
date
2005/06/07 10:18
Bonjour à tous!

I wonder if it would be possible for pylint to detect mismatch of packing when a
function is known to return a tuple with a fixed number of elements and when the
caller does not unpack that same number.  Currently Pylint (0.6.4) does not
detect the error in the following test code.

# -----------------------------------------------------------------------------
"""Test Pylint' ability to detect unpacking errors"""


__author__  = "Pierre Rouleau"
__version__ = "$Revision: 1.1 $".split()[1]
__category__ = "module, Pylint Test"


# -----------------------------------------------------------
# t u p l e _ 3 ( )         -- return a 3-tuple --
# ^^^^^^^^^^^^^^^^^
#
def tuple_3(val1, val2, val3) :
    """Return a 3-tuple.
    """

    return (val1, val2, val3)

# -------------------------------------------------------------
# r u n ( )         -- Perform tests --
# ^^^^^^^^^
#
def run() :
    """Perform tests.
    """

    r_a, r_b = tuple_3(1, 2, 3)
    print r_a, r_b

# -------------------------------------------------------------
if __name__ == "__main__":

    m_a, m_b = tuple_3(1, 2, 3)  # <------ error should unpack 3 values
    print m_a, m_b
# ---------------------------------------------------------------


Regards,

Pierre Rouleau


_______________________________________________
Python-Projects mailing list
Python-Projects@lists.logilab.org
http://lists.logilab.org/mailman/listinfo/python-projects