From 73480b22a5d1b158384dc0da3d6047f7e1c53c14 Mon Sep 17 00:00:00 2001 From: "Kai (Kazuya Ito)" Date: Sat, 28 Feb 2026 22:36:04 +0900 Subject: [PATCH 1/4] Update error message for type application support --- mypy/message_registry.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mypy/message_registry.py b/mypy/message_registry.py index 9de31514b6bd..47adb6b18b31 100644 --- a/mypy/message_registry.py +++ b/mypy/message_registry.py @@ -121,7 +121,7 @@ def with_additional_msg(self, info: str) -> ErrorMessage: "Function is missing a type annotation", codes.NO_UNTYPED_DEF ) ONLY_CLASS_APPLICATION: Final = ErrorMessage( - "Type application is only supported for generic classes" + "Type application is only supported for generic classes and type aliases" ) RETURN_TYPE_EXPECTED: Final = ErrorMessage( "Function is missing a return type annotation", codes.NO_UNTYPED_DEF From a96eda4b2a204e23b60a4a55936948f10882558b Mon Sep 17 00:00:00 2001 From: "Kai (Kazuya Ito)" Date: Sat, 28 Feb 2026 22:38:46 +0900 Subject: [PATCH 2/4] Clarify error messages for type applications --- test-data/unit/check-generics.test | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test-data/unit/check-generics.test b/test-data/unit/check-generics.test index 26d709850c1e..6cfc416bcbaf 100644 --- a/test-data/unit/check-generics.test +++ b/test-data/unit/check-generics.test @@ -426,7 +426,7 @@ from typing import TypeVar T = TypeVar('T') def f(x: T) -> T: pass -y = f[int] # E: Type application is only supported for generic classes +y = f[int] # E: Type application is only supported for generic classes and type aliases [out] @@ -1004,7 +1004,7 @@ reveal_type(y) # N: Revealed type is "builtins.int" U[int] # E: Type application targets a non-generic function or class O[int] # E: Bad number of arguments for type alias, expected 0, given 1 \ - # E: Type application is only supported for generic classes + # E: Type application is only supported for generic classes and type aliases [case testAliasesInClassBodyNormalVsSubscripted] @@ -1072,9 +1072,9 @@ reveal_type(ts) # N: Revealed type is "Any" us = UA.x # E: "" has no attribute "x" reveal_type(us) # N: Revealed type is "Any" -xx = CA[str] + 1 # E: Type application is only supported for generic classes -yy = TA[str]() # E: Type application is only supported for generic classes -zz = UA[str].x # E: Type application is only supported for generic classes +xx = CA[str] + 1 # E: Type application is only supported for generic classes and type aliases +yy = TA[str]() # E: Type application is only supported for generic classes and type aliases +zz = UA[str].x # E: Type application is only supported for generic classes and type aliases [builtins fixtures/tuple.pyi] [typing fixtures/typing-medium.pyi] [out] From 27ff5a64256695d25ff152c6d65af7d70e55b6be Mon Sep 17 00:00:00 2001 From: "Kai (Kazuya Ito)" Date: Sat, 28 Feb 2026 22:39:58 +0900 Subject: [PATCH 3/4] Fix type application error in check-typevar-tuple test --- test-data/unit/check-typevar-tuple.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test-data/unit/check-typevar-tuple.test b/test-data/unit/check-typevar-tuple.test index 874c79df0e19..06e641e056dd 100644 --- a/test-data/unit/check-typevar-tuple.test +++ b/test-data/unit/check-typevar-tuple.test @@ -2763,6 +2763,6 @@ T = TypeVar('T') def func(d: Callable[[Unpack[Ts]], T]) -> T: ... -y = func[1, int] # E: Type application is only supported for generic classes \ +y = func[1, int] # E: Type application is only supported for generic classes and type aliases \ # E: Invalid type: try using Literal[1] instead? [builtins fixtures/tuple.pyi] From 7d799ce84b592a584c4ec5aa005a3002d73238d8 Mon Sep 17 00:00:00 2001 From: "Kai (Kazuya Ito)" Date: Sat, 28 Feb 2026 22:41:16 +0900 Subject: [PATCH 4/4] Clarify error message for type application Updated error message for clarity regarding type application. --- test-data/unit/check-parameter-specification.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test-data/unit/check-parameter-specification.test b/test-data/unit/check-parameter-specification.test index b0808105a385..edae5e58784b 100644 --- a/test-data/unit/check-parameter-specification.test +++ b/test-data/unit/check-parameter-specification.test @@ -92,7 +92,7 @@ class B(Generic[P]): ... Other = B[P] T = TypeVar('T', bound=Alias[..., Any]) -Alias[..., Any] # E: Type application is only supported for generic classes +Alias[..., Any] # E: Type application is only supported for generic classes and type aliases B[...] Other[...] [builtins fixtures/paramspec.pyi]