Skip to content

Commit 48781fe

Browse files
authored
Fix a false positive for no-value-for-parameter when a staticmethod is called in a class body. (#9038)
Closes #9036
1 parent 0ac21c7 commit 48781fe

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Fix a false positive for ``no-value-for-parameter`` when a staticmethod is called in a class body.
2+
3+
Closes #9036

pylint/checkers/typecheck.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1504,10 +1504,10 @@ def visit_call(self, node: nodes.Call) -> None:
15041504
# includes an implicit `self` argument which is not present in `called.args`.
15051505
if (
15061506
isinstance(node.frame(), nodes.ClassDef)
1507-
and isinstance(node.parent, (nodes.Assign, nodes.AnnAssign))
15081507
and isinstance(called, nodes.FunctionDef)
15091508
and called in node.frame().body
15101509
and num_positional_args > 0
1510+
and "builtins.staticmethod" not in called.decoratornames()
15111511
):
15121512
num_positional_args -= 1
15131513

tests/functional/a/arguments.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,3 +320,14 @@ def name6(param1, **kwargs): ...
320320
name4(1, param2=False)
321321
name5()
322322
name6(param1=43)
323+
324+
325+
# https://github.com/pylint-dev/pylint/issues/9036
326+
# No value for argument 'string' in staticmethod call (no-value-for-parameter)
327+
class Foo:
328+
@staticmethod
329+
def func(string):
330+
return string
331+
332+
func(42)
333+
a = func(42)

0 commit comments

Comments
 (0)