Skip to content

Commit f03ab50

Browse files
committed
1 parent 8b73cc2 commit f03ab50

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

mypy/subtypes.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,8 +435,11 @@ def visit_instance(self, left: Instance) -> bool:
435435
# dynamic base classes correctly, see #5456.
436436
return not isinstance(self.right, NoneType)
437437
right = self.right
438-
if isinstance(right, TupleType) and right.partial_fallback.type.is_enum:
439-
return self._is_subtype(left, mypy.typeops.tuple_fallback(right))
438+
if isinstance(right, TupleType):
439+
return (
440+
self._is_subtype(left, right.partial_fallback)
441+
and self._is_subtype(left, mypy.typeops.tuple_fallback(right))
442+
)
440443
if isinstance(right, Instance):
441444
if type_state.is_cached_subtype_check(self._subtype_kind, left, right):
442445
return True

test-data/unit/check-tuples.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ t1: Tuple[A, A]
113113
t2: tuple
114114

115115
if int():
116-
t1 = t2 # E: Incompatible types in assignment (expression has type "Tuple[Any, ...]", variable has type "Tuple[A, A]")
116+
t1 = t2
117117
if int():
118118
t2 = t1
119119

test-data/unit/check-typevar-tuple.test

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ f(empty) # E: Argument 1 to "f" has incompatible type "Tuple[()]"; expected "Tu
6161
f(bad_args) # E: Argument 1 to "f" has incompatible type "Tuple[str, str]"; expected "Tuple[int, str]"
6262

6363
# The reason for error in subtle: actual can be empty, formal cannot.
64-
reveal_type(f(var_len_tuple)) # N: Revealed type is "Tuple[builtins.str, Unpack[builtins.tuple[builtins.int, ...]]]" \
65-
# E: Argument 1 to "f" has incompatible type "Tuple[int, ...]"; expected "Tuple[int, Unpack[Tuple[int, ...]]]"
64+
reveal_type(f(var_len_tuple)) # N: Revealed type is "Tuple[builtins.str, Unpack[builtins.tuple[builtins.int, ...]]]"
6665

6766
g_args: Tuple[str, int]
6867
reveal_type(g(g_args)) # N: Revealed type is "Tuple[builtins.str, builtins.str]"

0 commit comments

Comments
 (0)