Skip to content

Commit

Permalink
add too-few-function-args to docs
Browse files Browse the repository at this point in the history
  • Loading branch information
rogersheu committed Aug 13, 2024
1 parent 9682d47 commit 3cc7e7f
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 8 deletions.
7 changes: 7 additions & 0 deletions doc/data/messages/t/too-few-function-args/bad.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class Fruit:
def __init__(self, color, name):
self.color = color
self.name = name


apple = Fruit("red") # [too-few-function-args]
7 changes: 7 additions & 0 deletions doc/data/messages/t/too-few-function-args/good.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class Fruit:
def __init__(self, color, name):
self.color = color
self.name = name


apple = Fruit("red", "apple")
10 changes: 5 additions & 5 deletions pylint/checkers/typecheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def _missing_member_hint(
"Used when a function call passes too few arguments.",
),
"E1121": (
"Too many positional arguments (%s/%s)",
"Too many positional arguments for function `%s` (%s/%s)",
"too-many-function-args",
"Used when a function call passes too many positional arguments.",
),
Expand Down Expand Up @@ -378,7 +378,7 @@ def _missing_member_hint(
"a custom __getitem__ method.",
),
"E1145": (
"Too few positional arguments (%s/%s)",
"Too few positional arguments for function `%s` (%s/%s)",
"too-few-function-args",
"Used when a function or method has fewer arguments than expected.",
),
Expand Down Expand Up @@ -1430,14 +1430,14 @@ def _check_isinstance_args(self, node: nodes.Call) -> None:
self.add_message(
"too-many-function-args",
node=node,
args=(len(node.args), 2),
args=("isinstance", len(node.args), 2),
confidence=HIGH,
)
elif len(node.args) < 2:
self.add_message(
"too-few-function-args",
node=node,
args=(len(node.args), 2),
args=("isinstance", len(node.args), 2),
confidence=HIGH,
)
return
Expand Down Expand Up @@ -1574,7 +1574,7 @@ def visit_call(self, node: nodes.Call) -> None:
self.add_message(
"too-many-function-args",
node=node,
args=(len(parameters), num_positional_args),
args=(callable_name, len(parameters), num_positional_args),
)
break

Expand Down
2 changes: 1 addition & 1 deletion tests/functional/t/too/too_few_function_args.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
too-few-function-args:3:0:3:13::Too few positional arguments (1/2):HIGH
too-few-function-args:3:0:3:13::Too few positional arguments for function `isinstance` (1/2):HIGH
4 changes: 2 additions & 2 deletions tests/functional/t/too/too_many_function_args.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
too-many-function-args:23:0:23:23::Too many positional arguments (3/2):HIGH
too-many-function-args:23:0:23:23::Too many positional arguments for function `isinstance` (3/2):HIGH
isinstance-second-argument-not-valid-type:24:0:24:21::Second argument of isinstance is not a type:INFERENCE
too-many-function-args:24:0:24:21::Too many positional arguments (3/2):HIGH
too-many-function-args:24:0:24:21::Too many positional arguments for function `isinstance` (3/2):HIGH

0 comments on commit 3cc7e7f

Please sign in to comment.