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

False positive W0613 with keyword only argument #5771

Closed
DevinShanahan opened this issue Feb 4, 2022 · 2 comments · Fixed by #5908
Closed

False positive W0613 with keyword only argument #5771

DevinShanahan opened this issue Feb 4, 2022 · 2 comments · Fixed by #5908
Labels
False Positive 🦟 A message is emitted but nothing is wrong with the code Needs astroid update Needs an astroid update (probably a release too) before being mergable
Milestone

Comments

@DevinShanahan
Copy link

Bug description

Using a keyword-only argument is triggering a W0613(unused-argument) warning where it is not occurring if the (unused) argument is a keyword argument. Below, B.add does not issue the warning, but D.add does.

kwoa.py

# pylint: disable=C*,R*
class A:
    def add(self, a, b=0):
        return a + b

class B(A):
    def add(self, a, b=0):
        return None

class C:
    def add(self, a, *, b=0):
        return a + b

class D(C):
    def add(self, a, *, b=0):
        return None

Configuration

No response

Command used

pylint kwoa.py

Pylint output

************* Module kwoa
kwoa.py:16:24: W0613: Unused argument 'b' (unused-argument)

Expected behavior

I believe there are two possibilities here but I had been operating under the assumption that this warning would not occur for D.add given that is not the behavior for B.add. The other option is that a warning should also be issued B.add.

Pylint version

pylint 2.12.2
astroid 2.9.0
Python 3.9.5 (default, May 18 2021, 12:31:01) 
[Clang 10.0.0 ]

OS / Environment

No response

Additional dependencies

No response

@DevinShanahan DevinShanahan added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Feb 4, 2022
@jacobtylerwalls
Copy link
Member

Thanks for the report. Based on this comment I think you are correct that this is not supposed to warn. I have a diff for astroid that fixes it and hope to PR it soon.

@DanielNoord DanielNoord added False Positive 🦟 A message is emitted but nothing is wrong with the code Needs astroid update Needs an astroid update (probably a release too) before being mergable and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Feb 5, 2022
@jacobtylerwalls
Copy link
Member

PR adding the regression test should also simplify this to just argnames(): 01cc02d5e

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 astroid update Needs an astroid update (probably a release too) before being mergable
Projects
None yet
3 participants