diff --git a/mypy/checker.py b/mypy/checker.py index 999d75678aa4..066e929c5200 100644 --- a/mypy/checker.py +++ b/mypy/checker.py @@ -8484,11 +8484,6 @@ def visit_type_var(self, t: TypeVarType) -> bool: # multi-step type inference. return t.id.is_meta_var() - def visit_tuple_type(self, t: TupleType, /) -> bool: - # Exclude fallback to avoid bogus "need type annotation" errors - # TODO: Maybe erase plain tuples used as fallback in TupleType constructor? - return self.query_types(t.items) - class SetNothingToAny(TypeTranslator): """Replace all ambiguous Uninhabited types with Any (to avoid spurious extra errors).""" diff --git a/mypy/types.py b/mypy/types.py index f700be887116..76e4ad03ba27 100644 --- a/mypy/types.py +++ b/mypy/types.py @@ -2415,6 +2415,12 @@ def __init__( implicit: bool = False, ) -> None: super().__init__(line, column) + if fallback.type and fallback.type.fullname == "builtins.tuple": + assert len(fallback.args) == 1 + if not isinstance(fallback.args[0], AnyType): + fallback = fallback.copy_modified( + args=[AnyType(TypeOfAny.implementation_artifact)] + ) self.partial_fallback = fallback self.items = items self.implicit = implicit