Skip to content

Commit 56495fd

Browse files
committed
no-value-for-parameter variadic detection has improved for assign statements
Close #3563
1 parent 1654e49 commit 56495fd

File tree

3 files changed

+37
-6
lines changed

3 files changed

+37
-6
lines changed

ChangeLog

+4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ Release date: TBA
1717

1818
Close #3533
1919

20+
* ``no-value-for-parameter`` variadic detection has improved for assign statements
21+
22+
Close #3563
23+
2024
What's New in Pylint 2.5.0?
2125
===========================
2226

pylint/checkers/typecheck.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -564,9 +564,9 @@ def _no_context_variadic_keywords(node, scope):
564564

565565
if isinstance(scope, astroid.Lambda) and not isinstance(scope, astroid.FunctionDef):
566566
variadics = list(node.keywords or []) + node.kwargs
567-
elif isinstance(statement, (astroid.Return, astroid.Expr)) and isinstance(
568-
statement.value, astroid.Call
569-
):
567+
elif isinstance(
568+
statement, (astroid.Return, astroid.Expr, astroid.Assign)
569+
) and isinstance(statement.value, astroid.Call):
570570
call = statement.value
571571
variadics = list(call.keywords or []) + call.kwargs
572572

@@ -579,9 +579,9 @@ def _no_context_variadic_positional(node, scope):
579579
variadics = node.starargs + node.kwargs
580580
else:
581581
statement = node.statement()
582-
if isinstance(statement, (astroid.Expr, astroid.Return)) and isinstance(
583-
statement.value, astroid.Call
584-
):
582+
if isinstance(
583+
statement, (astroid.Expr, astroid.Return, astroid.Assign)
584+
) and isinstance(statement.value, astroid.Call):
585585
call = statement.value
586586
variadics = call.starargs + call.kwargs
587587

tests/functional/r/regression_no_value_for_parameter.py

+27
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# pylint: disable=missing-docstring,import-error
2+
import os
3+
24
from Unknown import Unknown
35

6+
47
class ConfigManager(Unknown):
58

69

@@ -13,3 +16,27 @@ def test(self):
1316

1417
def items(self, sectname, raw=True):
1518
pass
19+
20+
21+
def func(*, key=None):
22+
return key
23+
24+
25+
def varargs_good(*parts):
26+
"""All good"""
27+
return os.path.join(*parts)
28+
29+
30+
def varargs_no_expr(*parts):
31+
"""False positive below this line"""
32+
ret = os.path.join(*parts)
33+
return ret
34+
35+
36+
def kwargs_good(**kwargs):
37+
return func(**kwargs)
38+
39+
40+
def kwargs_no_expr(**kwargs):
41+
ret = func(**kwargs)
42+
return ret

0 commit comments

Comments
 (0)