invalid-getnewargs-ex-returned / E0313ΒΆ

Message emitted:

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

Description:

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

Problematic code:

class CustomGetNewArgsEx:
    """__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 CustomGetNewArgsEx:
    """__getnewargs_ex__ returns <type 'tuple'>"""

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

Created by the classes checker.