Skip to content

Commit 2c820d3

Browse files
committed
do not use itertools.product
1 parent bd2a103 commit 2c820d3

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

mypy/meet.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from __future__ import annotations
22

3-
from itertools import product
43
from typing import Callable
54

65
from mypy import join
@@ -129,13 +128,16 @@ def narrow_declared_type(declared: Type, narrowed: Type) -> Type:
129128
if declared == narrowed:
130129
return original_declared
131130
if isinstance(declared, UnionType):
131+
declared_items = declared.relevant_items()
132+
if isinstance(narrowed, UnionType):
133+
narrowed_items = narrowed.relevant_items()
134+
else:
135+
narrowed_items = [narrowed]
132136
return make_simplified_union(
133137
[
134138
narrow_declared_type(d, n)
135-
for d, n in product(
136-
declared.relevant_items(),
137-
narrowed.relevant_items() if isinstance(narrowed, UnionType) else (narrowed,),
138-
)
139+
for d in declared_items
140+
for n in narrowed_items
139141
# This (ugly) special-casing is needed to support checking
140142
# branches like this:
141143
# x: Union[float, complex]

0 commit comments

Comments
 (0)