-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 with default arg values before *args #2481
Comments
This is expected. The error message for that check basically says:
Which means that for your function you can't really pass
|
@PCManticore This is not a /keyword/ argument. this is just an argument with default value. And an error message occurs when I define a function, not when I pass params. |
@eirnym We don't make any distinction between |
Specification of keyword argument before positional arguments is a syntax error. And you aren't able pass a keyword argument with the same name as positional anyway. I see a few problems with combining all cases in the warning:
Therefore, I want an explicit distinction between these two cases. |
@PCManticore |
@CoinCheung Sometimes it's just not possible to write this way as you wrote, but this is the way he wants. |
@eirnym So does pylint suggests that it is a good habit to never use |
@CoinCheung for what it's worth, PEP-3102 uses that convention (i.e.: I don't think pylint suggests it's a good habit to never use In the end, though, pylint is a linter that you configure. If you decide that this warning isn't relevant to you and your project, you can disable it in (Disclaimer: I've only recently discovered pylint and am still in the process of getting familiar with it and setting it up in one of my projects.) Edit: #1835 notes that that syntax is invalid in Python2 so it seems there's an inherent conflict between the warning and Python2. |
Hello, I realize this is by now quite an old issue, however the preconditions have changed a bit. PEP-570, first implemented in Python 3.8, introduced the ability to define positional-only parameters which cannot be passed in as keywords, using the def fun(param1, param2, param3=True, /, *args): Defined like this, there is no way for
Pylint 2.4.4 does not seem to know about this and still raises a "keyword-arg-before-vararg" warning on the above definition. The |
Still hoping the pylint would be able to recognize PEP-570. Seems that this syntax is not yet recognized. My current Pylint version
|
Hi, it looks like this is still not fixed ( |
@fievelk The issue is closed and about another problem in another context. Please open a new issue describing the problem in the context of PEP570, and consider contributing if this issue is important for you. pylint will be able to recognize pep-570 the day someone has the incentive to implement it, and actually does. |
Steps to reproduce
Current behavior
W1113: Keyword argument before variable positional arguments list in the definition of fun function (keyword-arg-before-vararg)
Expected behavior
different warning if any as variable
param3
is not a keyword argument.pylint --version output
The text was updated successfully, but these errors were encountered: