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

no-value-for-parameter false positive #2820

Closed
PCManticore opened this issue Mar 19, 2019 · 7 comments
Closed

no-value-for-parameter false positive #2820

PCManticore opened this issue Mar 19, 2019 · 7 comments
Labels
Bug 🪲 Checkers Related to a checker

Comments

@PCManticore
Copy link
Contributor

From #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.

E1120 triggered

# 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)

Output

************* 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

E1120 not triggered

# 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)

Output


------------------------------------

Your code has been rated at 10.00/10

Conclusion

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 --version output

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)]
@0xLeon
Copy link

0xLeon commented Mar 20, 2019

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.

@PCManticore
Copy link
Contributor Author

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.

@0xLeon
Copy link

0xLeon commented Mar 26, 2019

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.

hackrush01 pushed a commit to lbryio/lbry-sdk that referenced this issue May 19, 2019
hackrush01 pushed a commit to lbryio/lbry-sdk that referenced this issue May 20, 2019
hackrush01 pushed a commit to lbryio/lbry-sdk that referenced this issue May 23, 2019
eukreign pushed a commit to lbryio/lbry-sdk that referenced this issue May 28, 2019
eukreign pushed a commit to lbryio/lbry-sdk that referenced this issue May 29, 2019
@cdce8p cdce8p closed this as completed Oct 17, 2021
@cdce8p
Copy link
Member

cdce8p commented Oct 17, 2021

This issue seems to be fixed when testing with the latest pylint version.
If you still encounter issues, please report back and I'll reopen it.

@mallniya
Copy link

mallniya commented Aug 5, 2022

I do, unfortunately, the following:

import os
path_groups = ['a', 'b', 'c']
path = os.path.join(*path_groups)

still shooting(
Signature of function is join(a, *p), so it looks like I'm in the right thread.

@Pierre-Sassoulas
Copy link
Member

@mallniya what is your pylint's version, please ? I cannot reproduce on the latest main.

@mallniya
Copy link

mallniya commented Aug 5, 2022

@Pierre-Sassoulas, frankly, I don't usually check the exact version, since I delegate this to the pip in the venv, but pylint is up to date:

$ pylint --version
pylint 2.14.5
astroid 2.11.7
Python 3.10.4 (main, Jun 29 2022, 12:14:53) [GCC 11.2.0]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🪲 Checkers Related to a checker
Projects
None yet
Development

No branches or pull requests

5 participants