Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
EmilyBourne opened this issue Jan 29, 2025 · 0 comments · Fixed by #10209
Closed

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

EmilyBourne opened this issue Jan 29, 2025 · 0 comments · Fixed by #10209
Labels
False Positive 🦟 A message is emitted but nothing is wrong with the code Needs PR This issue is accepted, sufficiently specified and now needs an implementation
Milestone

Comments

@EmilyBourne
Copy link

EmilyBourne commented Jan 29, 2025

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)

@EmilyBourne EmilyBourne added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Jan 29, 2025
@mbyrnepr2 mbyrnepr2 added Needs PR This issue is accepted, sufficiently specified and now needs an implementation False Positive 🦟 A message is emitted but nothing is wrong with the code and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Jan 29, 2025
mbyrnepr2 added a commit to mbyrnepr2/pylint that referenced this issue Jan 29, 2025
@mbyrnepr2 mbyrnepr2 added this to the 3.3.5 milestone Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
False Positive 🦟 A message is emitted but nothing is wrong with the code Needs PR This issue is accepted, sufficiently specified and now needs an implementation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants