Description
In v2.9.0, pylint appears to be confused by a certain pattern of abstract classes; it believes the code is calling a function on one abstract class which takes X arguments, it is actually calling another function with the same name on a totally different class, where it takes Y arguments. The original error was no-value-for-parameter
on this function, at line 191 - it believes key.sign
is rsa.RSAPrivateKey.sign
, which takes 3 arguments, but it is actually (and was previously recognised as) ec.EllipticCurvePrivateKey.sign
, which takes 2 arguments.
I've created a smaller repro with a similar pattern, the reported error is slightly different but it looks like the core confusion is the same.
Steps to reproduce
Given a file a.py
:
import abc
import six
@six.add_metaclass(abc.ABCMeta)
class Bar:
@abc.abstractmethod
def foo(self, a):
pass
@six.add_metaclass(abc.ABCMeta)
class Baz:
@abc.abstractmethod
def foo(self, a, b):
pass
class BarImpl(Bar):
def foo(self, a):
print(f"BarImpl.foo({a})")
class BazImpl(Baz):
def foo(self, a, b):
print(f"BazImpl.foo({a}, {b})")
def make_obj(s):
if s == "BarImpl":
return BarImpl()
if s == "BazImpl":
return BazImpl()
def call_foo(o):
if isinstance(o, Bar):
o.foo("saluton")
if isinstance(o, Baz):
o.foo("Hello", "world")
def call_foo_indirect(s):
o = make_obj(s)
if isinstance(o, Bar):
o.foo("saluton")
if isinstance(o, Baz):
o.foo("Hello", "world")
call_foo(BarImpl())
call_foo(BazImpl())
call_foo_indirect("BarImpl")
call_foo_indirect("BazImpl")
This minimal example also produces errors in older versions, but the original full example doesn't.
Current behavior
$ pylint a.py --disable=all --enable=no-value-for-parameter,too-many-function-args
************* Module a
a.py:48:8: E1121: Too many positional arguments for method call (too-many-function-args)
------------------------------------------------------------------
Your code has been rated at 8.53/10
Expected behavior
This should report no errors.
pylint --version output
Result of pylint --version
output:
$ pylint --version
pylint 2.9.0
astroid 2.6.1
Python 3.8.8 (default, Feb 20 2021, 21:09:14)
[GCC 7.5.0]