diff --git a/mypy/checker.py b/mypy/checker.py index d371f40ccaae..060be2c39b1f 100644 --- a/mypy/checker.py +++ b/mypy/checker.py @@ -1792,7 +1792,7 @@ def is_unannotated_any(t: Type) -> bool: if is_unannotated_any(self.get_coroutine_return_type(ret_type)): self.fail(message_registry.RETURN_TYPE_EXPECTED, fdef) if any(is_unannotated_any(t) for t in fdef.type.arg_types): - self.fail(message_registry.ARGUMENT_TYPE_EXPECTED, fdef) + self.fail(message_registry.PARAM_TYPE_EXPECTED, fdef) def check___new___signature(self, fdef: FuncDef, typ: CallableType) -> None: self_type = fill_typevars_with_any(fdef.info) diff --git a/mypy/fastparse.py b/mypy/fastparse.py index a8ed5eb038f5..8ef905a567d1 100644 --- a/mypy/fastparse.py +++ b/mypy/fastparse.py @@ -1001,21 +1001,21 @@ def do_func_def( if any(arg_types) or return_type: if len(arg_types) != 1 and any(isinstance(t, EllipsisType) for t in arg_types): self.fail( - message_registry.ELLIPSIS_WITH_OTHER_TYPEARGS, + message_registry.ELLIPSIS_WITH_OTHER_TYPEPARAMS, lineno, n.col_offset, blocker=False, ) elif len(arg_types) > len(arg_kinds): self.fail( - message_registry.TYPE_SIGNATURE_TOO_MANY_ARGS, + message_registry.TYPE_SIGNATURE_TOO_MANY_PARAMS, lineno, n.col_offset, blocker=False, ) elif len(arg_types) < len(arg_kinds): self.fail( - message_registry.TYPE_SIGNATURE_TOO_FEW_ARGS, + message_registry.TYPE_SIGNATURE_TOO_FEW_PARAMS, lineno, n.col_offset, blocker=False, diff --git a/mypy/message_registry.py b/mypy/message_registry.py index cfeb27b1a5c9..61a0764bd483 100644 --- a/mypy/message_registry.py +++ b/mypy/message_registry.py @@ -126,8 +126,8 @@ def with_additional_msg(self, info: str) -> ErrorMessage: RETURN_TYPE_EXPECTED: Final = ErrorMessage( "Function is missing a return type annotation", codes.NO_UNTYPED_DEF ) -ARGUMENT_TYPE_EXPECTED: Final = ErrorMessage( - "Function is missing a type annotation for one or more arguments", codes.NO_UNTYPED_DEF +PARAM_TYPE_EXPECTED: Final = ErrorMessage( + "Function is missing a type annotation for one or more parameters", codes.NO_UNTYPED_DEF ) KEYWORD_ARGUMENT_REQUIRES_STR_KEY_TYPE: Final = ErrorMessage( 'Keyword argument only valid with "str" key type in call to "dict"' @@ -224,7 +224,7 @@ def with_additional_msg(self, info: str) -> ErrorMessage: # Self-type MISSING_OR_INVALID_SELF_TYPE: Final = ErrorMessage( - "Self argument missing for a non-static method (or an invalid type for self)" + "self parameter missing for a non-static method (or an invalid type for self)" ) ERASED_SELF_TYPE_NOT_SUPERTYPE: Final = ErrorMessage( 'The erased type of self "{}" is not a supertype of its class "{}"' @@ -308,14 +308,14 @@ def with_additional_msg(self, info: str) -> ErrorMessage: TYPE_COMMENT_SYNTAX_ERROR_VALUE: Final = ErrorMessage( 'Syntax error in type comment "{}"', codes.SYNTAX ) -ELLIPSIS_WITH_OTHER_TYPEARGS: Final = ErrorMessage( - "Ellipses cannot accompany other argument types in function type signature", codes.SYNTAX +ELLIPSIS_WITH_OTHER_TYPEPARAMS: Final = ErrorMessage( + "Ellipses cannot accompany other parameter types in function type signature", codes.SYNTAX ) -TYPE_SIGNATURE_TOO_MANY_ARGS: Final = ErrorMessage( - "Type signature has too many arguments", codes.SYNTAX +TYPE_SIGNATURE_TOO_MANY_PARAMS: Final = ErrorMessage( + "Type signature has too many parameters", codes.SYNTAX ) -TYPE_SIGNATURE_TOO_FEW_ARGS: Final = ErrorMessage( - "Type signature has too few arguments", codes.SYNTAX +TYPE_SIGNATURE_TOO_FEW_PARAMS: Final = ErrorMessage( + "Type signature has too few parameters", codes.SYNTAX ) ARG_CONSTRUCTOR_NAME_EXPECTED: Final = ErrorMessage("Expected arg constructor name", codes.SYNTAX) ARG_CONSTRUCTOR_TOO_MANY_ARGS: Final = ErrorMessage( diff --git a/test-data/unit/check-classes.test b/test-data/unit/check-classes.test index 7fd96f9abf94..c458b59ba7d2 100644 --- a/test-data/unit/check-classes.test +++ b/test-data/unit/check-classes.test @@ -7836,7 +7836,7 @@ def to_same_callable(fn: Callable[P, T]) -> Callable[P, T]: class A: def undecorated() -> None: ... # E: Method must have at least one argument. Did you forget the "self" argument? - def undecorated_not_self(x: int) -> None: ... # E: Self argument missing for a non-static method (or an invalid type for self) + def undecorated_not_self(x: int) -> None: ... # E: self parameter missing for a non-static method (or an invalid type for self) 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" @@ -7864,7 +7864,7 @@ class A: def g1() -> None: ... # E: Method must have at least one argument. Did you forget the "self" argument? @to_same_callable - def g2(x: int) -> None: ... # E: Self argument missing for a non-static method (or an invalid type for self) + def g2(x: int) -> None: ... # E: self parameter missing for a non-static method (or an invalid type for self) @to_same_callable 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: return 0 @to_same_callable - def fn2(_x: int) -> int: # E: Self argument missing for a non-static method (or an invalid type for self) + def fn2(_x: int) -> int: # E: self parameter missing for a non-static method (or an invalid type for self) return 0 @to_same_callable @@ -7931,7 +7931,7 @@ class B: return 0 @remove_first - def fn3(self, _x: int) -> int: # E: Self argument missing for a non-static method (or an invalid type for self) + def fn3(self, _x: int) -> int: # E: self parameter missing for a non-static method (or an invalid type for self) return 0 @remove_first @@ -7965,15 +7965,15 @@ reveal_type(C().fn3) # N: Revealed type is "def (self: __main__.C, _x: builtins class D: @add_wrong_first - def fn1() -> int: # E: Self argument missing for a non-static method (or an invalid type for self) + def fn1() -> int: # E: self parameter missing for a non-static method (or an invalid type for self) return 0 @add_wrong_first - def fn2(_x: int) -> int: # E: Self argument missing for a non-static method (or an invalid type for self) + def fn2(_x: int) -> int: # E: self parameter missing for a non-static method (or an invalid type for self) return 0 @add_wrong_first - def fn3(self, _x: int) -> int: # E: Self argument missing for a non-static method (or an invalid type for self) + def fn3(self, _x: int) -> int: # E: self parameter missing for a non-static method (or an invalid type for self) return 0 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]: def unchecked(): class Bad: def fn() -> None: ... # E: Method must have at least one argument. Did you forget the "self" argument? - def fn2(x: int) -> None: ... # E: Self argument missing for a non-static method (or an invalid type for self) + def fn2(x: int) -> None: ... # E: self parameter missing for a non-static method (or an invalid type for self) # TODO: would be nice to make this error, but now we see the func # being decorated as Any, not as a callable @@ -8017,12 +8017,12 @@ def unchecked(): def checked() -> None: class Bad: def fn() -> None: ... # E: Method must have at least one argument. Did you forget the "self" argument? - def fn2(x: int) -> None: ... # E: Self argument missing for a non-static method (or an invalid type for self) + def fn2(x: int) -> None: ... # E: self parameter missing for a non-static method (or an invalid type for self) @to_same_callable def g() -> None: ... # E: Method must have at least one argument. Did you forget the "self" argument? @to_same_callable - def g2(x: int) -> None: ... # E: Self argument missing for a non-static method (or an invalid type for self) + def g2(x: int) -> None: ... # E: self parameter missing for a non-static method (or an invalid type for self) class AlsoBad: def fn(): ... # E: Method must have at least one argument. Did you forget the "self" argument? diff --git a/test-data/unit/check-columns.test b/test-data/unit/check-columns.test index 8458f0ac27dc..7509fb2d12d9 100644 --- a/test-data/unit/check-columns.test +++ b/test-data/unit/check-columns.test @@ -298,7 +298,7 @@ x = cast(int, y) # E:5: Redundant cast to "int" [case testColumnTypeSignatureHasTooFewArguments] if int(): - def f(x, y): # E:5: Type signature has too few arguments + def f(x, y): # E:5: Type signature has too few parameters # type: (int) -> None pass diff --git a/test-data/unit/check-errorcodes.test b/test-data/unit/check-errorcodes.test index 58f48144b3e5..26831a091f53 100644 --- a/test-data/unit/check-errorcodes.test +++ b/test-data/unit/check-errorcodes.test @@ -38,7 +38,7 @@ main:1: error: Invalid syntax [syntax] main:1: error: Invalid syntax. Perhaps you forgot a comma? [syntax] [case testErrorCodeSyntaxError2] -def f(): # E: Type signature has too many arguments [syntax] +def f(): # E: Type signature has too many parameters [syntax] # type: (int) -> None 1 @@ -382,7 +382,7 @@ def f(x): # E: Function is missing a type annotation [no-untyped-def] def g(x: int): # E: Function is missing a return type annotation [no-untyped-def] pass -def h(x) -> None: # E: Function is missing a type annotation for one or more arguments [no-untyped-def] +def h(x) -> None: # E: Function is missing a type annotation for one or more parameters [no-untyped-def] pass def gen(): # E: Function is missing a return type annotation [no-untyped-def] @@ -545,11 +545,11 @@ from typing import cast x = cast(int, int()) # E: Redundant cast to "int" [redundant-cast] [case testErrorCodeInvalidCommentSignature] -def f(x): # E: Type signature has too few arguments [syntax] +def f(x): # E: Type signature has too few parameters [syntax] # type: () -> None pass -def g(x): # E: Type signature has too many arguments [syntax] +def g(x): # E: Type signature has too many parameters [syntax] # type: (int, int) -> None pass diff --git a/test-data/unit/check-fastparse.test b/test-data/unit/check-fastparse.test index f1c0716e9fb8..4eef7a0e116c 100644 --- a/test-data/unit/check-fastparse.test +++ b/test-data/unit/check-fastparse.test @@ -178,7 +178,7 @@ def f(*, [out] [case testFasterParseTooManyArgumentsAnnotation] -def f(): # E: Type signature has too many arguments +def f(): # E: Type signature has too many parameters # type: (int) -> None pass @@ -186,7 +186,7 @@ f() f(1) # E: Too many arguments for "f" [case testFasterParseTooFewArgumentsAnnotation] -def f(x, y): # E: Type signature has too few arguments +def f(x, y): # E: Type signature has too few parameters # type: (int) -> None x() y() @@ -215,10 +215,10 @@ x @ 1 x @= 1 [case testFastParserShowsMultipleErrors] -def f(x): # E: Type signature has too few arguments +def f(x): # E: Type signature has too few parameters # type: () -> None pass -def g(): # E: Type signature has too many arguments +def g(): # E: Type signature has too many parameters # type: (int) -> None pass diff --git a/test-data/unit/check-flags.test b/test-data/unit/check-flags.test index 94aae547882f..5c77a3e81f0d 100644 --- a/test-data/unit/check-flags.test +++ b/test-data/unit/check-flags.test @@ -8,7 +8,7 @@ main:2: error: Function is missing a type annotation # flags: --disallow-untyped-defs def f(x) -> int: pass [out] -main:2: error: Function is missing a type annotation for one or more arguments +main:2: error: Function is missing a type annotation for one or more parameters [case testNoArgumentFunction] # flags: --disallow-untyped-defs @@ -63,7 +63,7 @@ async def f(): # E: Function is missing a return type annotation \ [case testAsyncUnannotatedArgument] # flags: --disallow-untyped-defs -async def f(x) -> None: # E: Function is missing a type annotation for one or more arguments +async def f(x) -> None: # E: Function is missing a type annotation for one or more parameters pass [builtins fixtures/async_await.pyi] [typing fixtures/typing-async.pyi] @@ -830,7 +830,7 @@ import standard, incomplete def incomplete(x) -> int: return 0 [file incomplete.py] -def incomplete(x) -> int: # E: Function is missing a type annotation for one or more arguments +def incomplete(x) -> int: # E: Function is missing a type annotation for one or more parameters return 0 [file mypy.ini] \[mypy] @@ -847,7 +847,7 @@ import standard, incomplete def incomplete(x) -> int: return 0 [file incomplete.py] -def incomplete(x) -> int: # E: Function is missing a type annotation for one or more arguments +def incomplete(x) -> int: # E: Function is missing a type annotation for one or more parameters return 0 [file pyproject.toml] \[tool.mypy] @@ -1555,7 +1555,7 @@ def g(m: Movie) -> Movie: def f(i: int): # E: Function is missing a return type annotation pass -def g(i) -> None: # E: Function is missing a type annotation for one or more arguments +def g(i) -> None: # E: Function is missing a type annotation for one or more parameters pass def h(i: int) -> int: # no error return i @@ -1582,7 +1582,7 @@ def f(i: int, s): [out] main:3: error: Function is missing a return type annotation -main:3: error: Function is missing a type annotation for one or more arguments +main:3: error: Function is missing a type annotation for one or more parameters [case testDisallowIncompleteDefsAttrsNoAnnotations] # flags: --disallow-incomplete-defs @@ -1609,7 +1609,7 @@ class Annotated: import attrs @attrs.define -class PartiallyAnnotated: # E: Function is missing a type annotation for one or more arguments +class PartiallyAnnotated: # E: Function is missing a type annotation for one or more parameters bar: int = attrs.field() baz = attrs.field() diff --git a/test-data/unit/check-functions.test b/test-data/unit/check-functions.test index a0762ab78f48..8ce971580714 100644 --- a/test-data/unit/check-functions.test +++ b/test-data/unit/check-functions.test @@ -778,7 +778,7 @@ main:8: error: Argument 1 to "g" has incompatible type "A"; expected "int" class A: def f(self): # type: () -> None - def g(x): # E: Type signature has too few arguments + def g(x): # E: Type signature has too few parameters # type: () -> None pass @@ -802,7 +802,7 @@ class A: class B: def g(self): # type: () -> None - def h(x): # E: Type signature has too few arguments + def h(x): # E: Type signature has too few parameters # type: () -> None pass @@ -2143,13 +2143,13 @@ class A: def f(x, y, z): # type: (..., int) -> None pass [out] -main:1: error: Ellipses cannot accompany other argument types in function type signature +main:1: error: Ellipses cannot accompany other parameter types in function type signature [case testEllipsisWithSomethingBeforeItFails] def f(x, y, z): # type: (int, ...) -> None pass [out] -main:1: error: Ellipses cannot accompany other argument types in function type signature +main:1: error: Ellipses cannot accompany other parameter types in function type signature [case testRejectCovariantArgument] from typing import TypeVar, Generic diff --git a/test-data/unit/check-overloading.test b/test-data/unit/check-overloading.test index 5a445c818218..0d9ce42f148f 100644 --- a/test-data/unit/check-overloading.test +++ b/test-data/unit/check-overloading.test @@ -4347,7 +4347,7 @@ class Wrapper2: @staticmethod def foo(x: int) -> int: ... @overload - def foo(x: str) -> str: ... # E: Self argument missing for a non-static method (or an invalid type for self) + def foo(x: str) -> str: ... # E: self parameter missing for a non-static method (or an invalid type for self) @staticmethod def foo(x): pass @@ -4358,7 +4358,7 @@ class Wrapper3: @overload @staticmethod def foo(x: str) -> str: ... - def foo(x: Union[int, str]): pass # E: Self argument missing for a non-static method (or an invalid type for self) + def foo(x: Union[int, str]): pass # E: self parameter missing for a non-static method (or an invalid type for self) [builtins fixtures/staticmethod.pyi] [case testOverloadWithSwappedDecorators2] @@ -4394,7 +4394,7 @@ class Wrapper3: def foo(x: int) -> int: ... @overload - def foo(x: str) -> str: ... # E: Self argument missing for a non-static method (or an invalid type for self) + def foo(x: str) -> str: ... # E: self parameter missing for a non-static method (or an invalid type for self) @staticmethod def foo(x): pass diff --git a/test-data/unit/check-python38.test b/test-data/unit/check-python38.test index 595ff95f44dc..55895e9c6c2b 100644 --- a/test-data/unit/check-python38.test +++ b/test-data/unit/check-python38.test @@ -116,7 +116,7 @@ def g(x: int): ... [case testPEP570ArgTypesMissing] # flags: --disallow-untyped-defs -def f(arg, /) -> None: ... # E: Function is missing a type annotation for one or more arguments +def f(arg, /) -> None: ... # E: Function is missing a type annotation for one or more parameters [case testPEP570ArgTypesBadDefault] def f(arg: int = "ERROR", /) -> None: ... # E: Incompatible default for argument "arg" (default has type "str", argument has type "int") diff --git a/test-data/unit/check-selftype.test b/test-data/unit/check-selftype.test index fe1c903f06ea..afed3fcb65c1 100644 --- a/test-data/unit/check-selftype.test +++ b/test-data/unit/check-selftype.test @@ -1058,7 +1058,7 @@ class A: def f(x: int) -> None: ... def g(self: None) -> None: ... [out] -main:3: error: Self argument missing for a non-static method (or an invalid type for self) +main:3: error: self parameter missing for a non-static method (or an invalid type for self) main:4: error: The erased type of self "None" is not a supertype of its class "__main__.A" [case testUnionPropertyField] diff --git a/test-data/unit/fine-grained.test b/test-data/unit/fine-grained.test index 41fb0ed18ba8..bb9ace3e2670 100644 --- a/test-data/unit/fine-grained.test +++ b/test-data/unit/fine-grained.test @@ -9124,15 +9124,15 @@ x = '' x = 1 [out] -c.py:1: error: Type signature has too few arguments -a.py:1: error: Type signature has too few arguments -a.py:5: error: Type signature has too few arguments -a.py:11: error: Type signature has too few arguments -== -c.py:1: error: Type signature has too few arguments -a.py:1: error: Type signature has too few arguments -a.py:5: error: Type signature has too few arguments -a.py:11: error: Type signature has too few arguments +c.py:1: error: Type signature has too few parameters +a.py:1: error: Type signature has too few parameters +a.py:5: error: Type signature has too few parameters +a.py:11: error: Type signature has too few parameters +== +c.py:1: error: Type signature has too few parameters +a.py:1: error: Type signature has too few parameters +a.py:5: error: Type signature has too few parameters +a.py:11: error: Type signature has too few parameters [case testErrorReportingNewAnalyzer] # flags: --disallow-any-generics diff --git a/test-data/unit/parse-errors.test b/test-data/unit/parse-errors.test index 99baf519e31c..1eb3fbf8cba7 100644 --- a/test-data/unit/parse-errors.test +++ b/test-data/unit/parse-errors.test @@ -248,13 +248,13 @@ file:1: error: Function has duplicate type signatures def f(x, y): # type: (X, Y, Z) -> z pass [out] -file:1: error: Type signature has too many arguments +file:1: error: Type signature has too many parameters [case testTooFewTypes] def f(x, y): # type: (X) -> z pass [out] -file:1: error: Type signature has too few arguments +file:1: error: Type signature has too few parameters [case testCommentFunctionAnnotationVarArgMispatch-skip] # see mypy issue #1997 diff --git a/test-data/unit/semanal-errors.test b/test-data/unit/semanal-errors.test index b69d35ce030e..40db0537c413 100644 --- a/test-data/unit/semanal-errors.test +++ b/test-data/unit/semanal-errors.test @@ -1158,8 +1158,8 @@ def f(): # type: (int) -> int def g(x): # type: () -> int pass [out] -main:2: error: Type signature has too many arguments -main:4: error: Type signature has too few arguments +main:2: error: Type signature has too many parameters +main:4: error: Type signature has too few parameters [case testStaticmethodAndNonMethod] import typing