Skip to content

Commit d488cc1

Browse files
authored
Update arguments to parameters (Additional) [1] (#20711)
Fix: #20683 I changed `arguments` to `parameters` in the error messages of these constants below and I also changed some names of constants: ``` ARGUMENT_TYPE_EXPECTED => PARAM_TYPE_EXPECTED MISSING_OR_INVALID_SELF_TYPE ELLIPSIS_WITH_OTHER_TYPEARGS => ELLIPSIS_WITH_OTHER_TYPEPARAMS TYPE_SIGNATURE_TOO_MANY_ARGS => TYPE_SIGNATURE_TOO_MANY_PARAMS TYPE_SIGNATURE_TOO_FEW_ARGS => TYPE_SIGNATURE_TOO_FEW_PARAMS ```
1 parent cae23fb commit d488cc1

15 files changed

+61
-61
lines changed

mypy/checker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1792,7 +1792,7 @@ def is_unannotated_any(t: Type) -> bool:
17921792
if is_unannotated_any(self.get_coroutine_return_type(ret_type)):
17931793
self.fail(message_registry.RETURN_TYPE_EXPECTED, fdef)
17941794
if any(is_unannotated_any(t) for t in fdef.type.arg_types):
1795-
self.fail(message_registry.ARGUMENT_TYPE_EXPECTED, fdef)
1795+
self.fail(message_registry.PARAM_TYPE_EXPECTED, fdef)
17961796

17971797
def check___new___signature(self, fdef: FuncDef, typ: CallableType) -> None:
17981798
self_type = fill_typevars_with_any(fdef.info)

mypy/fastparse.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,21 +1001,21 @@ def do_func_def(
10011001
if any(arg_types) or return_type:
10021002
if len(arg_types) != 1 and any(isinstance(t, EllipsisType) for t in arg_types):
10031003
self.fail(
1004-
message_registry.ELLIPSIS_WITH_OTHER_TYPEARGS,
1004+
message_registry.ELLIPSIS_WITH_OTHER_TYPEPARAMS,
10051005
lineno,
10061006
n.col_offset,
10071007
blocker=False,
10081008
)
10091009
elif len(arg_types) > len(arg_kinds):
10101010
self.fail(
1011-
message_registry.TYPE_SIGNATURE_TOO_MANY_ARGS,
1011+
message_registry.TYPE_SIGNATURE_TOO_MANY_PARAMS,
10121012
lineno,
10131013
n.col_offset,
10141014
blocker=False,
10151015
)
10161016
elif len(arg_types) < len(arg_kinds):
10171017
self.fail(
1018-
message_registry.TYPE_SIGNATURE_TOO_FEW_ARGS,
1018+
message_registry.TYPE_SIGNATURE_TOO_FEW_PARAMS,
10191019
lineno,
10201020
n.col_offset,
10211021
blocker=False,

mypy/message_registry.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ def with_additional_msg(self, info: str) -> ErrorMessage:
126126
RETURN_TYPE_EXPECTED: Final = ErrorMessage(
127127
"Function is missing a return type annotation", codes.NO_UNTYPED_DEF
128128
)
129-
ARGUMENT_TYPE_EXPECTED: Final = ErrorMessage(
130-
"Function is missing a type annotation for one or more arguments", codes.NO_UNTYPED_DEF
129+
PARAM_TYPE_EXPECTED: Final = ErrorMessage(
130+
"Function is missing a type annotation for one or more parameters", codes.NO_UNTYPED_DEF
131131
)
132132
KEYWORD_ARGUMENT_REQUIRES_STR_KEY_TYPE: Final = ErrorMessage(
133133
'Keyword argument only valid with "str" key type in call to "dict"'
@@ -224,7 +224,7 @@ def with_additional_msg(self, info: str) -> ErrorMessage:
224224

225225
# Self-type
226226
MISSING_OR_INVALID_SELF_TYPE: Final = ErrorMessage(
227-
"Self argument missing for a non-static method (or an invalid type for self)"
227+
'"self" parameter missing for a non-static method (or an invalid type for self)'
228228
)
229229
ERASED_SELF_TYPE_NOT_SUPERTYPE: Final = ErrorMessage(
230230
'The erased type of self "{}" is not a supertype of its class "{}"'
@@ -308,14 +308,14 @@ def with_additional_msg(self, info: str) -> ErrorMessage:
308308
TYPE_COMMENT_SYNTAX_ERROR_VALUE: Final = ErrorMessage(
309309
'Syntax error in type comment "{}"', codes.SYNTAX
310310
)
311-
ELLIPSIS_WITH_OTHER_TYPEARGS: Final = ErrorMessage(
312-
"Ellipses cannot accompany other argument types in function type signature", codes.SYNTAX
311+
ELLIPSIS_WITH_OTHER_TYPEPARAMS: Final = ErrorMessage(
312+
"Ellipses cannot accompany other parameter types in function type signature", codes.SYNTAX
313313
)
314-
TYPE_SIGNATURE_TOO_MANY_ARGS: Final = ErrorMessage(
315-
"Type signature has too many arguments", codes.SYNTAX
314+
TYPE_SIGNATURE_TOO_MANY_PARAMS: Final = ErrorMessage(
315+
"Type signature has too many parameters", codes.SYNTAX
316316
)
317-
TYPE_SIGNATURE_TOO_FEW_ARGS: Final = ErrorMessage(
318-
"Type signature has too few arguments", codes.SYNTAX
317+
TYPE_SIGNATURE_TOO_FEW_PARAMS: Final = ErrorMessage(
318+
"Type signature has too few parameters", codes.SYNTAX
319319
)
320320
ARG_CONSTRUCTOR_NAME_EXPECTED: Final = ErrorMessage("Expected arg constructor name", codes.SYNTAX)
321321
ARG_CONSTRUCTOR_TOO_MANY_ARGS: Final = ErrorMessage(

test-data/unit/check-classes.test

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7836,7 +7836,7 @@ def to_same_callable(fn: Callable[P, T]) -> Callable[P, T]:
78367836
class A:
78377837
def undecorated() -> None: ... # E: Method must have at least one argument. Did you forget the "self" argument?
78387838

7839-
def undecorated_not_self(x: int) -> None: ... # E: Self argument missing for a non-static method (or an invalid type for self)
7839+
def undecorated_not_self(x: int) -> None: ... # E: "self" parameter missing for a non-static method (or an invalid type for self)
78407840

78417841
def undecorated_not_self_2(self: int) -> None: ... # E: The erased type of self "builtins.int" is not a supertype of its class "__main__.A"
78427842

@@ -7864,7 +7864,7 @@ class A:
78647864
def g1() -> None: ... # E: Method must have at least one argument. Did you forget the "self" argument?
78657865

78667866
@to_same_callable
7867-
def g2(x: int) -> None: ... # E: Self argument missing for a non-static method (or an invalid type for self)
7867+
def g2(x: int) -> None: ... # E: "self" parameter missing for a non-static method (or an invalid type for self)
78687868

78697869
@to_same_callable
78707870
def g3(self: int) -> None: ... # E: The erased type of self "builtins.int" is not a supertype of its class "__main__.A"
@@ -7909,7 +7909,7 @@ class A:
79097909
return 0
79107910

79117911
@to_same_callable
7912-
def fn2(_x: int) -> int: # E: Self argument missing for a non-static method (or an invalid type for self)
7912+
def fn2(_x: int) -> int: # E: "self" parameter missing for a non-static method (or an invalid type for self)
79137913
return 0
79147914

79157915
@to_same_callable
@@ -7931,7 +7931,7 @@ class B:
79317931
return 0
79327932

79337933
@remove_first
7934-
def fn3(self, _x: int) -> int: # E: Self argument missing for a non-static method (or an invalid type for self)
7934+
def fn3(self, _x: int) -> int: # E: "self" parameter missing for a non-static method (or an invalid type for self)
79357935
return 0
79367936

79377937
@remove_first
@@ -7965,15 +7965,15 @@ reveal_type(C().fn3) # N: Revealed type is "def (self: __main__.C, _x: builtins
79657965

79667966
class D:
79677967
@add_wrong_first
7968-
def fn1() -> int: # E: Self argument missing for a non-static method (or an invalid type for self)
7968+
def fn1() -> int: # E: "self" parameter missing for a non-static method (or an invalid type for self)
79697969
return 0
79707970

79717971
@add_wrong_first
7972-
def fn2(_x: int) -> int: # E: Self argument missing for a non-static method (or an invalid type for self)
7972+
def fn2(_x: int) -> int: # E: "self" parameter missing for a non-static method (or an invalid type for self)
79737973
return 0
79747974

79757975
@add_wrong_first
7976-
def fn3(self, _x: int) -> int: # E: Self argument missing for a non-static method (or an invalid type for self)
7976+
def fn3(self, _x: int) -> int: # E: "self" parameter missing for a non-static method (or an invalid type for self)
79777977
return 0
79787978

79797979
reveal_type(D().fn1) # E: Invalid self argument "D" to attribute function "fn1" with type "Callable[[int], int]" \
@@ -7996,7 +7996,7 @@ def to_same_callable(fn: Callable[P, T]) -> Callable[P, T]:
79967996
def unchecked():
79977997
class Bad:
79987998
def fn() -> None: ... # E: Method must have at least one argument. Did you forget the "self" argument?
7999-
def fn2(x: int) -> None: ... # E: Self argument missing for a non-static method (or an invalid type for self)
7999+
def fn2(x: int) -> None: ... # E: "self" parameter missing for a non-static method (or an invalid type for self)
80008000

80018001
# TODO: would be nice to make this error, but now we see the func
80028002
# being decorated as Any, not as a callable
@@ -8017,12 +8017,12 @@ def unchecked():
80178017
def checked() -> None:
80188018
class Bad:
80198019
def fn() -> None: ... # E: Method must have at least one argument. Did you forget the "self" argument?
8020-
def fn2(x: int) -> None: ... # E: Self argument missing for a non-static method (or an invalid type for self)
8020+
def fn2(x: int) -> None: ... # E: "self" parameter missing for a non-static method (or an invalid type for self)
80218021

80228022
@to_same_callable
80238023
def g() -> None: ... # E: Method must have at least one argument. Did you forget the "self" argument?
80248024
@to_same_callable
8025-
def g2(x: int) -> None: ... # E: Self argument missing for a non-static method (or an invalid type for self)
8025+
def g2(x: int) -> None: ... # E: "self" parameter missing for a non-static method (or an invalid type for self)
80268026

80278027
class AlsoBad:
80288028
def fn(): ... # E: Method must have at least one argument. Did you forget the "self" argument?

test-data/unit/check-columns.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ x = cast(int, y) # E:5: Redundant cast to "int"
298298

299299
[case testColumnTypeSignatureHasTooFewArguments]
300300
if int():
301-
def f(x, y): # E:5: Type signature has too few arguments
301+
def f(x, y): # E:5: Type signature has too few parameters
302302
# type: (int) -> None
303303
pass
304304

test-data/unit/check-errorcodes.test

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ main:1: error: Invalid syntax [syntax]
3838
main:1: error: Invalid syntax. Perhaps you forgot a comma? [syntax]
3939

4040
[case testErrorCodeSyntaxError2]
41-
def f(): # E: Type signature has too many arguments [syntax]
41+
def f(): # E: Type signature has too many parameters [syntax]
4242
# type: (int) -> None
4343
1
4444

@@ -382,7 +382,7 @@ def f(x): # E: Function is missing a type annotation [no-untyped-def]
382382
def g(x: int): # E: Function is missing a return type annotation [no-untyped-def]
383383
pass
384384

385-
def h(x) -> None: # E: Function is missing a type annotation for one or more arguments [no-untyped-def]
385+
def h(x) -> None: # E: Function is missing a type annotation for one or more parameters [no-untyped-def]
386386
pass
387387

388388
def gen(): # E: Function is missing a return type annotation [no-untyped-def]
@@ -546,11 +546,11 @@ from typing import cast
546546
x = cast(int, int()) # E: Redundant cast to "int" [redundant-cast]
547547

548548
[case testErrorCodeInvalidCommentSignature]
549-
def f(x): # E: Type signature has too few arguments [syntax]
549+
def f(x): # E: Type signature has too few parameters [syntax]
550550
# type: () -> None
551551
pass
552552

553-
def g(x): # E: Type signature has too many arguments [syntax]
553+
def g(x): # E: Type signature has too many parameters [syntax]
554554
# type: (int, int) -> None
555555
pass
556556

test-data/unit/check-fastparse.test

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,15 +178,15 @@ def f(*,
178178
[out]
179179

180180
[case testFasterParseTooManyArgumentsAnnotation]
181-
def f(): # E: Type signature has too many arguments
181+
def f(): # E: Type signature has too many parameters
182182
# type: (int) -> None
183183
pass
184184

185185
f()
186186
f(1) # E: Too many arguments for "f"
187187

188188
[case testFasterParseTooFewArgumentsAnnotation]
189-
def f(x, y): # E: Type signature has too few arguments
189+
def f(x, y): # E: Type signature has too few parameters
190190
# type: (int) -> None
191191
x()
192192
y()
@@ -215,10 +215,10 @@ x @ 1
215215
x @= 1
216216

217217
[case testFastParserShowsMultipleErrors]
218-
def f(x): # E: Type signature has too few arguments
218+
def f(x): # E: Type signature has too few parameters
219219
# type: () -> None
220220
pass
221-
def g(): # E: Type signature has too many arguments
221+
def g(): # E: Type signature has too many parameters
222222
# type: (int) -> None
223223
pass
224224

test-data/unit/check-flags.test

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ main:2: error: Function is missing a type annotation
88
# flags: --disallow-untyped-defs
99
def f(x) -> int: pass
1010
[out]
11-
main:2: error: Function is missing a type annotation for one or more arguments
11+
main:2: error: Function is missing a type annotation for one or more parameters
1212

1313
[case testNoArgumentFunction]
1414
# flags: --disallow-untyped-defs
@@ -63,7 +63,7 @@ async def f(): # E: Function is missing a return type annotation \
6363

6464
[case testAsyncUnannotatedArgument]
6565
# flags: --disallow-untyped-defs
66-
async def f(x) -> None: # E: Function is missing a type annotation for one or more arguments
66+
async def f(x) -> None: # E: Function is missing a type annotation for one or more parameters
6767
pass
6868
[builtins fixtures/async_await.pyi]
6969
[typing fixtures/typing-async.pyi]
@@ -830,7 +830,7 @@ import standard, incomplete
830830
def incomplete(x) -> int:
831831
return 0
832832
[file incomplete.py]
833-
def incomplete(x) -> int: # E: Function is missing a type annotation for one or more arguments
833+
def incomplete(x) -> int: # E: Function is missing a type annotation for one or more parameters
834834
return 0
835835
[file mypy.ini]
836836
\[mypy]
@@ -847,7 +847,7 @@ import standard, incomplete
847847
def incomplete(x) -> int:
848848
return 0
849849
[file incomplete.py]
850-
def incomplete(x) -> int: # E: Function is missing a type annotation for one or more arguments
850+
def incomplete(x) -> int: # E: Function is missing a type annotation for one or more parameters
851851
return 0
852852
[file pyproject.toml]
853853
\[tool.mypy]
@@ -1555,7 +1555,7 @@ def g(m: Movie) -> Movie:
15551555

15561556
def f(i: int): # E: Function is missing a return type annotation
15571557
pass
1558-
def g(i) -> None: # E: Function is missing a type annotation for one or more arguments
1558+
def g(i) -> None: # E: Function is missing a type annotation for one or more parameters
15591559
pass
15601560
def h(i: int) -> int: # no error
15611561
return i
@@ -1582,7 +1582,7 @@ def f(i: int, s):
15821582

15831583
[out]
15841584
main:3: error: Function is missing a return type annotation
1585-
main:3: error: Function is missing a type annotation for one or more arguments
1585+
main:3: error: Function is missing a type annotation for one or more parameters
15861586

15871587
[case testDisallowIncompleteDefsAttrsNoAnnotations]
15881588
# flags: --disallow-incomplete-defs
@@ -1609,7 +1609,7 @@ class Annotated:
16091609
import attrs
16101610

16111611
@attrs.define
1612-
class PartiallyAnnotated: # E: Function is missing a type annotation for one or more arguments
1612+
class PartiallyAnnotated: # E: Function is missing a type annotation for one or more parameters
16131613
bar: int = attrs.field()
16141614
baz = attrs.field()
16151615

test-data/unit/check-functions.test

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,7 @@ main:8: error: Argument 1 to "g" has incompatible type "A"; expected "int"
778778
class A:
779779
def f(self):
780780
# type: () -> None
781-
def g(x): # E: Type signature has too few arguments
781+
def g(x): # E: Type signature has too few parameters
782782
# type: () -> None
783783
pass
784784

@@ -802,7 +802,7 @@ class A:
802802
class B:
803803
def g(self):
804804
# type: () -> None
805-
def h(x): # E: Type signature has too few arguments
805+
def h(x): # E: Type signature has too few parameters
806806
# type: () -> None
807807
pass
808808

@@ -2143,13 +2143,13 @@ class A:
21432143
def f(x, y, z): # type: (..., int) -> None
21442144
pass
21452145
[out]
2146-
main:1: error: Ellipses cannot accompany other argument types in function type signature
2146+
main:1: error: Ellipses cannot accompany other parameter types in function type signature
21472147

21482148
[case testEllipsisWithSomethingBeforeItFails]
21492149
def f(x, y, z): # type: (int, ...) -> None
21502150
pass
21512151
[out]
2152-
main:1: error: Ellipses cannot accompany other argument types in function type signature
2152+
main:1: error: Ellipses cannot accompany other parameter types in function type signature
21532153

21542154
[case testRejectCovariantArgument]
21552155
from typing import TypeVar, Generic

test-data/unit/check-overloading.test

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4347,7 +4347,7 @@ class Wrapper2:
43474347
@staticmethod
43484348
def foo(x: int) -> int: ...
43494349
@overload
4350-
def foo(x: str) -> str: ... # E: Self argument missing for a non-static method (or an invalid type for self)
4350+
def foo(x: str) -> str: ... # E: "self" parameter missing for a non-static method (or an invalid type for self)
43514351
@staticmethod
43524352
def foo(x): pass
43534353

@@ -4358,7 +4358,7 @@ class Wrapper3:
43584358
@overload
43594359
@staticmethod
43604360
def foo(x: str) -> str: ...
4361-
def foo(x: Union[int, str]): pass # E: Self argument missing for a non-static method (or an invalid type for self)
4361+
def foo(x: Union[int, str]): pass # E: "self" parameter missing for a non-static method (or an invalid type for self)
43624362
[builtins fixtures/staticmethod.pyi]
43634363

43644364
[case testOverloadWithSwappedDecorators2]
@@ -4394,7 +4394,7 @@ class Wrapper3:
43944394
def foo(x: int) -> int: ...
43954395

43964396
@overload
4397-
def foo(x: str) -> str: ... # E: Self argument missing for a non-static method (or an invalid type for self)
4397+
def foo(x: str) -> str: ... # E: "self" parameter missing for a non-static method (or an invalid type for self)
43984398

43994399
@staticmethod
44004400
def foo(x): pass

0 commit comments

Comments
 (0)