invalid-getnewargs-ex-returned / E0313#

Message emitted:

__getnewargs_ex__ does not return a tuple containing (tuple, dict)


Used when a __getnewargs_ex__ method returns something which is not of the form tuple(tuple, dict)

Problematic code:

class BadGetNewArgsEx:
    """__getnewargs_ex__ returns tuple with incorrect arg length"""

    def __getnewargs_ex__(self):  # [invalid-getnewargs-ex-returned]
        return (tuple(1), dict(x="y"), 1)

Correct code:

class GoodGetNewArgsEx:
    """__getnewargs_ex__ returns <type 'tuple'>"""

    def __getnewargs_ex__(self):
        return ((1,), {"2": 2})

Created by the classes checker.