Thanks to visit codestin.com
Credit goes to github.com

Skip to content

False positive for invalid-getnewargs-ex-returned #10208

@EmilyBourne

Description

@EmilyBourne

Bug description

The error invalid-getnewargs-ex-returned is raised if the tuple[tuple, dict] is built from variables

class A:
    def __init__(self, boo, far, *, hoo, haha):
        self._foo = boo
        self._bar = far
        self._hoo = hoo
        self._haha = haha

    def __getnewargs_ex__(self):
        args = (self._foo, self._bar)
        kwargs = {'hoo': self._hoo,
                  'haha': self._haha}
        return args, kwargs

Command used

pylint pylint_bug.py

Pylint output

************* Module pylint_bug
pylint_bug.py:1:0: C0114: Missing module docstring (missing-module-docstring)
pylint_bug.py:3:0: C0115: Missing class docstring (missing-class-docstring)
pylint_bug.py:10:4: E0313: __getnewargs_ex__ does not return a tuple containing (tuple, dict) (invalid-getnewargs-ex-returned)
pylint_bug.py:3:0: R0903: Too few public methods (0/2) (too-few-public-methods)

------------------------------------------------------------------
Your code has been rated at 2.00/10 (previous run: 0.00/10, +2.00)

Expected behavior

This code should not raise the error invalid-getnewargs-ex-returned

Pylint version

pylint 3.3.4
astroid 3.3.8
Python 3.10.12 (main, Jan 17 2025, 14:35:34) [GCC 11.4.0]

OS / Environment

Linux (Ubuntu)

Metadata

Metadata

Assignees

No one assigned

    Labels

    False 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
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions