diff --git a/docs/source/error_code_list2.rst b/docs/source/error_code_list2.rst index bd2436061974..36cf05d4f3f8 100644 --- a/docs/source/error_code_list2.rst +++ b/docs/source/error_code_list2.rst @@ -32,7 +32,7 @@ Example: # mypy: disallow-any-generics - # Error: Missing type parameters for generic type "list" [type-arg] + # Error: Missing type arguments for generic type "list" [type-arg] def remove_dups(items: list) -> list: ... diff --git a/mypy/message_registry.py b/mypy/message_registry.py index b0f9ed1b0dfe..cfeb27b1a5c9 100644 --- a/mypy/message_registry.py +++ b/mypy/message_registry.py @@ -176,7 +176,7 @@ def with_additional_msg(self, info: str) -> ErrorMessage: "Access to generic instance variables via class is ambiguous" ) GENERIC_CLASS_VAR_ACCESS: Final = "Access to generic class variables is ambiguous" -BARE_GENERIC: Final = "Missing type parameters for generic type {}" +BARE_GENERIC: Final = "Missing type arguments for generic type {}" IMPLICIT_GENERIC_ANY_BUILTIN: Final = ( 'Implicit generic "Any". Use "{}" and specify generic parameters' ) diff --git a/test-data/unit/check-columns.test b/test-data/unit/check-columns.test index c822c7c44f41..8458f0ac27dc 100644 --- a/test-data/unit/check-columns.test +++ b/test-data/unit/check-columns.test @@ -263,10 +263,10 @@ class D(A): [case testColumnMissingTypeParameters] # flags: --disallow-any-generics from typing import List, Callable -def f(x: List) -> None: pass # E:10: Missing type parameters for generic type "List" -def g(x: list) -> None: pass # E:10: Missing type parameters for generic type "list" +def f(x: List) -> None: pass # E:10: Missing type arguments for generic type "List" +def g(x: list) -> None: pass # E:10: Missing type arguments for generic type "list" if int(): - c: Callable # E:8: Missing type parameters for generic type "Callable" + c: Callable # E:8: Missing type arguments for generic type "Callable" [builtins fixtures/list.pyi] [case testColumnIncompatibleDefault] diff --git a/test-data/unit/check-errorcodes.test b/test-data/unit/check-errorcodes.test index 31b9c526b6e5..e1805eda7f51 100644 --- a/test-data/unit/check-errorcodes.test +++ b/test-data/unit/check-errorcodes.test @@ -357,11 +357,11 @@ a.x = '' # E: Incompatible types in assignment (expression has type "str", vari [case testErrorCodeMissingTypeArg] # flags: --disallow-any-generics from typing import List, TypeVar -x: List # E: Missing type parameters for generic type "List" [type-arg] -y: list # E: Missing type parameters for generic type "list" [type-arg] +x: List # E: Missing type arguments for generic type "List" [type-arg] +y: list # E: Missing type arguments for generic type "list" [type-arg] T = TypeVar('T') L = List[List[T]] -z: L # E: Missing type parameters for generic type "L" [type-arg] +z: L # E: Missing type arguments for generic type "L" [type-arg] [builtins fixtures/list.pyi] [case testErrorCodeUnionAttribute] diff --git a/test-data/unit/check-flags.test b/test-data/unit/check-flags.test index a892aeba5a2c..8a76cfa9675f 100644 --- a/test-data/unit/check-flags.test +++ b/test-data/unit/check-flags.test @@ -1540,8 +1540,8 @@ from queue import Queue x: Future[str] y: Queue[int] -p: Future # E: Missing type parameters for generic type "Future" -q: Queue # E: Missing type parameters for generic type "Queue" +p: Future # E: Missing type arguments for generic type "Future" +q: Queue # E: Missing type arguments for generic type "Queue" [file asyncio/__init__.pyi] from asyncio.futures import Future as Future [file asyncio/futures.pyi] @@ -1558,25 +1558,25 @@ class Queue(Generic[_T]): ... [case testDisallowAnyGenericsBuiltinTuple] # flags: --disallow-any-generics s = tuple([1, 2, 3]) -def f(t: tuple) -> None: pass # E: Missing type parameters for generic type "tuple" +def f(t: tuple) -> None: pass # E: Missing type arguments for generic type "tuple" [builtins fixtures/tuple.pyi] [case testDisallowAnyGenericsBuiltinList] # flags: --disallow-any-generics l = list([1, 2, 3]) -def f(t: list) -> None: pass # E: Missing type parameters for generic type "list" +def f(t: list) -> None: pass # E: Missing type arguments for generic type "list" [builtins fixtures/list.pyi] [case testDisallowAnyGenericsBuiltinSet] # flags: --disallow-any-generics l = set({1, 2, 3}) -def f(s: set) -> None: pass # E: Missing type parameters for generic type "set" +def f(s: set) -> None: pass # E: Missing type arguments for generic type "set" [builtins fixtures/set.pyi] [case testDisallowAnyGenericsBuiltinDict] # flags: --disallow-any-generics l = dict([('a', 1)]) -def f(d: dict) -> None: pass # E: Missing type parameters for generic type "dict" +def f(d: dict) -> None: pass # E: Missing type arguments for generic type "dict" [builtins fixtures/dict.pyi] [case testCheckDefaultAllowAnyGeneric] @@ -1607,9 +1607,8 @@ from typing import TypeVar, Callable T = TypeVar('T') C = Callable[[], T] -def f(c: C): # E: Missing type parameters for generic type "C" +def f(c: C): # E: Missing type arguments for generic type "C" pass -[out] [case testStrictAnyGeneric] # flags: --strict @@ -1620,9 +1619,8 @@ T = TypeVar('T') class A(Generic[T]): pass -def f(c: A) -> None: # E: Missing type parameters for generic type "A" +def f(c: A) -> None: # E: Missing type arguments for generic type "A" pass -[out] [case testStrictInConfigAnyGeneric] # flags: --config-file tmp/mypy.ini @@ -1633,12 +1631,11 @@ T = TypeVar('T') class A(Generic[T]): pass -def f(c: A) -> None: # E: Missing type parameters for generic type "A" +def f(c: A) -> None: # E: Missing type arguments for generic type "A" pass [file mypy.ini] \[mypy] strict = True -[out] [case testStrictInConfigAnyGenericPyProjectTOML] @@ -1650,15 +1647,13 @@ T = TypeVar('T') class A(Generic[T]): pass -def f(c: A) -> None: # E: Missing type parameters for generic type "A" +def f(c: A) -> None: # E: Missing type arguments for generic type "A" pass [file pyproject.toml] \[tool.mypy] strict = true -[out] - [case testStrictFalseInConfigAnyGeneric] # flags: --config-file tmp/mypy.ini @@ -1856,8 +1851,8 @@ main:2: error: Module "other_module_2" does not explicitly export attribute "a" from typing import List A = List # OK -B = List[A] # E:10: Missing type parameters for generic type "A" -x: A # E:4: Missing type parameters for generic type "A" +B = List[A] # E:10: Missing type arguments for generic type "A" +x: A # E:4: Missing type arguments for generic type "A" [builtins fixtures/list.pyi] [case testDisallowAnyExplicitDefSignature] @@ -1982,20 +1977,20 @@ N = TypedDict('N', {'x': str, 'y': List}) # no error # flags: --disallow-any-generics from typing import Tuple -def f(s: Tuple) -> None: pass # E: Missing type parameters for generic type "Tuple" -def g(s) -> Tuple: # E: Missing type parameters for generic type "Tuple" +def f(s: Tuple) -> None: pass # E: Missing type arguments for generic type "Tuple" +def g(s) -> Tuple: # E: Missing type arguments for generic type "Tuple" return 'a', 'b' def h(s) -> Tuple[str, str]: # no error return 'a', 'b' -x: Tuple = () # E: Missing type parameters for generic type "Tuple" +x: Tuple = () # E: Missing type arguments for generic type "Tuple" [builtins fixtures/tuple.pyi] [case testDisallowAnyGenericsTupleWithNoTypeParamsGeneric] # flags: --disallow-any-generics from typing import Tuple, List -def f(s: Tuple) -> None: pass # E: Missing type parameters for generic type "Tuple" -def g(s: List[Tuple]) -> None: pass # E: Missing type parameters for generic type "Tuple" +def f(s: Tuple) -> None: pass # E: Missing type arguments for generic type "Tuple" +def g(s: List[Tuple]) -> None: pass # E: Missing type arguments for generic type "Tuple" def h(s: List[Tuple[str, str]]) -> None: pass # no error [builtins fixtures/list.pyi] @@ -2004,11 +1999,11 @@ def h(s: List[Tuple[str, str]]) -> None: pass # no error from typing import Type, Any def f(s: Type[Any]) -> None: pass # no error -def g(s) -> Type: # E: Missing type parameters for generic type "Type" +def g(s) -> Type: # E: Missing type arguments for generic type "Type" return s def h(s) -> Type[str]: # no error return s -x: Type = g(0) # E: Missing type parameters for generic type "Type" +x: Type = g(0) # E: Missing type arguments for generic type "Type" [case testDisallowAnyGenericsAliasGenericType] # flags: --disallow-any-generics @@ -2016,7 +2011,7 @@ from typing import List L = List # no error -def f(l: L) -> None: pass # E: Missing type parameters for generic type "L" +def f(l: L) -> None: pass # E: Missing type arguments for generic type "L" def g(l: L[str]) -> None: pass # no error [builtins fixtures/list.pyi] @@ -2027,47 +2022,47 @@ from typing import TypeVar, Tuple T = TypeVar('T') A = Tuple[T, str, T] -def f(s: A) -> None: pass # E: Missing type parameters for generic type "A" -def g(s) -> A: # E: Missing type parameters for generic type "A" +def f(s: A) -> None: pass # E: Missing type arguments for generic type "A" +def g(s) -> A: # E: Missing type arguments for generic type "A" return 'a', 'b', 1 def h(s) -> A[str]: # no error return 'a', 'b', 'c' -x: A = ('a', 'b', 1) # E: Missing type parameters for generic type "A" +x: A = ('a', 'b', 1) # E: Missing type arguments for generic type "A" [builtins fixtures/tuple.pyi] [case testDisallowAnyGenericsPlainList] # flags: --disallow-any-generics from typing import List -def f(l: List) -> None: pass # E: Missing type parameters for generic type "List" +def f(l: List) -> None: pass # E: Missing type arguments for generic type "List" def g(l: List[str]) -> None: pass -def h(l: List[List]) -> None: pass # E: Missing type parameters for generic type "List" -def i(l: List[List[List[List]]]) -> None: pass # E: Missing type parameters for generic type "List" -def j() -> List: pass # E: Missing type parameters for generic type "List" +def h(l: List[List]) -> None: pass # E: Missing type arguments for generic type "List" +def i(l: List[List[List[List]]]) -> None: pass # E: Missing type arguments for generic type "List" +def j() -> List: pass # E: Missing type arguments for generic type "List" x = [] # E: Need type annotation for "x" (hint: "x: list[] = ...") -y: List = [] # E: Missing type parameters for generic type "List" +y: List = [] # E: Missing type arguments for generic type "List" [builtins fixtures/list.pyi] [case testDisallowAnyGenericsPlainDict] # flags: --disallow-any-generics from typing import List, Dict -def f(d: Dict) -> None: pass # E: Missing type parameters for generic type "Dict" -def g(d: Dict[str, Dict]) -> None: pass # E: Missing type parameters for generic type "Dict" -def h(d: List[Dict]) -> None: pass # E: Missing type parameters for generic type "Dict" +def f(d: Dict) -> None: pass # E: Missing type arguments for generic type "Dict" +def g(d: Dict[str, Dict]) -> None: pass # E: Missing type arguments for generic type "Dict" +def h(d: List[Dict]) -> None: pass # E: Missing type arguments for generic type "Dict" -d: Dict = {} # E: Missing type parameters for generic type "Dict" +d: Dict = {} # E: Missing type arguments for generic type "Dict" [builtins fixtures/dict.pyi] [case testDisallowAnyGenericsPlainSet] # flags: --disallow-any-generics from typing import Set -def f(s: Set) -> None: pass # E: Missing type parameters for generic type "Set" -def g(s: Set[Set]) -> None: pass # E: Missing type parameters for generic type "Set" +def f(s: Set) -> None: pass # E: Missing type arguments for generic type "Set" +def g(s: Set[Set]) -> None: pass # E: Missing type arguments for generic type "Set" -s: Set = set() # E: Missing type parameters for generic type "Set" +s: Set = set() # E: Missing type arguments for generic type "Set" [builtins fixtures/set.pyi] [case testDisallowAnyGenericsCustomGenericClass] @@ -2077,11 +2072,11 @@ from typing import Generic, TypeVar, Any T = TypeVar('T') class G(Generic[T]): pass -def f() -> G: # E: Missing type parameters for generic type "G" +def f() -> G: # E: Missing type arguments for generic type "G" return G() x: G[Any] = G() # no error -y: G = x # E: Missing type parameters for generic type "G" +y: G = x # E: Missing type arguments for generic type "G" [case testDisallowAnyGenericsForAliasesInRuntimeContext] # flags: --disallow-any-generics @@ -2093,8 +2088,8 @@ class G(Generic[T]): def foo(cls) -> T: ... A = G[Tuple[T, T]] -A() # E: Missing type parameters for generic type "A" -A.foo() # E: Missing type parameters for generic type "A" +A() # E: Missing type arguments for generic type "A" +A.foo() # E: Missing type arguments for generic type "A" B = G B() @@ -2498,8 +2493,9 @@ from typing import TypeVar, Generic, List, Union class C(Generic[T]): ... -A = Union[C, List] # E: Missing type parameters for generic type "C" \ - # E: Missing type parameters for generic type "List" +A = Union[C, List] # E: Missing type arguments for generic type "C" \ + # E: Missing type arguments for generic type "List" + [builtins fixtures/list.pyi] [case testNestedGenericInAliasAllow] diff --git a/test-data/unit/check-inline-config.test b/test-data/unit/check-inline-config.test index 37d59a84c873..8ada54a06b48 100644 --- a/test-data/unit/check-inline-config.test +++ b/test-data/unit/check-inline-config.test @@ -5,7 +5,7 @@ # mypy: disallow-any-generics, no-warn-no-return from typing import List, Optional -def foo() -> Optional[List]: # E: Missing type parameters for generic type "List" +def foo() -> Optional[List]: # E: Missing type arguments for generic type "List" 20 [builtins fixtures/list.pyi] @@ -16,7 +16,7 @@ def foo() -> Optional[List]: # E: Missing type parameters for generic type "Lis # mypy: no-warn-no-return from typing import List, Optional -def foo() -> Optional[List]: # E: Missing type parameters for generic type "List" +def foo() -> Optional[List]: # E: Missing type arguments for generic type "List" 20 [builtins fixtures/list.pyi] @@ -26,7 +26,7 @@ def foo() -> Optional[List]: # E: Missing type parameters for generic type "Lis # mypy: disallow-any-generics=true, warn-no-return=0 from typing import List, Optional -def foo() -> Optional[List]: # E: Missing type parameters for generic type "List" +def foo() -> Optional[List]: # E: Missing type arguments for generic type "List" 20 [builtins fixtures/list.pyi] @@ -37,7 +37,7 @@ def foo() -> Optional[List]: # E: Missing type parameters for generic type "Lis # mypy: disallow-any-generics = true, warn-no-return = 0 from typing import List, Optional -def foo() -> Optional[List]: # E: Missing type parameters for generic type "List" +def foo() -> Optional[List]: # E: Missing type arguments for generic type "List" 20 [builtins fixtures/list.pyi] @@ -48,7 +48,7 @@ def foo() -> Optional[List]: # E: Missing type parameters for generic type "Lis from typing import List -def foo(FOO: bool, BAR: bool) -> List: # E: Missing type parameters for generic type "List" +def foo(FOO: bool, BAR: bool) -> List: # E: Missing type arguments for generic type "List" if FOO or BAR: 1+'lol' return [] @@ -100,7 +100,7 @@ from typing import List, Optional def foo() -> Optional[List]: 20 [out] -tmp/a.py:4: error: Missing type parameters for generic type "List" +tmp/a.py:4: error: Missing type arguments for generic type "List" [out2] [out3] tmp/a.py:2: error: Missing return statement @@ -123,7 +123,7 @@ def foo() -> Optional[List]: [out] [out2] -tmp/a.py:4: error: Missing type parameters for generic type "List" +tmp/a.py:4: error: Missing type arguments for generic type "List" [builtins fixtures/list.pyi] diff --git a/test-data/unit/check-typeddict.test b/test-data/unit/check-typeddict.test index 29e3a7efbd8c..67a66e18001d 100644 --- a/test-data/unit/check-typeddict.test +++ b/test-data/unit/check-typeddict.test @@ -3040,8 +3040,9 @@ reveal_type(ad) # N: Revealed type is "TypedDict('__main__.TD', {'key': builtin Alias[str](key=0, value=0) # E: Incompatible types (expression has type "int", TypedDict item "value" has type "list[str]") # Generic aliases are *always* filled with Any, so this is different from TD(...) call. -Alias(key=0, value=0) # E: Missing type parameters for generic type "Alias" \ +Alias(key=0, value=0) # E: Missing type arguments for generic type "Alias" \ # E: Incompatible types (expression has type "int", TypedDict item "value" has type "list[Any]") + [builtins fixtures/dict.pyi] [typing fixtures/typing-typeddict.pyi] diff --git a/test-data/unit/check-typevar-defaults.test b/test-data/unit/check-typevar-defaults.test index d2d3bc10e3db..535d882ccf3c 100644 --- a/test-data/unit/check-typevar-defaults.test +++ b/test-data/unit/check-typevar-defaults.test @@ -219,7 +219,7 @@ def func_a1( class ClassA2(Generic[T1, T2, T3]): ... def func_a2( - a: ClassA2, # E: Missing type parameters for generic type "ClassA2" + a: ClassA2, # E: Missing type arguments for generic type "ClassA2" b: ClassA2[float], c: ClassA2[float, float], d: ClassA2[float, float, float], @@ -250,7 +250,7 @@ class ClassA3(Generic[T1, T2]): def __init__(self, var: Union[int, None] = None) -> None: ... def func_a3( - a: ClassA3, # E: Missing type parameters for generic type "ClassA3" + a: ClassA3, # E: Missing type arguments for generic type "ClassA3" b: ClassA3[float], c: ClassA3[float, float], d: ClassA3[float, float, float], # E: "ClassA3" expects between 1 and 2 type arguments, but 3 given @@ -316,7 +316,7 @@ def func_b1( class ClassB2(Generic[P1, P2]): ... def func_b2( - a: ClassB2, # E: Missing type parameters for generic type "ClassB2" + a: ClassB2, # E: Missing type arguments for generic type "ClassB2" b: ClassB2[[float]], c: ClassB2[[float], [float]], d: ClassB2[[float], [float], [float]], # E: "ClassB2" expects between 1 and 2 type arguments, but 3 given @@ -401,7 +401,7 @@ def func_c3( class ClassC4(Generic[T1, Unpack[Ts1], T3]): ... def func_c4( - a: ClassC4, # E: Missing type parameters for generic type "ClassC4" + a: ClassC4, # E: Missing type arguments for generic type "ClassC4" b: ClassC4[int], c: ClassC4[int, float], ) -> None: @@ -571,7 +571,7 @@ def func_a1( TA2 = Tuple[T1, T2, T3] def func_a2( - a: TA2, # E: Missing type parameters for generic type "TA2" + a: TA2, # E: Missing type arguments for generic type "TA2" b: TA2[float], c: TA2[float, float], d: TA2[float, float, float], @@ -586,7 +586,7 @@ def func_a2( TA3 = Union[Dict[T1, T2], List[T3]] def func_a3( - a: TA3, # E: Missing type parameters for generic type "TA3" + a: TA3, # E: Missing type arguments for generic type "TA3" b: TA3[float], c: TA3[float, float], d: TA3[float, float, float], @@ -601,7 +601,7 @@ def func_a3( TA4 = Tuple[T1, T4, T2] def func_a4( - a: TA4, # E: Missing type parameters for generic type "TA4" + a: TA4, # E: Missing type arguments for generic type "TA4" b: TA4[float], # E: Bad number of arguments for type alias, expected between 2 and 3, given 1 c: TA4[float, float], d: TA4[float, float, float], @@ -640,7 +640,7 @@ class ClassB2(Generic[P1, P2]): ... TB2 = ClassB2[P1, P2] def func_b2( - a: TB2, # E: Missing type parameters for generic type "TB2" + a: TB2, # E: Missing type arguments for generic type "TB2" b: TB2[[float]], c: TB2[[float], [float]], d: TB2[[float], [float], [float]], # E: Bad number of arguments for type alias, expected between 1 and 2, given 3 @@ -698,7 +698,7 @@ def func_c3( TC4 = Tuple[T1, Unpack[Ts1], T3] def func_c4( - a: TC4, # E: Missing type parameters for generic type "TC4" + a: TC4, # E: Missing type arguments for generic type "TC4" b: TC4[int], c: TC4[int, float], ) -> None: @@ -717,7 +717,7 @@ T2 = TypeVar("T2", default=T1) TD1 = Dict[T1, T2] def func_d1( - a: TD1, # E: Missing type parameters for generic type "TD1" + a: TD1, # E: Missing type arguments for generic type "TD1" b: TD1[int], c: TD1[int, float], ) -> None: diff --git a/test-data/unit/check-varargs.test b/test-data/unit/check-varargs.test index a400c88cbe7f..704cdb6617ee 100644 --- a/test-data/unit/check-varargs.test +++ b/test-data/unit/check-varargs.test @@ -1100,7 +1100,7 @@ class TD(TypedDict, Generic[T]): key: str value: T -def foo(**kwds: Unpack[TD]) -> None: ... # E: Missing type parameters for generic type "TD" +def foo(**kwds: Unpack[TD]) -> None: ... # E: Missing type arguments for generic type "TD" foo(key="yes", value=42) foo(key="yes", value="ok") [builtins fixtures/dict.pyi] diff --git a/test-data/unit/cmdline.test b/test-data/unit/cmdline.test index 64de97f0d686..c0ecc66fe053 100644 --- a/test-data/unit/cmdline.test +++ b/test-data/unit/cmdline.test @@ -491,7 +491,7 @@ disallow_any_generics = True [file m.py] def j(s: frozenset) -> None: pass [out] -m.py:1: error: Missing type parameters for generic type "frozenset" +m.py:1: error: Missing type arguments for generic type "frozenset" [case testDisallowAnyGenericsTypingCollections] # cmd: mypy m.py @@ -503,7 +503,7 @@ disallow_any_generics = True from typing import FrozenSet def j(s: FrozenSet) -> None: pass [out] -m.py:2: error: Missing type parameters for generic type "FrozenSet" +m.py:2: error: Missing type arguments for generic type "FrozenSet" [case testSectionInheritance] # cmd: mypy a @@ -537,7 +537,7 @@ strict_optional = True \[mypy-a.b.c.d.e] ignore_errors = False [out] -a/b/c/d/e/__init__.py:2: error: Missing type parameters for generic type "List" +a/b/c/d/e/__init__.py:2: error: Missing type arguments for generic type "List" a/b/c/d/e/__init__.py:3: error: Argument 1 to "g" has incompatible type "None"; expected "list[Any]" [case testMissingFile] diff --git a/test-data/unit/fine-grained.test b/test-data/unit/fine-grained.test index 070d780e93f6..6687f0ba83db 100644 --- a/test-data/unit/fine-grained.test +++ b/test-data/unit/fine-grained.test @@ -9076,7 +9076,7 @@ def foo() -> Optional[List]: 20 [out] == -a.py:4: error: Missing type parameters for generic type "List" +a.py:4: error: Missing type arguments for generic type "List" == == a.py:2: error: Missing return statement @@ -9149,7 +9149,7 @@ T = TypeVar('T') class A(Generic[T]): ... [out] == -main:5: error: Missing type parameters for generic type "A" +main:5: error: Missing type arguments for generic type "A" [case testStripNewAnalyzer] # flags: --ignore-missing-imports