diff --git a/mypy/checker.py b/mypy/checker.py index 461b45f8df45..466dc0b6ea8f 100644 --- a/mypy/checker.py +++ b/mypy/checker.py @@ -3200,7 +3200,9 @@ def visit_assignment_stmt(self, s: AssignmentStmt) -> None: # as X | Y. if not (s.is_alias_def and self.is_stub): with self.enter_final_context(s.is_final_def): - self.check_assignment(s.lvalues[-1], s.rvalue, s.type is None, s.new_syntax) + self.check_assignment( + s.lvalues[-1], s.rvalue, infer_lvalue_type=True, new_syntax=s.new_syntax + ) if s.is_alias_def: self.check_type_alias_rvalue(s) @@ -3228,7 +3230,7 @@ def visit_assignment_stmt(self, s: AssignmentStmt) -> None: rvalue = self.temp_node(self.lookup_type(s.rvalue), s) for lv in s.lvalues[:-1]: with self.enter_final_context(s.is_final_def): - self.check_assignment(lv, rvalue, s.type is None) + self.check_assignment(lv, rvalue, infer_lvalue_type=True) self.check_final(s) if ( diff --git a/mypy/plugins/attrs.py b/mypy/plugins/attrs.py index 47c6ad9f305a..d9d5293007e1 100644 --- a/mypy/plugins/attrs.py +++ b/mypy/plugins/attrs.py @@ -765,7 +765,6 @@ def _parse_converter( converter_info.init_type = AnyType(TypeOfAny.from_error) return converter_info - converter_type = get_proper_type(converter_type) if isinstance(converter_type, CallableType) and converter_type.arg_types: converter_info.init_type = converter_type.arg_types[0] if not is_attr_converters_optional: diff --git a/mypy/semanal.py b/mypy/semanal.py index 8179813c7171..563467d0e97d 100644 --- a/mypy/semanal.py +++ b/mypy/semanal.py @@ -7093,7 +7093,7 @@ def _get_node_for_class_scoped_import( # mypyc is absolutely convinced that `symbol_node` narrows to a Var in the following, # when it can also be a FuncBase. Once fixed, `f` in the following can be removed. # See also https://github.com/mypyc/mypyc/issues/892 - f: Callable[[object], Any] = lambda x: x + f = cast(Callable[[object], Any], lambda x: x) if isinstance(f(symbol_node), (Decorator, FuncBase, Var)): # For imports in class scope, we construct a new node to represent the symbol and # set its `info` attribute to `self.type`. diff --git a/mypy/types.py b/mypy/types.py index cdfc60a8e7df..ddfc38fa4516 100644 --- a/mypy/types.py +++ b/mypy/types.py @@ -2511,7 +2511,8 @@ def with_normalized_var_args(self) -> Self: types_suffix = self.arg_types[var_arg_index + 1 :] kinds_suffix = self.arg_kinds[var_arg_index + 1 :] names_suffix = self.arg_names[var_arg_index + 1 :] - no_name: str | None = None # to silence mypy + names_middle: list[str | None] + no_name = cast("str | None", None) # Now we have something non-trivial to do. if unpack_index is None: @@ -4175,12 +4176,6 @@ def find_unpack_in_list(items: Sequence[Type]) -> int | None: unpack_index: int | None = None for i, item in enumerate(items): if isinstance(item, UnpackType): - # We cannot fail here, so we must check this in an earlier - # semanal phase. - # Funky code here avoids mypyc narrowing the type of unpack_index. - old_index = unpack_index - assert old_index is None - # Don't return so that we can also sanity check there is only one. unpack_index = i return unpack_index