Skip to content

Commit 82f3c74

Browse files
committed
Stop testing iterables for truthiness!
1 parent 2ca095d commit 82f3c74

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

mypy/solve.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ def solve_one(lowers: Iterable[Type], uppers: Iterable[Type]) -> Type | None:
270270
uppers = new_uppers
271271

272272
# ...unless this is the only information we have, then we just pass it on.
273+
lowers = list(lowers)
273274
if not uppers and not lowers:
274275
candidate = UninhabitedType()
275276
candidate.ambiguous = True
@@ -285,7 +286,7 @@ def solve_one(lowers: Iterable[Type], uppers: Iterable[Type]) -> Type | None:
285286
# This deviates from the general mypy semantics because
286287
# recursive types are union-heavy in 95% of cases.
287288
# Retain `None` when no bottoms were provided to avoid bogus `Never` inference.
288-
bottom = UnionType.make_union(list(lowers))
289+
bottom = UnionType.make_union(lowers)
289290
else:
290291
# The order of lowers is non-deterministic.
291292
# We attempt to sort lowers because joins are non-associative. For instance:

0 commit comments

Comments
 (0)