Skip to content
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

Method with variadic args/kwargs but no self reports no-method-argument instead of no-self-argument #7507

Closed
Jackenmen opened this issue Sep 20, 2022 · 3 comments · Fixed by #7518
Labels
Bug 🪲 Good first issue Friendly and approachable by new contributors Minor 💅 Polishing pylint is always nice Needs PR This issue is accepted, sufficiently specified and now needs an implementation
Milestone

Comments

@Jackenmen
Copy link
Contributor

Bug description

# pylint: disable=missing-docstring

class MyClass:
    # correct warning: no-method-argument
    def no_args():
        """A method without a self argument or any other arguments."""

    # correct warning: no-self-argument
    def no_self_arg(arg):
        """A method without a self argument but with a standard argument."""

    # incorrect warning: no-method-argument
    def no_self_arg_but_varargs(*args):
        """A method without a self argument but with *args."""

    # incorrect warning: no-method-argument
    def no_self_arg_but_kwargs(**kwargs):
        """A method without a self argument but with **kwargs."""

    # incorrect warning: no-method-argument
    def no_self_arg_but_varargs_and_kwargs(*args, **kwargs):
        """A method without a self argument but with *args and **kwargs."""

    def correct(self):
        """Correct."""
        self.var = "correct"

Configuration

No response

Command used

pylint repro.py

Pylint output

************* Module repro
repro.py:5:4: E0211: Method has no argument (no-method-argument)
repro.py:9:4: E0213: Method should have "self" as first argument (no-self-argument)
repro.py:13:4: E0211: Method has no argument (no-method-argument)
repro.py:17:4: E0211: Method has no argument (no-method-argument)
repro.py:21:4: E0211: Method has no argument (no-method-argument)

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

Expected behavior

I expected to see no-self-argument when a method has *args or **kwargs rather than no-method-argument as the latter is quite confusing as the method does have arguments.

Pylint version

pylint 2.15.3
astroid 2.12.10
Python 3.8.14 (default, Sep  8 2022, 00:02:07) 
[GCC 11.2.0]

OS / Environment

Kubuntu 22.04.1 LTS

Additional dependencies

No response

@Jackenmen Jackenmen added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Sep 20, 2022
@mbyrnepr2 mbyrnepr2 added Bug 🪲 Minor 💅 Polishing pylint is always nice Good first issue Friendly and approachable by new contributors Needs PR This issue is accepted, sufficiently specified and now needs an implementation and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Sep 21, 2022
@mbyrnepr2
Copy link
Member

I think that makes sense. Thank you for reporting it.

@clavedeluna
Copy link
Collaborator

It would also be a nice to have that the wording for both no-method-argument and no-self-argument include the method name, that is

Method has no argument (no-method-argument)
Method should have "self" as first argument (no-self-argument)

to be

Method NAME has no argument (no-method-argument)
Method NAME should have "self" as first argument (no-self-argument)

@mbyrnepr2 mbyrnepr2 added this to Todo in Better error messages via automation Sep 21, 2022
@Pierre-Sassoulas
Copy link
Member

Yeah, having the name of the method would definitely be better for CLI use. (it's probably not the case because in IDE you know the name: it's the function you're hovering)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🪲 Good first issue Friendly and approachable by new contributors Minor 💅 Polishing pylint is always nice Needs PR This issue is accepted, sufficiently specified and now needs an implementation
Projects
Development

Successfully merging a pull request may close this issue.

4 participants