Pylint: False positive for `signature-differs` when collecting all arguments

Created on 12 Jul 2020  路  6Comments  路  Source: PyCQA/pylint

This is a very similar bug to #1553. The main difference is that in this case we set a default value to one of the parameters in the function that we override in the subclass (see elit=None).

Steps to reproduce

Create a file lorem.py as follows:

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


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

Note that this is a particularly common pattern in Django, for example when overriding the save method of models (see an example in the official documentation).

Current behavior

Run pylint on the file (pylint lorem.py):

...
lorem.py:7:4: W0222: Signature differs from overridden 'dolor' method (signature-differs)

Expected behavior

There is no error reported.

pylint --version output

pylint 2.5.3
astroid 2.4.2
Python 3.8.2 (default, Apr 27 2020, 15:53:34) 
[GCC 9.3.0]
bug

All 6 comments

+1

I hit this today as well; this is a very common idiom and shouldn't trigger a warning.

I've prepared a small PR that fixes this issue: https://github.com/PyCQA/pylint/pull/3988

When do you plan to release new pylint? Right now pylint from pypi and also from Fedora 33 are both erroring with this issue. This blocks FreeIPA CI...

Any news when this fix will be merged to master?

The fix has been already merged some time ago: https://github.com/PyCQA/pylint/pull/3988

In fact, this fix should already be included in pylint 2.7.0+ as far as I remember.

My bad I had 2.6 version, after upgrade everything works, thanks :)!

Was this page helpful?
0 / 5 - 0 ratings