Skip to content

Commit cccaaf1

Browse files
committed
Add _is_super helper check
1 parent b79e04d commit cccaaf1

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

pylint/checkers/typecheck.py

+14
Original file line numberDiff line numberDiff line change
@@ -1448,6 +1448,20 @@ def _check_isinstance_args(self, node: nodes.Call, callable_name: str) -> None:
14481448
confidence=INFERENCE,
14491449
)
14501450

1451+
def _is_super(self, node: nodes.Call) -> bool:
1452+
"True if this node is a call to super()."
1453+
if (
1454+
isinstance(node.func, nodes.Attribute)
1455+
and node.func.attrname == "__init__"
1456+
and isinstance(node.func.expr, nodes.Call)
1457+
and isinstance(node.func.expr.func, nodes.Name)
1458+
and node.func.expr.func.name == "super"
1459+
):
1460+
inferred = safe_infer(node.func.expr)
1461+
if isinstance(inferred, astroid.objects.Super):
1462+
return True
1463+
return False
1464+
14511465
# pylint: disable = too-many-branches, too-many-locals, too-many-statements
14521466
def visit_call(self, node: nodes.Call) -> None:
14531467
"""Check that called functions/methods are inferred to callable objects,

0 commit comments

Comments
 (0)