From https://github.com/PyCQA/pylint/issues/2778:
I'm not sure if this gives any new insights, but I just wanted to report that I'm able to trigger error 1120 with an even simpler construct, while also having a code example which is more or less exactly the same, but doesn't trigger this error.
# pylint: disable=missing-docstring,too-few-public-methods,mixed-indentation,invalid-name
class Base():
def __init__(self, foo, *args):
self._foo = foo
self._args = args
class Child(Base):
pass
class SomethingElse():
def __init__(self, *args):
self._child = Child(*args)
************* Module E1120-Trigger
E1120-Trigger.py:14:16: E1120: No value for argument 'foo' in constructor call (no-value-for-parameter)
-----------------------------------
Your code has been rated at 4.44/10
# pylint: disable=missing-docstring,too-few-public-methods,mixed-indentation,invalid-name
class Base():
def __init__(self, foo, *args):
self._foo = foo
self._args = args
class Child(Base):
def __init__(self, *args):
super().__init__(*args)
self._bar = True
class SomethingElse():
def __init__(self, *args):
self._child = Child(*args)
------------------------------------
Your code has been rated at 10.00/10
The difference is in the explicit call to the parent __init__() method in the second example. With this in place, E1120 is not triggered. In the first example, E1120 is triggered in the last line where a Child instance is created.
pylint 2.3.1
astroid 2.2.5
Python 3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 23:09:28) [MSC v.1916 64 bit (AMD64)]
Thanks for following up on this. I'd be glad for a fix for this, because it's messing my linting results now due to a code change in my project.
Hey @0xLeon Sure thing, feel free to tackle a PR!
This check is emitted in pylint/checkers/typecheck.py, we'll need to adapt that detection code to account for the case when the first parameter is a positional one, followed by variadic parameters.
I'll might give this a try, but can't promise because the legal clearance in my company for providing code to OSS projects is… exhausting, so to say. But that hint on where to start looking into this is actually pretty useful, thanks! I'm new to pylint development, so a starting point is a good thing.
Most helpful comment
I'll might give this a try, but can't promise because the legal clearance in my company for providing code to OSS projects is… exhausting, so to say. But that hint on where to start looking into this is actually pretty useful, thanks! I'm new to pylint development, so a starting point is a good thing.