Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
58988cc
Update error message for missing argument type annotation
hyperkai Jan 31, 2026
416a76a
Update error messages for missing type annotations
hyperkai Jan 31, 2026
8c5d9cb
Fix type annotation error messages in tests
hyperkai Jan 31, 2026
d29c114
Fix type annotation error message in test
hyperkai Jan 31, 2026
a894621
Fix wording in error message for self parameter
hyperkai Feb 1, 2026
5343adb
Update check-classes.test
hyperkai Feb 1, 2026
a927084
Update check-selftype.test
hyperkai Feb 1, 2026
1a7ac4f
Update check-overloading.test
hyperkai Feb 1, 2026
f5551e0
Update message_registry.py
hyperkai Feb 1, 2026
62f2204
Update check-functions.test
hyperkai Feb 1, 2026
79f7b11
Update message_registry.py
hyperkai Feb 1, 2026
48c627c
Update check-fastparse.test
hyperkai Feb 1, 2026
f53a296
Update parse-errors.test
hyperkai Feb 1, 2026
9d0ae67
Update semanal-errors.test
hyperkai Feb 1, 2026
5458f4d
Update check-errorcodes.test
hyperkai Feb 1, 2026
5c8534b
Update message_registry.py
hyperkai Feb 1, 2026
8afa534
Update check-fastparse.test
hyperkai Feb 1, 2026
1755885
Update parse-errors.test
hyperkai Feb 1, 2026
47764f4
Update check-columns.test
hyperkai Feb 1, 2026
30dca1e
Update fine-grained.test
hyperkai Feb 1, 2026
6b9bde7
Update semanal-errors.test
hyperkai Feb 1, 2026
90e6954
Update check-functions.test
hyperkai Feb 1, 2026
4566bd1
Update check-errorcodes.test
hyperkai Feb 1, 2026
b9ab2a7
Update message_registry.py
hyperkai Feb 1, 2026
605c8b9
Update message_registry.py
hyperkai Feb 1, 2026
2d825fc
Update fastparse.py
hyperkai Feb 1, 2026
14ac318
Update fastparse.py
hyperkai Feb 1, 2026
24f8fba
Update checker.py
hyperkai Feb 1, 2026
cb7277a
Update message_registry.py
hyperkai Feb 1, 2026
6116842
Update message_registry.py
hyperkai Feb 1, 2026
db4ac33
Update message_registry.py
hyperkai Feb 2, 2026
5cd99e6
Update check-classes.test
hyperkai Feb 2, 2026
1c7535f
Update check-selftype.test
hyperkai Feb 2, 2026
c7e904c
Update check-overloading.test
hyperkai Feb 2, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions mypy/message_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def with_additional_msg(self, info: str) -> 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
"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"'
Expand Down Expand Up @@ -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)"
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also changed Self to self which is actually used as a parameter because It's more understandable:

class Cls:  # ↓↓↓↓
   def method(self) -> None: ...

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be more consistent to use "self" parameter ... if using the lower-case version. I'd prefer it it was either quoted this way (we use double quotes) or unchanged from original, with capitalized 'Self'.

)
ERASED_SELF_TYPE_NOT_SUPERTYPE: Final = ErrorMessage(
'The erased type of self "{}" is not a supertype of its class "{}"'
Expand Down
2 changes: 1 addition & 1 deletion test-data/unit/check-errorcodes.test
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
14 changes: 7 additions & 7 deletions test-data/unit/check-flags.test
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand All @@ -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]
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion test-data/unit/check-python38.test
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Loading