Skip to content

Commit 7be6350

Browse files
committed
added note to too_many_positional_arguments
1 parent 0ea16df commit 7be6350

4 files changed

Lines changed: 18 additions & 0 deletions

File tree

mypy/messages.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -972,6 +972,7 @@ def too_many_positional_arguments(self, callee: CallableType, context: Context)
972972
msg = "Too many positional arguments" + for_function(callee)
973973
self.fail(msg, context)
974974
self.maybe_note_about_special_args(callee, context)
975+
self.note_defined_here(callee, context)
975976

976977
def maybe_note_about_special_args(self, callee: CallableType, context: Context) -> None:
977978
if self.prefer_simple_messages():

test-data/unit/check-kwargs.test

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,21 @@ def f(a: int, *, b: str) -> None:
495495
pass
496496
f(1) # E: Missing named argument "b" for "f"
497497

498+
[case testTooManyPositionalArgumentsFromOtherModule]
499+
import m
500+
m.f(1, 2)
501+
[file m.py]
502+
def f(a: int, *, b: int) -> None:
503+
pass
504+
[out]
505+
main:2: error: Too many positional arguments for "f"
506+
main:2: note: "f" defined in "m"
507+
508+
[case testTooManyPositionalArgumentsForSameModule]
509+
def f(a: int, *, b: int) -> None:
510+
pass
511+
f(1, 2) # E: Too many positional arguments for "f"
512+
498513
[case testStarArgsAndKwArgsSpecialCase]
499514
from typing import Dict, Mapping
500515

test-data/unit/check-namedtuple.test

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ main:5: error: Argument "rename" to "namedtuple" has incompatible type "str"; ex
132132
main:6: error: Unexpected keyword argument "unrecognized_arg" for "namedtuple"
133133
main:6: note: "namedtuple" defined in "collections"
134134
main:7: error: Too many positional arguments for "namedtuple"
135+
main:7: note: "namedtuple" defined in "collections"
135136

136137
[case testNamedTupleDefaults]
137138
from collections import namedtuple

test-data/unit/check-type-aliases.test

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,6 +1112,7 @@ reveal_type(t3) # N: Revealed type is "Any"
11121112

11131113
T4 = TypeAliasType("T4") # E: Missing positional argument "value" in call to "TypeAliasType"
11141114
T5 = TypeAliasType("T5", int, str) # E: Too many positional arguments for "TypeAliasType" \
1115+
# N: "TypeAliasType" defined in "typing_extensions" \
11151116
# E: Argument 3 to "TypeAliasType" has incompatible type "type[str]"; expected "tuple[TypeVar? | ParamSpec? | TypeVarTuple?, ...]"
11161117
[builtins fixtures/tuple.pyi]
11171118
[typing fixtures/typing-full.pyi]

0 commit comments

Comments
 (0)