Skip to content

Commit 19ba56b

Browse files
committed
Neaten double check to type guard
1 parent 7c36b24 commit 19ba56b

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

mypy/checker.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6231,9 +6231,13 @@ def find_type_equals_check(
62316231
compared
62326232
"""
62336233

6234-
def is_type_call(expr: CallExpr) -> bool:
6234+
def is_type_call(expr: Expression) -> TypeGuard[CallExpr]:
62356235
"""Is expr a call to type with one argument?"""
6236-
return refers_to_fullname(expr.callee, "builtins.type") and len(expr.args) == 1
6236+
return (
6237+
isinstance(expr, CallExpr)
6238+
and refers_to_fullname(expr.callee, "builtins.type")
6239+
and len(expr.args) == 1
6240+
)
62376241

62386242
# exprs that are being passed into type
62396243
exprs_in_type_calls: list[Expression] = []
@@ -6245,7 +6249,7 @@ def is_type_call(expr: CallExpr) -> bool:
62456249
for index in expr_indices:
62466250
expr = node.operands[index]
62476251

6248-
if isinstance(expr, CallExpr) and is_type_call(expr):
6252+
if is_type_call(expr):
62496253
exprs_in_type_calls.append(expr.args[0])
62506254
else:
62516255
current_type = self.get_isinstance_type(expr)

0 commit comments

Comments
 (0)