Skip to content

Commit ff7105b

Browse files
committed
Normalize tuple fallback to tuple[Any, ...] in constructor if it isn't special
1 parent b50f3a1 commit ff7105b

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

mypy/checker.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8484,11 +8484,6 @@ def visit_type_var(self, t: TypeVarType) -> bool:
84848484
# multi-step type inference.
84858485
return t.id.is_meta_var()
84868486

8487-
def visit_tuple_type(self, t: TupleType, /) -> bool:
8488-
# Exclude fallback to avoid bogus "need type annotation" errors
8489-
# TODO: Maybe erase plain tuples used as fallback in TupleType constructor?
8490-
return self.query_types(t.items)
8491-
84928487

84938488
class SetNothingToAny(TypeTranslator):
84948489
"""Replace all ambiguous Uninhabited types with Any (to avoid spurious extra errors)."""

mypy/types.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2415,6 +2415,12 @@ def __init__(
24152415
implicit: bool = False,
24162416
) -> None:
24172417
super().__init__(line, column)
2418+
if fallback.type and fallback.type.fullname == "builtins.tuple":
2419+
assert len(fallback.args) == 1
2420+
if not isinstance(fallback.args[0], AnyType):
2421+
fallback = fallback.copy_modified(
2422+
args=[AnyType(TypeOfAny.implementation_artifact)]
2423+
)
24182424
self.partial_fallback = fallback
24192425
self.items = items
24202426
self.implicit = implicit

0 commit comments

Comments
 (0)