Skip to content

Commit a57d3b0

Browse files
authored
Fix incorrect fast path in is_same_type() (#20874)
Although it is unlikely to ever matter, this is technically not correct since we started narrowing upper bounds a while ago (this is already handled correctly in the subtype/meet/join visitors).
1 parent fae0084 commit a57d3b0

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

mypy/subtypes.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,12 @@ def is_same_type(
271271
and a.last_known_value is b.last_known_value
272272
):
273273
return all(is_same_type(x, y) for x, y in zip(a.args, b.args))
274-
elif isinstance(a, TypeVarType) and isinstance(b, TypeVarType) and a.id == b.id:
274+
elif (
275+
isinstance(a, TypeVarType)
276+
and isinstance(b, TypeVarType)
277+
and a.id == b.id
278+
and a.upper_bound == b.upper_bound
279+
):
275280
return True
276281

277282
# Note that using ignore_promotions=True (default) makes types like int and int64

0 commit comments

Comments
 (0)