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 for arguments-differ when collecting all arguments #1553

Closed
benf-wspdigital opened this issue Jun 23, 2017 · 6 comments · Fixed by #3001
Closed

False positive for arguments-differ when collecting all arguments #1553

benf-wspdigital opened this issue Jun 23, 2017 · 6 comments · Fixed by #3001
Labels
Good first issue Friendly and approachable by new contributors

Comments

@benf-wspdigital
Copy link

The arguments-differ check will complain about this common pattern:

class Ipsum:
    def dolor(self, elit):
        pass


class LoremIpsum(Ipsum):
    def dolor(self, *args, **kwargs):
        super().dolor(*args, **kwargs)

PyLint reports:

$ python3 -m pylint --reports=n --enable=arguments-differ lorem.py 
************* Module lorem
lorem.py:7: [W0235(useless-super-delegation), LoremIpsum.dolor] Useless super delegation in method 'dolor'
lorem.py:7: [W0221(arguments-differ), LoremIpsum.dolor] Parameters differ from overridden 'dolor' method

That code should not trigger the arguments-differ check, because that pattern is explicitly just passing through the arguments to the superclass's method.

@AWhetter AWhetter added the Good first issue Friendly and approachable by new contributors label Jul 8, 2017
@AWhetter
Copy link
Contributor

AWhetter commented Jul 8, 2017

To any beginner contributors looking to fix this: arguments-differ is raised around https://github.com/PyCQA/pylint/blob/fbdf5ba095ebbbf04db12f6c3e88e21152a30507/pylint/checkers/classes.py#L1233
This will likely need a fix in _different_parameters() or _has_different_parameters() where we should add a check for *args, and **kwargs in overridden.

@kczapla
Copy link
Contributor

kczapla commented Sep 23, 2017

Hi,
I made simple fix here #1674.

mattlbeck added a commit to mattlbeck/pylint that referenced this issue Jul 11, 2019
No message is emitted if the overriding function provides positional or
keyword variadics in its signature that can feasibly accept and pass on
all parameters given by the overridden function.

Closes pylint-dev#1482
Closes pylint-dev#1553
Pierre-Sassoulas pushed a commit to Pierre-Sassoulas/pylint that referenced this issue Feb 24, 2020
No message is emitted if the overriding function provides positional or
keyword variadics in its signature that can feasibly accept and pass on
all parameters given by the overridden function.

Closes pylint-dev#1482
Closes pylint-dev#1553
Pierre-Sassoulas pushed a commit to mattlbeck/pylint that referenced this issue Mar 27, 2020
No message is emitted if the overriding function provides positional or
keyword variadics in its signature that can feasibly accept and pass on
all parameters given by the overridden function.

Closes pylint-dev#1482
Closes pylint-dev#1553
Pierre-Sassoulas pushed a commit that referenced this issue Mar 27, 2020
No message is emitted if the overriding function provides positional or
keyword variadics in its signature that can feasibly accept and pass on
all parameters given by the overridden function.

Closes #1482
Closes #1553
@GergelyKalmar
Copy link
Contributor

This fix doesn't seem to work when the overridden methods have default values:

class Ipsum:
    def dolor(self, elit=None):
        pass
pylint lorem.py
...
lorem.py:7:4: W0222: Signature differs from overridden 'dolor' method (signature-differs)

Is this to be expected?

@Pierre-Sassoulas
Copy link
Member

@GergelyKalmar I don't think the example you gave has all the code it should, we can't know what is inherited.

@GergelyKalmar
Copy link
Contributor

@Pierre-Sassoulas Sorry, I meant it in the same context as the original example in the issue report, just with a default value added:

class Ipsum:
    def dolor(self, elit=None):
        pass


class LoremIpsum(Ipsum):
    def dolor(self, *args, **kwargs):
        super().dolor(*args, **kwargs)

This should fail with a signature-differs error.

@Pierre-Sassoulas
Copy link
Member

Thank you. It seems like a bug, I think you can open a new issue with this example :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Good first issue Friendly and approachable by new contributors
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants