Skip to content

Commit 956e3ab

Browse files
authored
Fix narrowing related code for types with overloaded __new__ (#20676)
I introduced some more instances of #12320 Noticed while analysing #20674
1 parent 4b14528 commit 956e3ab

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

mypy/checker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6494,7 +6494,7 @@ def comparison_type_narrowing_helper(self, node: ComparisonExpr) -> tuple[TypeMa
64946494
and not self.is_literal_enum(expr)
64956495
# CallableType type objects are usually already maximally specific
64966496
and not (
6497-
isinstance(p_expr := get_proper_type(expr_type), CallableType)
6497+
isinstance(p_expr := get_proper_type(expr_type), FunctionLike)
64986498
and p_expr.is_type_obj()
64996499
)
65006500
# This is a little ad hoc, in the absence of intersection types

mypy/typeops.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1006,7 +1006,7 @@ def is_singleton_identity_type(typ: ProperType) -> bool:
10061006
return typ.is_enum_literal() or isinstance(typ.value, bool)
10071007
if isinstance(typ, TypeType) and isinstance(typ.item, Instance) and typ.item.type.is_final:
10081008
return True
1009-
if isinstance(typ, CallableType) and typ.is_type_obj() and typ.type_object().is_final:
1009+
if isinstance(typ, FunctionLike) and typ.is_type_obj() and typ.type_object().is_final:
10101010
return True
10111011
return False
10121012

0 commit comments

Comments
 (0)