From 7c012a390bf8f8d63cdaf21a6cb6c4cdf0c986ff Mon Sep 17 00:00:00 2001 From: hauntsaninja Date: Tue, 29 Aug 2023 23:03:48 -0700 Subject: [PATCH] Represent bottom type as Never Fixes #15950 --- mypy/checker.py | 12 +++++----- mypy/checkexpr.py | 4 ++-- mypy/expandtype.py | 2 +- mypy/meet.py | 4 ++-- mypy/messages.py | 6 ++--- mypy/solve.py | 4 ++-- mypy/typeops.py | 2 +- mypy/types.py | 2 +- test-data/unit/check-classes.test | 16 ++++++------- test-data/unit/check-dataclass-transform.test | 12 +++++----- test-data/unit/check-dataclasses.test | 8 +++---- test-data/unit/check-generic-subtyping.test | 2 +- test-data/unit/check-generics.test | 12 +++++----- test-data/unit/check-inference-context.test | 16 ++++++------- test-data/unit/check-inference.test | 24 +++++++++---------- test-data/unit/check-isinstance.test | 4 ++-- test-data/unit/check-literal.test | 4 ++-- test-data/unit/check-narrowing.test | 2 +- test-data/unit/check-native-int.test | 8 +++---- test-data/unit/check-overloading.test | 12 +++++----- .../unit/check-parameter-specification.test | 6 ++--- test-data/unit/check-plugin-attrs.test | 10 ++++---- test-data/unit/check-protocols.test | 2 +- test-data/unit/check-python310.test | 2 +- test-data/unit/check-selftype.test | 4 ++-- test-data/unit/check-singledispatch.test | 2 +- test-data/unit/check-typeddict.test | 10 ++++---- test-data/unit/check-typevar-tuple.test | 2 +- test-data/unit/check-unreachable-code.test | 10 ++++---- test-data/unit/check-varargs.test | 10 ++++---- test-data/unit/pythoneval-asyncio.test | 2 +- test-data/unit/pythoneval.test | 6 ++--- 32 files changed, 111 insertions(+), 111 deletions(-) diff --git a/mypy/checker.py b/mypy/checker.py index a44601b83e21..fffa87c4f634 100644 --- a/mypy/checker.py +++ b/mypy/checker.py @@ -3934,7 +3934,7 @@ def is_valid_defaultdict_partial_value_type(self, t: ProperType) -> bool: Examples: * t is 'int' --> True - * t is 'list[]' --> True + * t is 'list[Never]' --> True * t is 'dict[...]' --> False (only generic types with a single type argument supported) """ @@ -3980,7 +3980,7 @@ def set_inference_error_fallback_type(self, var: Var, lvalue: Lvalue, type: Type x = [] # type: ignore x.append(1) # Should be ok! - We implement this here by giving x a valid type (replacing inferred with Any). + We implement this here by giving x a valid type (replacing inferred Never with Any). """ fallback = self.inference_error_fallback_type(type) self.set_inferred_type(var, lvalue, fallback) @@ -7403,7 +7403,7 @@ def is_valid_inferred_type(typ: Type, is_lvalue_final: bool = False) -> bool: class InvalidInferredTypes(BoolTypeQuery): """Find type components that are not valid for an inferred type. - These include type, and any types resulting from failed + These include type, and any uninhabited types resulting from failed (ambiguous) type inference. """ @@ -7424,7 +7424,7 @@ def visit_type_var(self, t: TypeVarType) -> bool: class SetNothingToAny(TypeTranslator): - """Replace all ambiguous types with Any (to avoid spurious extra errors).""" + """Replace all ambiguous Uninhabited types with Any (to avoid spurious extra errors).""" def visit_uninhabited_type(self, t: UninhabitedType) -> Type: if t.ambiguous: @@ -7432,7 +7432,7 @@ def visit_uninhabited_type(self, t: UninhabitedType) -> Type: return t def visit_type_alias_type(self, t: TypeAliasType) -> Type: - # Target of the alias cannot be an ambiguous , so we just + # Target of the alias cannot be an ambiguous UninhabitedType, so we just # replace the arguments. return t.copy_modified(args=[a.accept(self) for a in t.args]) @@ -7774,7 +7774,7 @@ def is_subtype_no_promote(left: Type, right: Type) -> bool: def is_overlapping_types_no_promote_no_uninhabited_no_none(left: Type, right: Type) -> bool: - # For the purpose of unsafe overload checks we consider list[] and list[int] + # For the purpose of unsafe overload checks we consider list[Never] and list[int] # non-overlapping. This is consistent with how we treat list[int] and list[str] as # non-overlapping, despite [] belongs to both. Also this will prevent false positives # for failed type inference during unification. diff --git a/mypy/checkexpr.py b/mypy/checkexpr.py index 4430d0773cfa..5034b4f7c702 100644 --- a/mypy/checkexpr.py +++ b/mypy/checkexpr.py @@ -2080,7 +2080,7 @@ def infer_function_type_arguments( ): freeze_all_type_vars(applied) return applied - # If it didn't work, erase free variables as , to avoid confusing errors. + # If it didn't work, erase free variables as uninhabited, to avoid confusing errors. unknown = UninhabitedType() unknown.ambiguous = True inferred_args = [ @@ -2440,7 +2440,7 @@ def check_argument_types( callee_arg_types = [orig_callee_arg_type] callee_arg_kinds = [ARG_STAR] else: - # TODO: Any and can appear in Unpack (as a result of user error), + # TODO: Any and Never can appear in Unpack (as a result of user error), # fail gracefully here and elsewhere (and/or normalize them away). assert isinstance(unpacked_type, Instance) assert unpacked_type.type.fullname == "builtins.tuple" diff --git a/mypy/expandtype.py b/mypy/expandtype.py index 26353c043cb7..be8ecb9ccfd9 100644 --- a/mypy/expandtype.py +++ b/mypy/expandtype.py @@ -285,7 +285,7 @@ def expand_unpack(self, t: UnpackType) -> list[Type]: ): return [UnpackType(typ=repl)] elif isinstance(repl, (AnyType, UninhabitedType)): - # Replace *Ts = Any with *Ts = *tuple[Any, ...] and some for . + # Replace *Ts = Any with *Ts = *tuple[Any, ...] and some for Never. # These types may appear here as a result of user error or failed inference. return [UnpackType(t.type.tuple_fallback.copy_modified(args=[repl]))] else: diff --git a/mypy/meet.py b/mypy/meet.py index e3a22a226575..2efde4ac7588 100644 --- a/mypy/meet.py +++ b/mypy/meet.py @@ -968,11 +968,11 @@ def typed_dict_mapping_overlap( As usual empty, dictionaries lie in a gray area. In general, List[str] and List[str] are considered non-overlapping despite empty list belongs to both. However, List[int] - and List[] are considered overlapping. + and List[Never] are considered overlapping. So here we follow the same logic: a TypedDict with no required keys is considered non-overlapping with Mapping[str, ], but is considered overlapping with - Mapping[, ]. This way we avoid false positives for overloads, and also + Mapping[Never, Never]. This way we avoid false positives for overloads, and also avoid false positives for comparisons like SomeTypedDict == {} under --strict-equality. """ left, right = get_proper_types((left, right)) diff --git a/mypy/messages.py b/mypy/messages.py index aab30ee29108..fa66b7ab898a 100644 --- a/mypy/messages.py +++ b/mypy/messages.py @@ -2052,7 +2052,7 @@ def report_protocol_problems( if supertype.type.fullname in exclusions.get(type(subtype), []): return if any(isinstance(tp, UninhabitedType) for tp in get_proper_types(supertype.args)): - # We don't want to add notes for failed inference (e.g. Iterable[]). + # We don't want to add notes for failed inference (e.g. Iterable[Never]). # This will be only confusing a user even more. return @@ -2379,7 +2379,7 @@ def quote_type_string(type_string: str) -> str: """Quotes a type representation for use in messages.""" no_quote_regex = r"^<(tuple|union): \d+ items>$" if ( - type_string in ["Module", "overloaded function", "", ""] + type_string in ["Module", "overloaded function", "Never", ""] or type_string.startswith("Module ") or re.match(no_quote_regex, type_string) is not None or type_string.endswith("?") @@ -2581,7 +2581,7 @@ def format_literal_value(typ: LiteralType) -> str: if typ.is_noreturn: return "NoReturn" else: - return "" + return "Never" elif isinstance(typ, TypeType): type_name = "type" if options.use_lowercase_names() else "Type" return f"{type_name}[{format(typ.item)}]" diff --git a/mypy/solve.py b/mypy/solve.py index 5945d97ed85a..95377ea9f93e 100644 --- a/mypy/solve.py +++ b/mypy/solve.py @@ -300,8 +300,8 @@ def test(x: U) -> U: ... common_upper_bound_p = get_proper_type(common_upper_bound) # We include None for when strict-optional is disabled. if isinstance(common_upper_bound_p, (UninhabitedType, NoneType)): - # This will cause to infer , which is better than a free TypeVar - # that has an upper bound . + # This will cause to infer Never, which is better than a free TypeVar + # that has an upper bound Never. return None values: list[Type] = [] diff --git a/mypy/typeops.py b/mypy/typeops.py index 0e0bc348942e..f9c1914cc9a8 100644 --- a/mypy/typeops.py +++ b/mypy/typeops.py @@ -330,7 +330,7 @@ class B(A): pass ) # Update the method signature with the solutions found. - # Technically, some constraints might be unsolvable, make them . + # Technically, some constraints might be unsolvable, make them Never. to_apply = [t if t is not None else UninhabitedType() for t in typeargs] func = expand_type(func, {tv.id: arg for tv, arg in zip(self_vars, to_apply)}) variables = [v for v in func.variables if v not in self_vars] diff --git a/mypy/types.py b/mypy/types.py index fb360fb892f1..f974157ce84d 100644 --- a/mypy/types.py +++ b/mypy/types.py @@ -3103,7 +3103,7 @@ def visit_none_type(self, t: NoneType) -> str: return "None" def visit_uninhabited_type(self, t: UninhabitedType) -> str: - return "" + return "Never" def visit_erased_type(self, t: ErasedType) -> str: return "" diff --git a/test-data/unit/check-classes.test b/test-data/unit/check-classes.test index 04b51bb603c5..4bc1e50f7be9 100644 --- a/test-data/unit/check-classes.test +++ b/test-data/unit/check-classes.test @@ -7718,13 +7718,13 @@ class D: def __init__(self) -> NoReturn: ... if object(): - reveal_type(A()) # N: Revealed type is "" + reveal_type(A()) # N: Revealed type is "Never" if object(): - reveal_type(B()) # N: Revealed type is "" + reveal_type(B()) # N: Revealed type is "Never" if object(): - reveal_type(C()) # N: Revealed type is "" + reveal_type(C()) # N: Revealed type is "Never" if object(): - reveal_type(D()) # N: Revealed type is "" + reveal_type(D()) # N: Revealed type is "Never" [case testOverloadedNewAndInitNoReturn] from typing import NoReturn, overload @@ -7764,19 +7764,19 @@ class D: def __init__(self, a: int = ...) -> None: ... if object(): - reveal_type(A()) # N: Revealed type is "" + reveal_type(A()) # N: Revealed type is "Never" reveal_type(A(1)) # N: Revealed type is "__main__.A" if object(): - reveal_type(B()) # N: Revealed type is "" + reveal_type(B()) # N: Revealed type is "Never" reveal_type(B(1)) # N: Revealed type is "__main__.B" if object(): - reveal_type(C()) # N: Revealed type is "" + reveal_type(C()) # N: Revealed type is "Never" reveal_type(C(1)) # N: Revealed type is "__main__.C" if object(): - reveal_type(D()) # N: Revealed type is "" + reveal_type(D()) # N: Revealed type is "Never" reveal_type(D(1)) # N: Revealed type is "__main__.D" [case testClassScopeImportWithWrapperAndError] diff --git a/test-data/unit/check-dataclass-transform.test b/test-data/unit/check-dataclass-transform.test index 58cd5e5a90f8..743c7fef8aa9 100644 --- a/test-data/unit/check-dataclass-transform.test +++ b/test-data/unit/check-dataclass-transform.test @@ -506,7 +506,7 @@ class FunctionModel: integer_: tuple FunctionModel(string_="abc", integer_=1) -FunctionModel(string_="abc", integer_=tuple()) # E: Argument "integer_" to "FunctionModel" has incompatible type "Tuple[, ...]"; expected "int" +FunctionModel(string_="abc", integer_=tuple()) # E: Argument "integer_" to "FunctionModel" has incompatible type "Tuple[Never, ...]"; expected "int" [typing fixtures/typing-full.pyi] [builtins fixtures/dataclasses.pyi] @@ -529,7 +529,7 @@ class FunctionModel: integer_: int FunctionModel(string_="abc", integer_=1) -FunctionModel(string_="abc", integer_=tuple()) # E: Argument "integer_" to "FunctionModel" has incompatible type "Tuple[, ...]"; expected "int" +FunctionModel(string_="abc", integer_=tuple()) # E: Argument "integer_" to "FunctionModel" has incompatible type "Tuple[Never, ...]"; expected "int" [typing fixtures/typing-full.pyi] [builtins fixtures/dataclasses.pyi] @@ -552,7 +552,7 @@ class BaseClassModel(ModelBase): integer_: tuple BaseClassModel(string_="abc", integer_=1) -BaseClassModel(string_="abc", integer_=tuple()) # E: Argument "integer_" to "BaseClassModel" has incompatible type "Tuple[, ...]"; expected "int" +BaseClassModel(string_="abc", integer_=tuple()) # E: Argument "integer_" to "BaseClassModel" has incompatible type "Tuple[Never, ...]"; expected "int" [typing fixtures/typing-full.pyi] [builtins fixtures/dataclasses.pyi] @@ -574,7 +574,7 @@ class BaseClassModel(ModelBase): integer_: int BaseClassModel(string_="abc", integer_=1) -BaseClassModel(string_="abc", integer_=tuple()) # E: Argument "integer_" to "BaseClassModel" has incompatible type "Tuple[, ...]"; expected "int" +BaseClassModel(string_="abc", integer_=tuple()) # E: Argument "integer_" to "BaseClassModel" has incompatible type "Tuple[Never, ...]"; expected "int" [typing fixtures/typing-full.pyi] [builtins fixtures/dataclasses.pyi] @@ -599,7 +599,7 @@ class MetaClassModel(ModelBaseWithMeta): integer_: tuple MetaClassModel(string_="abc", integer_=1) -MetaClassModel(string_="abc", integer_=tuple()) # E: Argument "integer_" to "MetaClassModel" has incompatible type "Tuple[, ...]"; expected "int" +MetaClassModel(string_="abc", integer_=tuple()) # E: Argument "integer_" to "MetaClassModel" has incompatible type "Tuple[Never, ...]"; expected "int" [typing fixtures/typing-full.pyi] [builtins fixtures/dataclasses.pyi] @@ -624,7 +624,7 @@ class MetaClassModel(ModelBaseWithMeta): integer_: int MetaClassModel(string_="abc", integer_=1) -MetaClassModel(string_="abc", integer_=tuple()) # E: Argument "integer_" to "MetaClassModel" has incompatible type "Tuple[, ...]"; expected "int" +MetaClassModel(string_="abc", integer_=tuple()) # E: Argument "integer_" to "MetaClassModel" has incompatible type "Tuple[Never, ...]"; expected "int" [typing fixtures/typing-full.pyi] [builtins fixtures/dataclasses.pyi] diff --git a/test-data/unit/check-dataclasses.test b/test-data/unit/check-dataclasses.test index 1f5f5635de4e..8a50e7124d05 100644 --- a/test-data/unit/check-dataclasses.test +++ b/test-data/unit/check-dataclasses.test @@ -2134,8 +2134,8 @@ T = TypeVar('T') class A(Generic[T]): x: T # exercises meet(T=int, int) = int y: bool # exercises meet(bool, int) = bool - z: str # exercises meet(str, bytes) = - w: dict # exercises meet(dict, ) = + z: str # exercises meet(str, bytes) = Never + w: dict # exercises meet(dict, Never) = Never init_var: InitVar[int] # exercises (non-optional, optional) = non-optional @dataclass @@ -2149,8 +2149,8 @@ class B: a_or_b: Union[A[int], B] _ = replace(a_or_b, x=42, y=True, init_var=42) _ = replace(a_or_b, x=42, y=True) # E: Missing named argument "init_var" for "replace" of "Union[A[int], B]" -_ = replace(a_or_b, x=42, y=True, z='42', init_var=42) # E: Argument "z" to "replace" of "Union[A[int], B]" has incompatible type "str"; expected -_ = replace(a_or_b, x=42, y=True, w={}, init_var=42) # E: Argument "w" to "replace" of "Union[A[int], B]" has incompatible type "Dict[, ]"; expected +_ = replace(a_or_b, x=42, y=True, z='42', init_var=42) # E: Argument "z" to "replace" of "Union[A[int], B]" has incompatible type "str"; expected Never +_ = replace(a_or_b, x=42, y=True, w={}, init_var=42) # E: Argument "w" to "replace" of "Union[A[int], B]" has incompatible type "Dict[Never, Never]"; expected Never _ = replace(a_or_b, y=42, init_var=42) # E: Argument "y" to "replace" of "Union[A[int], B]" has incompatible type "int"; expected "bool" [builtins fixtures/tuple.pyi] diff --git a/test-data/unit/check-generic-subtyping.test b/test-data/unit/check-generic-subtyping.test index 11c92d07021a..fd40f128ff4a 100644 --- a/test-data/unit/check-generic-subtyping.test +++ b/test-data/unit/check-generic-subtyping.test @@ -434,7 +434,7 @@ B(1) C(1) C('a') # E: Argument 1 to "C" has incompatible type "str"; expected "int" D(A(1)) -D(1) # E: Argument 1 to "D" has incompatible type "int"; expected "A[]" +D(1) # E: Argument 1 to "D" has incompatible type "int"; expected "A[Never]" [case testInheritedConstructor2] diff --git a/test-data/unit/check-generics.test b/test-data/unit/check-generics.test index 93674c0c2d5c..0781451e07ce 100644 --- a/test-data/unit/check-generics.test +++ b/test-data/unit/check-generics.test @@ -573,7 +573,7 @@ def func(x: IntNode[T]) -> IntNode[T]: return x reveal_type(func) # N: Revealed type is "def [T] (x: __main__.Node[builtins.int, T`-1]) -> __main__.Node[builtins.int, T`-1]" -func(1) # E: Argument 1 to "func" has incompatible type "int"; expected "Node[int, ]" +func(1) # E: Argument 1 to "func" has incompatible type "int"; expected "Node[int, Never]" func(Node('x', 1)) # E: Argument 1 to "Node" has incompatible type "str"; expected "int" reveal_type(func(Node(1, 'x'))) # N: Revealed type is "__main__.Node[builtins.int, builtins.str]" @@ -834,7 +834,7 @@ reveal_type(x) # N: Revealed type is "builtins.int" def f2(x: IntTP[T]) -> IntTP[T]: return x -f2((1, 2, 3)) # E: Argument 1 to "f2" has incompatible type "Tuple[int, int, int]"; expected "Tuple[int, ]" +f2((1, 2, 3)) # E: Argument 1 to "f2" has incompatible type "Tuple[int, int, int]"; expected "Tuple[int, Never]" reveal_type(f2((1, 'x'))) # N: Revealed type is "Tuple[builtins.int, builtins.str]" [builtins fixtures/for.pyi] @@ -904,7 +904,7 @@ n.y = 'x' # E: Incompatible types in assignment (expression has type "str", vari def f(x: Node[T, T]) -> TupledNode[T]: return Node(x.x, (x.x, x.x)) -f(1) # E: Argument 1 to "f" has incompatible type "int"; expected "Node[, ]" +f(1) # E: Argument 1 to "f" has incompatible type "int"; expected "Node[Never, Never]" f(Node(1, 'x')) # E: Cannot infer type argument 1 of "f" reveal_type(Node('x', 'x')) # N: Revealed type is "a.Node[builtins.str, builtins.str]" @@ -2279,7 +2279,7 @@ class Box(Generic[T]): class IteratorBox(Box[Iterator[T]]): ... -@IteratorBox.wrap # E: Argument 1 to "wrap" of "Box" has incompatible type "Callable[[], int]"; expected "Callable[[], Iterator[]]" +@IteratorBox.wrap # E: Argument 1 to "wrap" of "Box" has incompatible type "Callable[[], int]"; expected "Callable[[], Iterator[Never]]" def g() -> int: ... [builtins fixtures/classmethod.pyi] @@ -3034,8 +3034,8 @@ def id2(x: V) -> V: reveal_type(dec1(id1)) # N: Revealed type is "def [S <: __main__.B] (S`1) -> builtins.list[S`1]" reveal_type(dec1(id2)) # N: Revealed type is "def [S in (builtins.int, builtins.str)] (S`3) -> builtins.list[S`3]" reveal_type(dec2(id1)) # N: Revealed type is "def [UC <: __main__.C] (UC`5) -> builtins.list[UC`5]" -reveal_type(dec2(id2)) # N: Revealed type is "def () -> builtins.list[]" \ - # E: Argument 1 to "dec2" has incompatible type "Callable[[V], V]"; expected "Callable[[], ]" +reveal_type(dec2(id2)) # N: Revealed type is "def (Never) -> builtins.list[Never]" \ + # E: Argument 1 to "dec2" has incompatible type "Callable[[V], V]"; expected "Callable[[Never], Never]" [case testInferenceAgainstGenericLambdas] # flags: --new-type-inference diff --git a/test-data/unit/check-inference-context.test b/test-data/unit/check-inference-context.test index 5f25b007dd47..169fee65f127 100644 --- a/test-data/unit/check-inference-context.test +++ b/test-data/unit/check-inference-context.test @@ -22,7 +22,7 @@ if int(): if int(): ab = f() if int(): - b = f() # E: Incompatible types in assignment (expression has type "A[]", variable has type "B") + b = f() # E: Incompatible types in assignment (expression has type "A[Never]", variable has type "B") [case testBasicContextInferenceForConstructor] from typing import TypeVar, Generic T = TypeVar('T') @@ -37,7 +37,7 @@ if int(): if int(): ab = A() if int(): - b = A() # E: Incompatible types in assignment (expression has type "A[]", variable has type "B") + b = A() # E: Incompatible types in assignment (expression has type "A[Never]", variable has type "B") [case testIncompatibleContextInference] from typing import TypeVar, Generic T = TypeVar('T') @@ -372,7 +372,7 @@ ao: List[object] a: A def f(): a, aa, ao # Prevent redefinition -a = [] # E: Incompatible types in assignment (expression has type "List[]", variable has type "A") +a = [] # E: Incompatible types in assignment (expression has type "List[Never]", variable has type "A") aa = [] ao = [] @@ -842,7 +842,7 @@ T = TypeVar('T') def f(x: Union[List[T], str]) -> None: pass f([1]) f('') -f(1) # E: Argument 1 to "f" has incompatible type "int"; expected "Union[List[], str]" +f(1) # E: Argument 1 to "f" has incompatible type "int"; expected "Union[List[Never], str]" [builtins fixtures/isinstancelist.pyi] [case testIgnoringInferenceContext] @@ -911,7 +911,7 @@ from typing import TypeVar, Callable, Generic T = TypeVar('T') class A(Generic[T]): pass -reveal_type(A()) # N: Revealed type is "__main__.A[]" +reveal_type(A()) # N: Revealed type is "__main__.A[Never]" b = reveal_type(A()) # type: A[int] # N: Revealed type is "__main__.A[builtins.int]" [case testUnionWithGenericTypeItemContext] @@ -1311,7 +1311,7 @@ from typing import List, TypeVar T = TypeVar('T', bound=int) def f(x: List[T]) -> T: ... -# mypy infers List[] here, and is a subtype of str +# mypy infers List[Never] here, and Never is a subtype of str y: str = f([]) [builtins fixtures/list.pyi] @@ -1323,7 +1323,7 @@ def f(x: List[T]) -> List[T]: ... # TODO: improve error message for such cases, see #3283 and #5706 y: List[str] = f([]) \ - # E: Incompatible types in assignment (expression has type "List[]", variable has type "List[str]") \ + # E: Incompatible types in assignment (expression has type "List[Never]", variable has type "List[str]") \ # N: "List" is invariant -- see https://mypy.readthedocs.io/en/stable/common_issues.html#variance \ # N: Consider using "Sequence" instead, which is covariant [builtins fixtures/list.pyi] @@ -1343,7 +1343,7 @@ T = TypeVar('T', bound=int) def f(x: Optional[T] = None) -> List[T]: ... y: List[str] = f() \ - # E: Incompatible types in assignment (expression has type "List[]", variable has type "List[str]") \ + # E: Incompatible types in assignment (expression has type "List[Never]", variable has type "List[str]") \ # N: "List" is invariant -- see https://mypy.readthedocs.io/en/stable/common_issues.html#variance \ # N: Consider using "Sequence" instead, which is covariant [builtins fixtures/list.pyi] diff --git a/test-data/unit/check-inference.test b/test-data/unit/check-inference.test index 56d3fe2b4ce7..36b028977591 100644 --- a/test-data/unit/check-inference.test +++ b/test-data/unit/check-inference.test @@ -876,10 +876,10 @@ g('a')() # E: "List[str]" not callable # The next line is a case where there are multiple ways to satisfy a constraint # involving a Union. Either T = List[str] or T = str would turn out to be valid, # but mypy doesn't know how to branch on these two options (and potentially have -# to backtrack later) and defaults to T = . The result is an +# to backtrack later) and defaults to T = Never. The result is an # awkward error message. Either a better error message, or simply accepting the # call, would be preferable here. -g(['a']) # E: Argument 1 to "g" has incompatible type "List[str]"; expected "List[]" +g(['a']) # E: Argument 1 to "g" has incompatible type "List[str]"; expected "List[Never]" h(g(['a'])) @@ -972,7 +972,7 @@ from typing import TypeVar, Union, List T = TypeVar('T') def f() -> List[T]: pass d1 = f() # type: Union[List[int], str] -d2 = f() # type: Union[int, str] # E: Incompatible types in assignment (expression has type "List[]", variable has type "Union[int, str]") +d2 = f() # type: Union[int, str] # E: Incompatible types in assignment (expression has type "List[Never]", variable has type "Union[int, str]") def g(x: T) -> List[T]: pass d3 = g(1) # type: Union[List[int], List[str]] [builtins fixtures/list.pyi] @@ -3126,7 +3126,7 @@ T = TypeVar('T') def f() -> Callable[..., NoReturn]: ... x = f() -reveal_type(x) # N: Revealed type is "def (*Any, **Any) -> " +reveal_type(x) # N: Revealed type is "def (*Any, **Any) -> Never" [case testDeferralInNestedScopes] @@ -3635,8 +3635,8 @@ class Call(Protocol[T]): def f(x: Call[T]) -> Tuple[T, T]: ... def g(__x: str) -> None: pass -reveal_type(f(g)) # N: Revealed type is "Tuple[, ]" \ - # E: Argument 1 to "f" has incompatible type "Callable[[str], None]"; expected "Call[]" +reveal_type(f(g)) # N: Revealed type is "Tuple[Never, Never]" \ + # E: Argument 1 to "f" has incompatible type "Callable[[str], None]"; expected "Call[Never]" [builtins fixtures/list.pyi] [case testCallableInferenceAgainstCallableNamedVsPosOnly] @@ -3651,8 +3651,8 @@ class Call(Protocol[T]): def f(x: Call[T]) -> Tuple[T, T]: ... def g(*, x: str) -> None: pass -reveal_type(f(g)) # N: Revealed type is "Tuple[, ]" \ - # E: Argument 1 to "f" has incompatible type "Callable[[NamedArg(str, 'x')], None]"; expected "Call[]" +reveal_type(f(g)) # N: Revealed type is "Tuple[Never, Never]" \ + # E: Argument 1 to "f" has incompatible type "Callable[[NamedArg(str, 'x')], None]"; expected "Call[Never]" [builtins fixtures/list.pyi] [case testCallableInferenceAgainstCallablePosOnlyVsKwargs] @@ -3667,8 +3667,8 @@ class Call(Protocol[T]): def f(x: Call[T]) -> Tuple[T, T]: ... def g(**x: str) -> None: pass -reveal_type(f(g)) # N: Revealed type is "Tuple[, ]" \ - # E: Argument 1 to "f" has incompatible type "Callable[[KwArg(str)], None]"; expected "Call[]" +reveal_type(f(g)) # N: Revealed type is "Tuple[Never, Never]" \ + # E: Argument 1 to "f" has incompatible type "Callable[[KwArg(str)], None]"; expected "Call[Never]" [builtins fixtures/list.pyi] [case testCallableInferenceAgainstCallableNamedVsArgs] @@ -3683,6 +3683,6 @@ class Call(Protocol[T]): def f(x: Call[T]) -> Tuple[T, T]: ... def g(*args: str) -> None: pass -reveal_type(f(g)) # N: Revealed type is "Tuple[, ]" \ - # E: Argument 1 to "f" has incompatible type "Callable[[VarArg(str)], None]"; expected "Call[]" +reveal_type(f(g)) # N: Revealed type is "Tuple[Never, Never]" \ + # E: Argument 1 to "f" has incompatible type "Callable[[VarArg(str)], None]"; expected "Call[Never]" [builtins fixtures/list.pyi] diff --git a/test-data/unit/check-isinstance.test b/test-data/unit/check-isinstance.test index 361d4db78752..b7ee38b69d00 100644 --- a/test-data/unit/check-isinstance.test +++ b/test-data/unit/check-isinstance.test @@ -1812,9 +1812,9 @@ reveal_type(fm) # N: Revealed type is "__main__.FooMetaclass" if issubclass(fm, Foo): reveal_type(fm) # N: Revealed type is "Type[__main__.Foo]" if issubclass(fm, Bar): - reveal_type(fm) # N: Revealed type is "" + reveal_type(fm) # N: Revealed type is "Never" if issubclass(fm, Baz): - reveal_type(fm) # N: Revealed type is "" + reveal_type(fm) # N: Revealed type is "Never" [builtins fixtures/isinstance.pyi] [case testIsinstanceAndNarrowTypeVariable] diff --git a/test-data/unit/check-literal.test b/test-data/unit/check-literal.test index ecd4fc0a1f00..08c709c6b777 100644 --- a/test-data/unit/check-literal.test +++ b/test-data/unit/check-literal.test @@ -1794,7 +1794,7 @@ def f6(x: Optional[Literal[1]], y: Optional[Literal[2]]) -> None: pass reveal_type(unify(f1)) # N: Revealed type is "Literal[1]" if object(): - reveal_type(unify(f2)) # N: Revealed type is "" + reveal_type(unify(f2)) # N: Revealed type is "Never" reveal_type(unify(f3)) # N: Revealed type is "Literal[1]" reveal_type(unify(f4)) # N: Revealed type is "Literal[1]" reveal_type(unify(f5)) # N: Revealed type is "Literal[1]" @@ -1819,7 +1819,7 @@ T = TypeVar('T') def unify(func: Callable[[T, T], None]) -> T: pass def func(x: Literal[1], y: Literal[2]) -> None: pass -reveal_type(unify(func)) # N: Revealed type is "" +reveal_type(unify(func)) # N: Revealed type is "Never" [builtins fixtures/list.pyi] [out] diff --git a/test-data/unit/check-narrowing.test b/test-data/unit/check-narrowing.test index 291f73a45230..c86cffd453df 100644 --- a/test-data/unit/check-narrowing.test +++ b/test-data/unit/check-narrowing.test @@ -1189,7 +1189,7 @@ def f(t: Type[T], a: A, b: B) -> None: reveal_type(a) # N: Revealed type is "__main__.A" if type(b) is t: - reveal_type(b) # N: Revealed type is "" + reveal_type(b) # N: Revealed type is "Never" else: reveal_type(b) # N: Revealed type is "__main__.B" diff --git a/test-data/unit/check-native-int.test b/test-data/unit/check-native-int.test index 30314eebcb31..2f852ca522c5 100644 --- a/test-data/unit/check-native-int.test +++ b/test-data/unit/check-native-int.test @@ -87,9 +87,9 @@ reveal_type(meet(f, f32)) # N: Revealed type is "mypy_extensions.i32" reveal_type(meet(f64, f)) # N: Revealed type is "mypy_extensions.i64" reveal_type(meet(f, f64)) # N: Revealed type is "mypy_extensions.i64" if object(): - reveal_type(meet(f32, f64)) # N: Revealed type is "" + reveal_type(meet(f32, f64)) # N: Revealed type is "Never" if object(): - reveal_type(meet(f64, f32)) # N: Revealed type is "" + reveal_type(meet(f64, f32)) # N: Revealed type is "Never" reveal_type(meet(f, fa)) # N: Revealed type is "builtins.int" reveal_type(meet(f32, fa)) # N: Revealed type is "mypy_extensions.i32" @@ -149,9 +149,9 @@ def ff(x: float) -> None: pass def fi32(x: i32) -> None: pass if object(): - reveal_type(meet(ff, fi32)) # N: Revealed type is "" + reveal_type(meet(ff, fi32)) # N: Revealed type is "Never" if object(): - reveal_type(meet(fi32, ff)) # N: Revealed type is "" + reveal_type(meet(fi32, ff)) # N: Revealed type is "Never" [builtins fixtures/dict.pyi] [case testNativeIntForLoopRange] diff --git a/test-data/unit/check-overloading.test b/test-data/unit/check-overloading.test index ede4a2e4cf62..4546c7171856 100644 --- a/test-data/unit/check-overloading.test +++ b/test-data/unit/check-overloading.test @@ -3397,11 +3397,11 @@ def wrapper() -> None: # Note: These should be fine, but mypy has an unrelated bug # that makes them error out? - a2_overload: A = SomeType().foo(obj1) # E: Argument 1 to "foo" of "SomeType" has incompatible type "Union[W1[A], W2[A]]"; expected "W1[]" - a2_union: A = SomeType().bar(obj1) # E: Argument 1 to "bar" of "SomeType" has incompatible type "Union[W1[A], W2[A]]"; expected "Union[W1[], W2[]]" + a2_overload: A = SomeType().foo(obj1) # E: Argument 1 to "foo" of "SomeType" has incompatible type "Union[W1[A], W2[A]]"; expected "W1[Never]" + a2_union: A = SomeType().bar(obj1) # E: Argument 1 to "bar" of "SomeType" has incompatible type "Union[W1[A], W2[A]]"; expected "Union[W1[Never], W2[Never]]" - SomeType().foo(obj1) # E: Argument 1 to "foo" of "SomeType" has incompatible type "Union[W1[A], W2[A]]"; expected "W1[]" - SomeType().bar(obj1) # E: Argument 1 to "bar" of "SomeType" has incompatible type "Union[W1[A], W2[A]]"; expected "Union[W1[], W2[]]" + SomeType().foo(obj1) # E: Argument 1 to "foo" of "SomeType" has incompatible type "Union[W1[A], W2[A]]"; expected "W1[Never]" + SomeType().bar(obj1) # E: Argument 1 to "bar" of "SomeType" has incompatible type "Union[W1[A], W2[A]]"; expected "Union[W1[Never], W2[Never]]" [case testOverloadingInferUnionReturnWithBadObjectTypevarReturn] from typing import overload, Union, TypeVar, Generic @@ -3425,8 +3425,8 @@ class SomeType(Generic[T]): def wrapper(mysterious: T) -> T: obj1: Union[W1[A], W2[B]] - SomeType().foo(obj1) # E: Argument 1 to "foo" of "SomeType" has incompatible type "Union[W1[A], W2[B]]"; expected "W1[]" - SomeType().bar(obj1) # E: Argument 1 to "bar" of "SomeType" has incompatible type "Union[W1[A], W2[B]]"; expected "Union[W1[], W2[]]" + SomeType().foo(obj1) # E: Argument 1 to "foo" of "SomeType" has incompatible type "Union[W1[A], W2[B]]"; expected "W1[Never]" + SomeType().bar(obj1) # E: Argument 1 to "bar" of "SomeType" has incompatible type "Union[W1[A], W2[B]]"; expected "Union[W1[Never], W2[Never]]" SomeType[A]().foo(obj1) # E: Argument 1 to "foo" of "SomeType" has incompatible type "Union[W1[A], W2[B]]"; expected "W1[A]" SomeType[A]().bar(obj1) # E: Argument 1 to "bar" of "SomeType" has incompatible type "Union[W1[A], W2[B]]"; expected "Union[W1[A], W2[A]]" diff --git a/test-data/unit/check-parameter-specification.test b/test-data/unit/check-parameter-specification.test index ed1d59b376d2..111c81c327c5 100644 --- a/test-data/unit/check-parameter-specification.test +++ b/test-data/unit/check-parameter-specification.test @@ -1401,9 +1401,9 @@ def wrong_name_constructor(b: bool) -> SomeClass: return SomeClass("a") func(SomeClass, constructor) -reveal_type(func(SomeClass, wrong_constructor)) # N: Revealed type is "def (a: ) -> __main__.SomeClass" -reveal_type(func_regular(SomeClass, wrong_constructor)) # N: Revealed type is "def () -> __main__.SomeClass" -func(SomeClass, wrong_name_constructor) # E: Argument 1 to "func" has incompatible type "Type[SomeClass]"; expected "Callable[[], SomeClass]" +reveal_type(func(SomeClass, wrong_constructor)) # N: Revealed type is "def (a: Never) -> __main__.SomeClass" +reveal_type(func_regular(SomeClass, wrong_constructor)) # N: Revealed type is "def (Never) -> __main__.SomeClass" +func(SomeClass, wrong_name_constructor) # E: Argument 1 to "func" has incompatible type "Type[SomeClass]"; expected "Callable[[Never], SomeClass]" [builtins fixtures/paramspec.pyi] [case testParamSpecInTypeAliasBasic] diff --git a/test-data/unit/check-plugin-attrs.test b/test-data/unit/check-plugin-attrs.test index 1465bab2bb7b..fb5f1f9472c2 100644 --- a/test-data/unit/check-plugin-attrs.test +++ b/test-data/unit/check-plugin-attrs.test @@ -1181,7 +1181,7 @@ def my_factory() -> int: return 7 @attr.s class A: - x: int = attr.ib(factory=list) # E: Incompatible types in assignment (expression has type "List[]", variable has type "int") + x: int = attr.ib(factory=list) # E: Incompatible types in assignment (expression has type "List[Never]", variable has type "int") y: str = attr.ib(factory=my_factory) # E: Incompatible types in assignment (expression has type "int", variable has type "str") [builtins fixtures/list.pyi] @@ -2131,8 +2131,8 @@ T = TypeVar('T') class A(Generic[T]): x: T # exercises meet(T=int, int) = int y: bool # exercises meet(bool, int) = bool - z: str # exercises meet(str, bytes) = - w: dict # exercises meet(dict, ) = + z: str # exercises meet(str, bytes) = Never + w: dict # exercises meet(dict, Never) = Never @attrs.define @@ -2144,8 +2144,8 @@ class B: a_or_b: A[int] | B a2 = attrs.evolve(a_or_b, x=42, y=True) -a2 = attrs.evolve(a_or_b, x=42, y=True, z='42') # E: Argument "z" to "evolve" of "Union[A[int], B]" has incompatible type "str"; expected -a2 = attrs.evolve(a_or_b, x=42, y=True, w={}) # E: Argument "w" to "evolve" of "Union[A[int], B]" has incompatible type "Dict[, ]"; expected +a2 = attrs.evolve(a_or_b, x=42, y=True, z='42') # E: Argument "z" to "evolve" of "Union[A[int], B]" has incompatible type "str"; expected Never +a2 = attrs.evolve(a_or_b, x=42, y=True, w={}) # E: Argument "w" to "evolve" of "Union[A[int], B]" has incompatible type "Dict[Never, Never]"; expected Never [builtins fixtures/plugin_attrs.pyi] diff --git a/test-data/unit/check-protocols.test b/test-data/unit/check-protocols.test index dba01be50fee..e73add454a67 100644 --- a/test-data/unit/check-protocols.test +++ b/test-data/unit/check-protocols.test @@ -928,7 +928,7 @@ class L: def last(seq: Linked[T]) -> T: pass -last(L()) # E: Argument 1 to "last" has incompatible type "L"; expected "Linked[]" +last(L()) # E: Argument 1 to "last" has incompatible type "L"; expected "Linked[Never]" [case testMutuallyRecursiveProtocols] from typing import Protocol, Sequence, List diff --git a/test-data/unit/check-python310.test b/test-data/unit/check-python310.test index 0fe6a3d5a5cc..f81da23d148c 100644 --- a/test-data/unit/check-python310.test +++ b/test-data/unit/check-python310.test @@ -1144,7 +1144,7 @@ m: str match m: case a if a := 1: # E: Incompatible types in assignment (expression has type "int", variable has type "str") - reveal_type(a) # N: Revealed type is "" + reveal_type(a) # N: Revealed type is "Never" [case testMatchAssigningPatternGuard] m: str diff --git a/test-data/unit/check-selftype.test b/test-data/unit/check-selftype.test index d5024412ca97..bf7a928ff51d 100644 --- a/test-data/unit/check-selftype.test +++ b/test-data/unit/check-selftype.test @@ -1520,7 +1520,7 @@ from typing import Self, TypeVar, Tuple T = TypeVar("T") class C: def meth(self: T) -> Tuple[Self, T]: ... # E: Method cannot have explicit self annotation and Self type -reveal_type(C().meth()) # N: Revealed type is "Tuple[, __main__.C]" +reveal_type(C().meth()) # N: Revealed type is "Tuple[Never, __main__.C]" [builtins fixtures/property.pyi] [case testTypingSelfProperty] @@ -1558,7 +1558,7 @@ class C: class D(C): ... reveal_type(D.meth()) # N: Revealed type is "__main__.D" -reveal_type(D.bad()) # N: Revealed type is "" +reveal_type(D.bad()) # N: Revealed type is "Never" [builtins fixtures/classmethod.pyi] [case testTypingSelfOverload] diff --git a/test-data/unit/check-singledispatch.test b/test-data/unit/check-singledispatch.test index 1adec1575b7e..e63d4c073e86 100644 --- a/test-data/unit/check-singledispatch.test +++ b/test-data/unit/check-singledispatch.test @@ -300,7 +300,7 @@ h('a', 1) # E: Argument 2 to "h" has incompatible type "int"; expected "str" [case testDontCrashWhenRegisteringAfterError] import functools -a = functools.singledispatch('a') # E: Need type annotation for "a" # E: Argument 1 to "singledispatch" has incompatible type "str"; expected "Callable[..., ]" +a = functools.singledispatch('a') # E: Need type annotation for "a" # E: Argument 1 to "singledispatch" has incompatible type "str"; expected "Callable[..., Never]" @a.register(int) def default(val) -> int: diff --git a/test-data/unit/check-typeddict.test b/test-data/unit/check-typeddict.test index 7de8e6416f35..b8953f05b6a5 100644 --- a/test-data/unit/check-typeddict.test +++ b/test-data/unit/check-typeddict.test @@ -602,7 +602,7 @@ YbZ = TypedDict('YbZ', {'y': object, 'z': int}) T = TypeVar('T') def f(x: Callable[[T, T], None]) -> T: pass def g(x: XYa, y: YbZ) -> None: pass -reveal_type(f(g)) # N: Revealed type is "" +reveal_type(f(g)) # N: Revealed type is "Never" [builtins fixtures/dict.pyi] [case testMeetOfTypedDictsWithNoCommonKeysHasAllKeysAndNewFallback] @@ -625,7 +625,7 @@ M = Mapping[str, int] T = TypeVar('T') def f(x: Callable[[T, T], None]) -> T: pass def g(x: X, y: M) -> None: pass -reveal_type(f(g)) # N: Revealed type is "" +reveal_type(f(g)) # N: Revealed type is "Never" [builtins fixtures/dict.pyi] [case testMeetOfTypedDictWithIncompatibleMappingIsUninhabited] @@ -636,7 +636,7 @@ M = Mapping[str, str] T = TypeVar('T') def f(x: Callable[[T, T], None]) -> T: pass def g(x: X, y: M) -> None: pass -reveal_type(f(g)) # N: Revealed type is "" +reveal_type(f(g)) # N: Revealed type is "Never" [builtins fixtures/dict.pyi] [case testMeetOfTypedDictWithCompatibleMappingSuperclassIsUninhabitedForNow] @@ -680,7 +680,7 @@ YZ = TypedDict('YZ', {'y': int, 'z': int}) T = TypeVar('T') def f(x: Callable[[T, T], None]) -> T: pass def g(x: XY, y: YZ) -> None: pass -reveal_type(f(g)) # N: Revealed type is "" +reveal_type(f(g)) # N: Revealed type is "Never" [builtins fixtures/dict.pyi] @@ -1856,7 +1856,7 @@ class Config(TypedDict): b: str x: Config -x == {} # E: Non-overlapping equality check (left operand type: "Config", right operand type: "Dict[, ]") +x == {} # E: Non-overlapping equality check (left operand type: "Config", right operand type: "Dict[Never, Never]") [builtins fixtures/dict.pyi] [typing fixtures/typing-typeddict.pyi] diff --git a/test-data/unit/check-typevar-tuple.test b/test-data/unit/check-typevar-tuple.test index c8b33ec96b06..f7faab4818c9 100644 --- a/test-data/unit/check-typevar-tuple.test +++ b/test-data/unit/check-typevar-tuple.test @@ -17,7 +17,7 @@ reveal_type(f(args)) # N: Revealed type is "Tuple[builtins.int, builtins.str]" reveal_type(f(varargs)) # N: Revealed type is "builtins.tuple[builtins.int, ...]" -f(0) # E: Argument 1 to "f" has incompatible type "int"; expected "Tuple[, ...]" +f(0) # E: Argument 1 to "f" has incompatible type "int"; expected "Tuple[Never, ...]" def g(a: Tuple[Unpack[Ts]], b: Tuple[Unpack[Ts]]) -> Tuple[Unpack[Ts]]: return a diff --git a/test-data/unit/check-unreachable-code.test b/test-data/unit/check-unreachable-code.test index 20b5dea9fc87..acb5ca6ea609 100644 --- a/test-data/unit/check-unreachable-code.test +++ b/test-data/unit/check-unreachable-code.test @@ -900,15 +900,15 @@ from typing_extensions import NoReturn as TENoReturn from mypy_extensions import NoReturn as MENoReturn bottom1: Never -reveal_type(bottom1) # N: Revealed type is "" +reveal_type(bottom1) # N: Revealed type is "Never" bottom2: TENever -reveal_type(bottom2) # N: Revealed type is "" +reveal_type(bottom2) # N: Revealed type is "Never" bottom3: NoReturn -reveal_type(bottom3) # N: Revealed type is "" +reveal_type(bottom3) # N: Revealed type is "Never" bottom4: TENoReturn -reveal_type(bottom4) # N: Revealed type is "" +reveal_type(bottom4) # N: Revealed type is "Never" bottom5: MENoReturn -reveal_type(bottom5) # N: Revealed type is "" +reveal_type(bottom5) # N: Revealed type is "Never" [builtins fixtures/tuple.pyi] diff --git a/test-data/unit/check-varargs.test b/test-data/unit/check-varargs.test index fe09fb43c97c..54546f3973b3 100644 --- a/test-data/unit/check-varargs.test +++ b/test-data/unit/check-varargs.test @@ -604,27 +604,27 @@ class B: pass if int(): a, aa = G().f(*[a]) \ # E: Incompatible types in assignment (expression has type "List[A]", variable has type "A") \ - # E: Incompatible types in assignment (expression has type "List[]", variable has type "List[A]") \ + # E: Incompatible types in assignment (expression has type "List[Never]", variable has type "List[A]") \ # N: "List" is invariant -- see https://mypy.readthedocs.io/en/stable/common_issues.html#variance \ # N: Consider using "Sequence" instead, which is covariant if int(): - aa, a = G().f(*[a]) # E: Incompatible types in assignment (expression has type "List[]", variable has type "A") + aa, a = G().f(*[a]) # E: Incompatible types in assignment (expression has type "List[Never]", variable has type "A") if int(): ab, aa = G().f(*[a]) \ - # E: Incompatible types in assignment (expression has type "List[]", variable has type "List[A]") \ + # E: Incompatible types in assignment (expression has type "List[Never]", variable has type "List[A]") \ # N: "List" is invariant -- see https://mypy.readthedocs.io/en/stable/common_issues.html#variance \ # N: Consider using "Sequence" instead, which is covariant \ # E: Argument 1 to "f" of "G" has incompatible type "*List[A]"; expected "B" if int(): ao, ao = G().f(*[a]) \ - # E: Incompatible types in assignment (expression has type "List[]", variable has type "List[object]") \ + # E: Incompatible types in assignment (expression has type "List[Never]", variable has type "List[object]") \ # N: "List" is invariant -- see https://mypy.readthedocs.io/en/stable/common_issues.html#variance \ # N: Consider using "Sequence" instead, which is covariant if int(): aa, aa = G().f(*[a]) \ - # E: Incompatible types in assignment (expression has type "List[]", variable has type "List[A]") \ + # E: Incompatible types in assignment (expression has type "List[Never]", variable has type "List[A]") \ # N: "List" is invariant -- see https://mypy.readthedocs.io/en/stable/common_issues.html#variance \ # N: Consider using "Sequence" instead, which is covariant [builtins fixtures/list.pyi] diff --git a/test-data/unit/pythoneval-asyncio.test b/test-data/unit/pythoneval-asyncio.test index 556414cf3252..069374b9635c 100644 --- a/test-data/unit/pythoneval-asyncio.test +++ b/test-data/unit/pythoneval-asyncio.test @@ -472,7 +472,7 @@ async def bad(arg: P) -> T: pass [out] _program.py:8: note: Revealed type is "def [T] (arg: P?) -> typing.Coroutine[Any, Any, T`-1]" -_program.py:9: error: Value of type "Coroutine[Any, Any, ]" must be used +_program.py:9: error: Value of type "Coroutine[Any, Any, Never]" must be used _program.py:9: note: Are you missing an await? _program.py:11: error: Variable "_testForwardRefToBadAsyncShouldNotCrash_newsemanal.P" is not valid as a type _program.py:11: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases diff --git a/test-data/unit/pythoneval.test b/test-data/unit/pythoneval.test index 58dfb172cf76..c5be30eac1b7 100644 --- a/test-data/unit/pythoneval.test +++ b/test-data/unit/pythoneval.test @@ -863,8 +863,8 @@ MyDDict(dict)[0] _program.py:7: error: Argument 1 to "defaultdict" has incompatible type "Type[List[Any]]"; expected "Optional[Callable[[], str]]" _program.py:10: error: Invalid index type "str" for "defaultdict[int, str]"; expected type "int" _program.py:10: error: Incompatible types in assignment (expression has type "int", target has type "str") -_program.py:20: error: Argument 1 to "tst" has incompatible type "defaultdict[str, List[]]"; expected "defaultdict[int, List[]]" -_program.py:24: error: Invalid index type "str" for "MyDDict[Dict[, ]]"; expected type "int" +_program.py:20: error: Argument 1 to "tst" has incompatible type "defaultdict[str, List[Never]]"; expected "defaultdict[int, List[Never]]" +_program.py:24: error: Invalid index type "str" for "MyDDict[Dict[Never, Never]]"; expected type "int" [case testNoSubcriptionOfStdlibCollections] # flags: --python-version 3.7 @@ -2004,7 +2004,7 @@ Foo().__dict__ = {} _testInferenceOfDunderDictOnClassObjects.py:2: note: Revealed type is "types.MappingProxyType[builtins.str, Any]" _testInferenceOfDunderDictOnClassObjects.py:3: note: Revealed type is "builtins.dict[builtins.str, Any]" _testInferenceOfDunderDictOnClassObjects.py:4: error: Property "__dict__" defined in "type" is read-only -_testInferenceOfDunderDictOnClassObjects.py:4: error: Incompatible types in assignment (expression has type "Dict[, ]", variable has type "MappingProxyType[str, Any]") +_testInferenceOfDunderDictOnClassObjects.py:4: error: Incompatible types in assignment (expression has type "Dict[Never, Never]", variable has type "MappingProxyType[str, Any]") [case testTypeVarTuple] # flags: --enable-incomplete-feature=TypeVarTuple --enable-incomplete-feature=Unpack --python-version=3.11