Skip to content

Commit e802b54

Browse files
committed
Revert "Update checkexpr.py"
Accidentally deleted the wrong changes This reverts commit 17ebfea.
1 parent 496db6a commit e802b54

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

mypy/checkexpr.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1453,6 +1453,32 @@ def check_call_expr_with_callee_type(
14531453
member: str | None = None,
14541454
) -> Type:
14551455

1456+
proper_callee = get_proper_type(callee_type)
1457+
1458+
is_constructor_call = False
1459+
if isinstance(e.callee, RefExpr):
1460+
node = e.callee.node
1461+
if node is not None and hasattr(node, "name"):
1462+
is_constructor_call = node.name == "__init__"
1463+
elif callable_name is None:
1464+
# direct class call without member name
1465+
is_constructor_call = True
1466+
1467+
object_type = get_proper_type(object_type)
1468+
if (
1469+
isinstance(proper_callee, CallableType)
1470+
and isinstance(object_type, Instance)
1471+
and is_constructor_call
1472+
):
1473+
target_name = object_type.type.name
1474+
arg_names_set = set(e.arg_names or [])
1475+
1476+
for name, kind in zip(proper_callee.arg_names, proper_callee.arg_kinds):
1477+
if name is not None and kind in (ARG_NAMED, ARG_POS):
1478+
if name not in arg_names_set:
1479+
if target_name == "misc":
1480+
continue # Skip error for miscellaneous/unknown classes
1481+
14561482
"""Type check call expression.
14571483
14581484
The callee_type should be used as the type of callee expression. In particular,

0 commit comments

Comments
 (0)