Method: pylint.checkers.newstyle.NewStyleConflictChecker.visit_functiondef
Calls: 3521, Exceptions: 5, Paths: 19Back
Path 1: 1805 calls (0.51)
FunctionDef (1768) AsyncFunctionDef (37)
None (1805)
1@only_required_for_messages("bad-super-call")
2 def visit_functiondef(self, node: nodes.FunctionDef) -> None:
3 """Check use of super."""
4 # ignore actual functions or method within a new style class
5 if not node.is_method():
6 return
7 klass = node.parent.frame(future=True)
8 for stmt in node.nodes_of_class(nodes.Call):
9 if node_frame_class(stmt) != node_frame_class(node):
10 # Don't look down in other scopes.
11 continue
12
13 expr = stmt.func
14 if not isinstance(expr, nodes.Attribute):
15 continue
16
17 call = expr.expr
18 # skip the test if using super
19 if not (
20 isinstance(call, nodes.Call)
21 and isinstance(call.func, nodes.Name)
22 and call.func.name == "super"
23 ):
24 continue
25
26 # super should not be used on an old style class
27 if klass.newstyle or not has_known_bases(klass):
28 # super first arg should not be the class
29 if not call.args:
30 continue
31
32 # calling super(type(self), self) can lead to recursion loop
33 # in derived classes
34 arg0 = call.args[0]
35 if (
36 isinstance(arg0, nodes.Call)
37 and isinstance(arg0.func, nodes.Name)
38 and arg0.func.name == "type"
39 ):
40 self.add_message("bad-super-call", node=call, args=("type",))
41 continue
42
43 # calling super(self.__class__, self) can lead to recursion loop
44 # in derived classes
45 if (
46 len(call.args) >= 2
47 and isinstance(call.args[1], nodes.Name)
48 and call.args[1].name == "self"
49 and isinstance(arg0, nodes.Attribute)
50 and arg0.attrname == "__class__"
51 ):
52 self.add_message(
53 "bad-super-call", node=call, args=("self.__class__",)
54 )
55 continue
56
57 try:
58 supcls = call.args and next(call.args[0].infer(), None)
59 except astroid.InferenceError:
60 continue
61
62 # If the supcls is in the ancestors of klass super can be used to skip
63 # a step in the mro() and get a method from a higher parent
64 if klass is not supcls and all(i != supcls for i in klass.ancestors()):
65 name = None
66 # if supcls is not Uninferable, then supcls was inferred
67 # and use its name. Otherwise, try to look
68 # for call.args[0].name
69 if supcls:
70 name = supcls.name
71 elif call.args and hasattr(call.args[0], "name"):
72 name = call.args[0].name
73 if name:
74 self.add_message("bad-super-call", node=call, args=(name,))
Path 2: 1087 calls (0.31)
FunctionDef (1078) AsyncFunctionDef (9)
1@only_required_for_messages("bad-super-call")
2 def visit_functiondef(self, node: nodes.FunctionDef) -> None:
3 """Check use of super."""
4 # ignore actual functions or method within a new style class
5 if not node.is_method():
6 return
7 klass = node.parent.frame(future=True)
8 for stmt in node.nodes_of_class(nodes.Call):
9 if node_frame_class(stmt) != node_frame_class(node):
10 # Don't look down in other scopes.
11 continue
12
13 expr = stmt.func
14 if not isinstance(expr, nodes.Attribute):
15 continue
16
17 call = expr.expr
18 # skip the test if using super
19 if not (
20 isinstance(call, nodes.Call)
21 and isinstance(call.func, nodes.Name)
22 and call.func.name == "super"
23 ):
24 continue
25
26 # super should not be used on an old style class
27 if klass.newstyle or not has_known_bases(klass):
28 # super first arg should not be the class
29 if not call.args:
30 continue
31
32 # calling super(type(self), self) can lead to recursion loop
33 # in derived classes
34 arg0 = call.args[0]
35 if (
36 isinstance(arg0, nodes.Call)
37 and isinstance(arg0.func, nodes.Name)
38 and arg0.func.name == "type"
39 ):
40 self.add_message("bad-super-call", node=call, args=("type",))
41 continue
42
43 # calling super(self.__class__, self) can lead to recursion loop
44 # in derived classes
45 if (
46 len(call.args) >= 2
47 and isinstance(call.args[1], nodes.Name)
48 and call.args[1].name == "self"
49 and isinstance(arg0, nodes.Attribute)
50 and arg0.attrname == "__class__"
51 ):
52 self.add_message(
53 "bad-super-call", node=call, args=("self.__class__",)
54 )
55 continue
56
57 try:
58 supcls = call.args and next(call.args[0].infer(), None)
59 except astroid.InferenceError:
60 continue
61
62 # If the supcls is in the ancestors of klass super can be used to skip
63 # a step in the mro() and get a method from a higher parent
64 if klass is not supcls and all(i != supcls for i in klass.ancestors()):
65 name = None
66 # if supcls is not Uninferable, then supcls was inferred
67 # and use its name. Otherwise, try to look
68 # for call.args[0].name
69 if supcls:
70 name = supcls.name
71 elif call.args and hasattr(call.args[0], "name"):
72 name = call.args[0].name
73 if name:
74 self.add_message("bad-super-call", node=call, args=(name,))
Path 3: 304 calls (0.09)
FunctionDef (300) AsyncFunctionDef (4)
1@only_required_for_messages("bad-super-call")
2 def visit_functiondef(self, node: nodes.FunctionDef) -> None:
3 """Check use of super."""
4 # ignore actual functions or method within a new style class
5 if not node.is_method():
6 return
7 klass = node.parent.frame(future=True)
8 for stmt in node.nodes_of_class(nodes.Call):
9 if node_frame_class(stmt) != node_frame_class(node):
10 # Don't look down in other scopes.
11 continue
12
13 expr = stmt.func
14 if not isinstance(expr, nodes.Attribute):
15 continue
16
17 call = expr.expr
18 # skip the test if using super
19 if not (
20 isinstance(call, nodes.Call)
21 and isinstance(call.func, nodes.Name)
22 and call.func.name == "super"
23 ):
24 continue
25
26 # super should not be used on an old style class
27 if klass.newstyle or not has_known_bases(klass):
28 # super first arg should not be the class
29 if not call.args:
30 continue
31
32 # calling super(type(self), self) can lead to recursion loop
33 # in derived classes
34 arg0 = call.args[0]
35 if (
36 isinstance(arg0, nodes.Call)
37 and isinstance(arg0.func, nodes.Name)
38 and arg0.func.name == "type"
39 ):
40 self.add_message("bad-super-call", node=call, args=("type",))
41 continue
42
43 # calling super(self.__class__, self) can lead to recursion loop
44 # in derived classes
45 if (
46 len(call.args) >= 2
47 and isinstance(call.args[1], nodes.Name)
48 and call.args[1].name == "self"
49 and isinstance(arg0, nodes.Attribute)
50 and arg0.attrname == "__class__"
51 ):
52 self.add_message(
53 "bad-super-call", node=call, args=("self.__class__",)
54 )
55 continue
56
57 try:
58 supcls = call.args and next(call.args[0].infer(), None)
59 except astroid.InferenceError:
60 continue
61
62 # If the supcls is in the ancestors of klass super can be used to skip
63 # a step in the mro() and get a method from a higher parent
64 if klass is not supcls and all(i != supcls for i in klass.ancestors()):
65 name = None
66 # if supcls is not Uninferable, then supcls was inferred
67 # and use its name. Otherwise, try to look
68 # for call.args[0].name
69 if supcls:
70 name = supcls.name
71 elif call.args and hasattr(call.args[0], "name"):
72 name = call.args[0].name
73 if name:
74 self.add_message("bad-super-call", node=call, args=(name,))
Path 4: 131 calls (0.04)
FunctionDef (129) AsyncFunctionDef (2)
1@only_required_for_messages("bad-super-call")
2 def visit_functiondef(self, node: nodes.FunctionDef) -> None:
3 """Check use of super."""
4 # ignore actual functions or method within a new style class
5 if not node.is_method():
6 return
7 klass = node.parent.frame(future=True)
8 for stmt in node.nodes_of_class(nodes.Call):
9 if node_frame_class(stmt) != node_frame_class(node):
10 # Don't look down in other scopes.
11 continue
12
13 expr = stmt.func
14 if not isinstance(expr, nodes.Attribute):
15 continue
16
17 call = expr.expr
18 # skip the test if using super
19 if not (
20 isinstance(call, nodes.Call)
21 and isinstance(call.func, nodes.Name)
22 and call.func.name == "super"
23 ):
24 continue
25
26 # super should not be used on an old style class
27 if klass.newstyle or not has_known_bases(klass):
28 # super first arg should not be the class
29 if not call.args:
30 continue
31
32 # calling super(type(self), self) can lead to recursion loop
33 # in derived classes
34 arg0 = call.args[0]
35 if (
36 isinstance(arg0, nodes.Call)
37 and isinstance(arg0.func, nodes.Name)
38 and arg0.func.name == "type"
39 ):
40 self.add_message("bad-super-call", node=call, args=("type",))
41 continue
42
43 # calling super(self.__class__, self) can lead to recursion loop
44 # in derived classes
45 if (
46 len(call.args) >= 2
47 and isinstance(call.args[1], nodes.Name)
48 and call.args[1].name == "self"
49 and isinstance(arg0, nodes.Attribute)
50 and arg0.attrname == "__class__"
51 ):
52 self.add_message(
53 "bad-super-call", node=call, args=("self.__class__",)
54 )
55 continue
56
57 try:
58 supcls = call.args and next(call.args[0].infer(), None)
59 except astroid.InferenceError:
60 continue
61
62 # If the supcls is in the ancestors of klass super can be used to skip
63 # a step in the mro() and get a method from a higher parent
64 if klass is not supcls and all(i != supcls for i in klass.ancestors()):
65 name = None
66 # if supcls is not Uninferable, then supcls was inferred
67 # and use its name. Otherwise, try to look
68 # for call.args[0].name
69 if supcls:
70 name = supcls.name
71 elif call.args and hasattr(call.args[0], "name"):
72 name = call.args[0].name
73 if name:
74 self.add_message("bad-super-call", node=call, args=(name,))
Path 5: 67 calls (0.02)
FunctionDef (67)
1@only_required_for_messages("bad-super-call")
2 def visit_functiondef(self, node: nodes.FunctionDef) -> None:
3 """Check use of super."""
4 # ignore actual functions or method within a new style class
5 if not node.is_method():
6 return
7 klass = node.parent.frame(future=True)
8 for stmt in node.nodes_of_class(nodes.Call):
9 if node_frame_class(stmt) != node_frame_class(node):
10 # Don't look down in other scopes.
11 continue
12
13 expr = stmt.func
14 if not isinstance(expr, nodes.Attribute):
15 continue
16
17 call = expr.expr
18 # skip the test if using super
19 if not (
20 isinstance(call, nodes.Call)
21 and isinstance(call.func, nodes.Name)
22 and call.func.name == "super"
23 ):
24 continue
25
26 # super should not be used on an old style class
27 if klass.newstyle or not has_known_bases(klass):
28 # super first arg should not be the class
29 if not call.args:
30 continue
31
32 # calling super(type(self), self) can lead to recursion loop
33 # in derived classes
34 arg0 = call.args[0]
35 if (
36 isinstance(arg0, nodes.Call)
37 and isinstance(arg0.func, nodes.Name)
38 and arg0.func.name == "type"
39 ):
40 self.add_message("bad-super-call", node=call, args=("type",))
41 continue
42
43 # calling super(self.__class__, self) can lead to recursion loop
44 # in derived classes
45 if (
46 len(call.args) >= 2
47 and isinstance(call.args[1], nodes.Name)
48 and call.args[1].name == "self"
49 and isinstance(arg0, nodes.Attribute)
50 and arg0.attrname == "__class__"
51 ):
52 self.add_message(
53 "bad-super-call", node=call, args=("self.__class__",)
54 )
55 continue
56
57 try:
58 supcls = call.args and next(call.args[0].infer(), None)
59 except astroid.InferenceError:
60 continue
61
62 # If the supcls is in the ancestors of klass super can be used to skip
63 # a step in the mro() and get a method from a higher parent
64 if klass is not supcls and all(i != supcls for i in klass.ancestors()):
65 name = None
66 # if supcls is not Uninferable, then supcls was inferred
67 # and use its name. Otherwise, try to look
68 # for call.args[0].name
69 if supcls:
70 name = supcls.name
71 elif call.args and hasattr(call.args[0], "name"):
72 name = call.args[0].name
73 if name:
74 self.add_message("bad-super-call", node=call, args=(name,))
Path 6: 62 calls (0.02)
FunctionDef (62)
GeneratorExit (3)
1@only_required_for_messages("bad-super-call")
2 def visit_functiondef(self, node: nodes.FunctionDef) -> None:
3 """Check use of super."""
4 # ignore actual functions or method within a new style class
5 if not node.is_method():
6 return
7 klass = node.parent.frame(future=True)
8 for stmt in node.nodes_of_class(nodes.Call):
9 if node_frame_class(stmt) != node_frame_class(node):
10 # Don't look down in other scopes.
11 continue
12
13 expr = stmt.func
14 if not isinstance(expr, nodes.Attribute):
15 continue
16
17 call = expr.expr
18 # skip the test if using super
19 if not (
20 isinstance(call, nodes.Call)
21 and isinstance(call.func, nodes.Name)
22 and call.func.name == "super"
23 ):
24 continue
25
26 # super should not be used on an old style class
27 if klass.newstyle or not has_known_bases(klass):
28 # super first arg should not be the class
29 if not call.args:
30 continue
31
32 # calling super(type(self), self) can lead to recursion loop
33 # in derived classes
34 arg0 = call.args[0]
35 if (
36 isinstance(arg0, nodes.Call)
37 and isinstance(arg0.func, nodes.Name)
38 and arg0.func.name == "type"
39 ):
40 self.add_message("bad-super-call", node=call, args=("type",))
41 continue
42
43 # calling super(self.__class__, self) can lead to recursion loop
44 # in derived classes
45 if (
46 len(call.args) >= 2
47 and isinstance(call.args[1], nodes.Name)
48 and call.args[1].name == "self"
49 and isinstance(arg0, nodes.Attribute)
50 and arg0.attrname == "__class__"
51 ):
52 self.add_message(
53 "bad-super-call", node=call, args=("self.__class__",)
54 )
55 continue
56
57 try:
58 supcls = call.args and next(call.args[0].infer(), None)
59 except astroid.InferenceError:
60 continue
61
62 # If the supcls is in the ancestors of klass super can be used to skip
63 # a step in the mro() and get a method from a higher parent
64 if klass is not supcls and all(i != supcls for i in klass.ancestors()):
65 name = None
66 # if supcls is not Uninferable, then supcls was inferred
67 # and use its name. Otherwise, try to look
68 # for call.args[0].name
69 if supcls:
70 name = supcls.name
71 elif call.args and hasattr(call.args[0], "name"):
72 name = call.args[0].name
73 if name:
74 self.add_message("bad-super-call", node=call, args=(name,))
Path 7: 41 calls (0.01)
FunctionDef (40) AsyncFunctionDef (1)
1@only_required_for_messages("bad-super-call")
2 def visit_functiondef(self, node: nodes.FunctionDef) -> None:
3 """Check use of super."""
4 # ignore actual functions or method within a new style class
5 if not node.is_method():
6 return
7 klass = node.parent.frame(future=True)
8 for stmt in node.nodes_of_class(nodes.Call):
9 if node_frame_class(stmt) != node_frame_class(node):
10 # Don't look down in other scopes.
11 continue
12
13 expr = stmt.func
14 if not isinstance(expr, nodes.Attribute):
15 continue
16
17 call = expr.expr
18 # skip the test if using super
19 if not (
20 isinstance(call, nodes.Call)
21 and isinstance(call.func, nodes.Name)
22 and call.func.name == "super"
23 ):
24 continue
25
26 # super should not be used on an old style class
27 if klass.newstyle or not has_known_bases(klass):
28 # super first arg should not be the class
29 if not call.args:
30 continue
31
32 # calling super(type(self), self) can lead to recursion loop
33 # in derived classes
34 arg0 = call.args[0]
35 if (
36 isinstance(arg0, nodes.Call)
37 and isinstance(arg0.func, nodes.Name)
38 and arg0.func.name == "type"
39 ):
40 self.add_message("bad-super-call", node=call, args=("type",))
41 continue
42
43 # calling super(self.__class__, self) can lead to recursion loop
44 # in derived classes
45 if (
46 len(call.args) >= 2
47 and isinstance(call.args[1], nodes.Name)
48 and call.args[1].name == "self"
49 and isinstance(arg0, nodes.Attribute)
50 and arg0.attrname == "__class__"
51 ):
52 self.add_message(
53 "bad-super-call", node=call, args=("self.__class__",)
54 )
55 continue
56
57 try:
58 supcls = call.args and next(call.args[0].infer(), None)
59 except astroid.InferenceError:
60 continue
61
62 # If the supcls is in the ancestors of klass super can be used to skip
63 # a step in the mro() and get a method from a higher parent
64 if klass is not supcls and all(i != supcls for i in klass.ancestors()):
65 name = None
66 # if supcls is not Uninferable, then supcls was inferred
67 # and use its name. Otherwise, try to look
68 # for call.args[0].name
69 if supcls:
70 name = supcls.name
71 elif call.args and hasattr(call.args[0], "name"):
72 name = call.args[0].name
73 if name:
74 self.add_message("bad-super-call", node=call, args=(name,))
Path 8: 4 calls (0.0)
FunctionDef (4)
1@only_required_for_messages("bad-super-call")
2 def visit_functiondef(self, node: nodes.FunctionDef) -> None:
3 """Check use of super."""
4 # ignore actual functions or method within a new style class
5 if not node.is_method():
6 return
7 klass = node.parent.frame(future=True)
8 for stmt in node.nodes_of_class(nodes.Call):
9 if node_frame_class(stmt) != node_frame_class(node):
10 # Don't look down in other scopes.
11 continue
12
13 expr = stmt.func
14 if not isinstance(expr, nodes.Attribute):
15 continue
16
17 call = expr.expr
18 # skip the test if using super
19 if not (
20 isinstance(call, nodes.Call)
21 and isinstance(call.func, nodes.Name)
22 and call.func.name == "super"
23 ):
24 continue
25
26 # super should not be used on an old style class
27 if klass.newstyle or not has_known_bases(klass):
28 # super first arg should not be the class
29 if not call.args:
30 continue
31
32 # calling super(type(self), self) can lead to recursion loop
33 # in derived classes
34 arg0 = call.args[0]
35 if (
36 isinstance(arg0, nodes.Call)
37 and isinstance(arg0.func, nodes.Name)
38 and arg0.func.name == "type"
39 ):
40 self.add_message("bad-super-call", node=call, args=("type",))
41 continue
42
43 # calling super(self.__class__, self) can lead to recursion loop
44 # in derived classes
45 if (
46 len(call.args) >= 2
47 and isinstance(call.args[1], nodes.Name)
48 and call.args[1].name == "self"
49 and isinstance(arg0, nodes.Attribute)
50 and arg0.attrname == "__class__"
51 ):
52 self.add_message(
53 "bad-super-call", node=call, args=("self.__class__",)
54 )
55 continue
56
57 try:
58 supcls = call.args and next(call.args[0].infer(), None)
59 except astroid.InferenceError:
60 continue
61
62 # If the supcls is in the ancestors of klass super can be used to skip
63 # a step in the mro() and get a method from a higher parent
64 if klass is not supcls and all(i != supcls for i in klass.ancestors()):
65 name = None
66 # if supcls is not Uninferable, then supcls was inferred
67 # and use its name. Otherwise, try to look
68 # for call.args[0].name
69 if supcls:
70 name = supcls.name
71 elif call.args and hasattr(call.args[0], "name"):
72 name = call.args[0].name
73 if name:
74 self.add_message("bad-super-call", node=call, args=(name,))
Path 9: 4 calls (0.0)
FunctionDef (4)
1@only_required_for_messages("bad-super-call")
2 def visit_functiondef(self, node: nodes.FunctionDef) -> None:
3 """Check use of super."""
4 # ignore actual functions or method within a new style class
5 if not node.is_method():
6 return
7 klass = node.parent.frame(future=True)
8 for stmt in node.nodes_of_class(nodes.Call):
9 if node_frame_class(stmt) != node_frame_class(node):
10 # Don't look down in other scopes.
11 continue
12
13 expr = stmt.func
14 if not isinstance(expr, nodes.Attribute):
15 continue
16
17 call = expr.expr
18 # skip the test if using super
19 if not (
20 isinstance(call, nodes.Call)
21 and isinstance(call.func, nodes.Name)
22 and call.func.name == "super"
23 ):
24 continue
25
26 # super should not be used on an old style class
27 if klass.newstyle or not has_known_bases(klass):
28 # super first arg should not be the class
29 if not call.args:
30 continue
31
32 # calling super(type(self), self) can lead to recursion loop
33 # in derived classes
34 arg0 = call.args[0]
35 if (
36 isinstance(arg0, nodes.Call)
37 and isinstance(arg0.func, nodes.Name)
38 and arg0.func.name == "type"
39 ):
40 self.add_message("bad-super-call", node=call, args=("type",))
41 continue
42
43 # calling super(self.__class__, self) can lead to recursion loop
44 # in derived classes
45 if (
46 len(call.args) >= 2
47 and isinstance(call.args[1], nodes.Name)
48 and call.args[1].name == "self"
49 and isinstance(arg0, nodes.Attribute)
50 and arg0.attrname == "__class__"
51 ):
52 self.add_message(
53 "bad-super-call", node=call, args=("self.__class__",)
54 )
55 continue
56
57 try:
58 supcls = call.args and next(call.args[0].infer(), None)
59 except astroid.InferenceError:
60 continue
61
62 # If the supcls is in the ancestors of klass super can be used to skip
63 # a step in the mro() and get a method from a higher parent
64 if klass is not supcls and all(i != supcls for i in klass.ancestors()):
65 name = None
66 # if supcls is not Uninferable, then supcls was inferred
67 # and use its name. Otherwise, try to look
68 # for call.args[0].name
69 if supcls:
70 name = supcls.name
71 elif call.args and hasattr(call.args[0], "name"):
72 name = call.args[0].name
73 if name:
74 self.add_message("bad-super-call", node=call, args=(name,))
Path 10: 3 calls (0.0)
FunctionDef (2) AsyncFunctionDef (1)
GeneratorExit (1)
1@only_required_for_messages("bad-super-call")
2 def visit_functiondef(self, node: nodes.FunctionDef) -> None:
3 """Check use of super."""
4 # ignore actual functions or method within a new style class
5 if not node.is_method():
6 return
7 klass = node.parent.frame(future=True)
8 for stmt in node.nodes_of_class(nodes.Call):
9 if node_frame_class(stmt) != node_frame_class(node):
10 # Don't look down in other scopes.
11 continue
12
13 expr = stmt.func
14 if not isinstance(expr, nodes.Attribute):
15 continue
16
17 call = expr.expr
18 # skip the test if using super
19 if not (
20 isinstance(call, nodes.Call)
21 and isinstance(call.func, nodes.Name)
22 and call.func.name == "super"
23 ):
24 continue
25
26 # super should not be used on an old style class
27 if klass.newstyle or not has_known_bases(klass):
28 # super first arg should not be the class
29 if not call.args:
30 continue
31
32 # calling super(type(self), self) can lead to recursion loop
33 # in derived classes
34 arg0 = call.args[0]
35 if (
36 isinstance(arg0, nodes.Call)
37 and isinstance(arg0.func, nodes.Name)
38 and arg0.func.name == "type"
39 ):
40 self.add_message("bad-super-call", node=call, args=("type",))
41 continue
42
43 # calling super(self.__class__, self) can lead to recursion loop
44 # in derived classes
45 if (
46 len(call.args) >= 2
47 and isinstance(call.args[1], nodes.Name)
48 and call.args[1].name == "self"
49 and isinstance(arg0, nodes.Attribute)
50 and arg0.attrname == "__class__"
51 ):
52 self.add_message(
53 "bad-super-call", node=call, args=("self.__class__",)
54 )
55 continue
56
57 try:
58 supcls = call.args and next(call.args[0].infer(), None)
59 except astroid.InferenceError:
60 continue
61
62 # If the supcls is in the ancestors of klass super can be used to skip
63 # a step in the mro() and get a method from a higher parent
64 if klass is not supcls and all(i != supcls for i in klass.ancestors()):
65 name = None
66 # if supcls is not Uninferable, then supcls was inferred
67 # and use its name. Otherwise, try to look
68 # for call.args[0].name
69 if supcls:
70 name = supcls.name
71 elif call.args and hasattr(call.args[0], "name"):
72 name = call.args[0].name
73 if name:
74 self.add_message("bad-super-call", node=call, args=(name,))
Path 11: 3 calls (0.0)
FunctionDef (3)
1@only_required_for_messages("bad-super-call")
2 def visit_functiondef(self, node: nodes.FunctionDef) -> None:
3 """Check use of super."""
4 # ignore actual functions or method within a new style class
5 if not node.is_method():
6 return
7 klass = node.parent.frame(future=True)
8 for stmt in node.nodes_of_class(nodes.Call):
9 if node_frame_class(stmt) != node_frame_class(node):
10 # Don't look down in other scopes.
11 continue
12
13 expr = stmt.func
14 if not isinstance(expr, nodes.Attribute):
15 continue
16
17 call = expr.expr
18 # skip the test if using super
19 if not (
20 isinstance(call, nodes.Call)
21 and isinstance(call.func, nodes.Name)
22 and call.func.name == "super"
23 ):
24 continue
25
26 # super should not be used on an old style class
27 if klass.newstyle or not has_known_bases(klass):
28 # super first arg should not be the class
29 if not call.args:
30 continue
31
32 # calling super(type(self), self) can lead to recursion loop
33 # in derived classes
34 arg0 = call.args[0]
35 if (
36 isinstance(arg0, nodes.Call)
37 and isinstance(arg0.func, nodes.Name)
38 and arg0.func.name == "type"
39 ):
40 self.add_message("bad-super-call", node=call, args=("type",))
41 continue
42
43 # calling super(self.__class__, self) can lead to recursion loop
44 # in derived classes
45 if (
46 len(call.args) >= 2
47 and isinstance(call.args[1], nodes.Name)
48 and call.args[1].name == "self"
49 and isinstance(arg0, nodes.Attribute)
50 and arg0.attrname == "__class__"
51 ):
52 self.add_message(
53 "bad-super-call", node=call, args=("self.__class__",)
54 )
55 continue
56
57 try:
58 supcls = call.args and next(call.args[0].infer(), None)
59 except astroid.InferenceError:
60 continue
61
62 # If the supcls is in the ancestors of klass super can be used to skip
63 # a step in the mro() and get a method from a higher parent
64 if klass is not supcls and all(i != supcls for i in klass.ancestors()):
65 name = None
66 # if supcls is not Uninferable, then supcls was inferred
67 # and use its name. Otherwise, try to look
68 # for call.args[0].name
69 if supcls:
70 name = supcls.name
71 elif call.args and hasattr(call.args[0], "name"):
72 name = call.args[0].name
73 if name:
74 self.add_message("bad-super-call", node=call, args=(name,))
Path 12: 2 calls (0.0)
FunctionDef (2)
1@only_required_for_messages("bad-super-call")
2 def visit_functiondef(self, node: nodes.FunctionDef) -> None:
3 """Check use of super."""
4 # ignore actual functions or method within a new style class
5 if not node.is_method():
6 return
7 klass = node.parent.frame(future=True)
8 for stmt in node.nodes_of_class(nodes.Call):
9 if node_frame_class(stmt) != node_frame_class(node):
10 # Don't look down in other scopes.
11 continue
12
13 expr = stmt.func
14 if not isinstance(expr, nodes.Attribute):
15 continue
16
17 call = expr.expr
18 # skip the test if using super
19 if not (
20 isinstance(call, nodes.Call)
21 and isinstance(call.func, nodes.Name)
22 and call.func.name == "super"
23 ):
24 continue
25
26 # super should not be used on an old style class
27 if klass.newstyle or not has_known_bases(klass):
28 # super first arg should not be the class
29 if not call.args:
30 continue
31
32 # calling super(type(self), self) can lead to recursion loop
33 # in derived classes
34 arg0 = call.args[0]
35 if (
36 isinstance(arg0, nodes.Call)
37 and isinstance(arg0.func, nodes.Name)
38 and arg0.func.name == "type"
39 ):
40 self.add_message("bad-super-call", node=call, args=("type",))
41 continue
42
43 # calling super(self.__class__, self) can lead to recursion loop
44 # in derived classes
45 if (
46 len(call.args) >= 2
47 and isinstance(call.args[1], nodes.Name)
48 and call.args[1].name == "self"
49 and isinstance(arg0, nodes.Attribute)
50 and arg0.attrname == "__class__"
51 ):
52 self.add_message(
53 "bad-super-call", node=call, args=("self.__class__",)
54 )
55 continue
56
57 try:
58 supcls = call.args and next(call.args[0].infer(), None)
59 except astroid.InferenceError:
60 continue
61
62 # If the supcls is in the ancestors of klass super can be used to skip
63 # a step in the mro() and get a method from a higher parent
64 if klass is not supcls and all(i != supcls for i in klass.ancestors()):
65 name = None
66 # if supcls is not Uninferable, then supcls was inferred
67 # and use its name. Otherwise, try to look
68 # for call.args[0].name
69 if supcls:
70 name = supcls.name
71 elif call.args and hasattr(call.args[0], "name"):
72 name = call.args[0].name
73 if name:
74 self.add_message("bad-super-call", node=call, args=(name,))
Path 13: 2 calls (0.0)
FunctionDef (2)
1@only_required_for_messages("bad-super-call")
2 def visit_functiondef(self, node: nodes.FunctionDef) -> None:
3 """Check use of super."""
4 # ignore actual functions or method within a new style class
5 if not node.is_method():
6 return
7 klass = node.parent.frame(future=True)
8 for stmt in node.nodes_of_class(nodes.Call):
9 if node_frame_class(stmt) != node_frame_class(node):
10 # Don't look down in other scopes.
11 continue
12
13 expr = stmt.func
14 if not isinstance(expr, nodes.Attribute):
15 continue
16
17 call = expr.expr
18 # skip the test if using super
19 if not (
20 isinstance(call, nodes.Call)
21 and isinstance(call.func, nodes.Name)
22 and call.func.name == "super"
23 ):
24 continue
25
26 # super should not be used on an old style class
27 if klass.newstyle or not has_known_bases(klass):
28 # super first arg should not be the class
29 if not call.args:
30 continue
31
32 # calling super(type(self), self) can lead to recursion loop
33 # in derived classes
34 arg0 = call.args[0]
35 if (
36 isinstance(arg0, nodes.Call)
37 and isinstance(arg0.func, nodes.Name)
38 and arg0.func.name == "type"
39 ):
40 self.add_message("bad-super-call", node=call, args=("type",))
41 continue
42
43 # calling super(self.__class__, self) can lead to recursion loop
44 # in derived classes
45 if (
46 len(call.args) >= 2
47 and isinstance(call.args[1], nodes.Name)
48 and call.args[1].name == "self"
49 and isinstance(arg0, nodes.Attribute)
50 and arg0.attrname == "__class__"
51 ):
52 self.add_message(
53 "bad-super-call", node=call, args=("self.__class__",)
54 )
55 continue
56
57 try:
58 supcls = call.args and next(call.args[0].infer(), None)
59 except astroid.InferenceError:
60 continue
61
62 # If the supcls is in the ancestors of klass super can be used to skip
63 # a step in the mro() and get a method from a higher parent
64 if klass is not supcls and all(i != supcls for i in klass.ancestors()):
65 name = None
66 # if supcls is not Uninferable, then supcls was inferred
67 # and use its name. Otherwise, try to look
68 # for call.args[0].name
69 if supcls:
70 name = supcls.name
71 elif call.args and hasattr(call.args[0], "name"):
72 name = call.args[0].name
73 if name:
74 self.add_message("bad-super-call", node=call, args=(name,))
Path 14: 1 calls (0.0)
FunctionDef (1)
1@only_required_for_messages("bad-super-call")
2 def visit_functiondef(self, node: nodes.FunctionDef) -> None:
3 """Check use of super."""
4 # ignore actual functions or method within a new style class
5 if not node.is_method():
6 return
7 klass = node.parent.frame(future=True)
8 for stmt in node.nodes_of_class(nodes.Call):
9 if node_frame_class(stmt) != node_frame_class(node):
10 # Don't look down in other scopes.
11 continue
12
13 expr = stmt.func
14 if not isinstance(expr, nodes.Attribute):
15 continue
16
17 call = expr.expr
18 # skip the test if using super
19 if not (
20 isinstance(call, nodes.Call)
21 and isinstance(call.func, nodes.Name)
22 and call.func.name == "super"
23 ):
24 continue
25
26 # super should not be used on an old style class
27 if klass.newstyle or not has_known_bases(klass):
28 # super first arg should not be the class
29 if not call.args:
30 continue
31
32 # calling super(type(self), self) can lead to recursion loop
33 # in derived classes
34 arg0 = call.args[0]
35 if (
36 isinstance(arg0, nodes.Call)
37 and isinstance(arg0.func, nodes.Name)
38 and arg0.func.name == "type"
39 ):
40 self.add_message("bad-super-call", node=call, args=("type",))
41 continue
42
43 # calling super(self.__class__, self) can lead to recursion loop
44 # in derived classes
45 if (
46 len(call.args) >= 2
47 and isinstance(call.args[1], nodes.Name)
48 and call.args[1].name == "self"
49 and isinstance(arg0, nodes.Attribute)
50 and arg0.attrname == "__class__"
51 ):
52 self.add_message(
53 "bad-super-call", node=call, args=("self.__class__",)
54 )
55 continue
56
57 try:
58 supcls = call.args and next(call.args[0].infer(), None)
59 except astroid.InferenceError:
60 continue
61
62 # If the supcls is in the ancestors of klass super can be used to skip
63 # a step in the mro() and get a method from a higher parent
64 if klass is not supcls and all(i != supcls for i in klass.ancestors()):
65 name = None
66 # if supcls is not Uninferable, then supcls was inferred
67 # and use its name. Otherwise, try to look
68 # for call.args[0].name
69 if supcls:
70 name = supcls.name
71 elif call.args and hasattr(call.args[0], "name"):
72 name = call.args[0].name
73 if name:
74 self.add_message("bad-super-call", node=call, args=(name,))
Path 15: 1 calls (0.0)
FunctionDef (1)
1@only_required_for_messages("bad-super-call")
2 def visit_functiondef(self, node: nodes.FunctionDef) -> None:
3 """Check use of super."""
4 # ignore actual functions or method within a new style class
5 if not node.is_method():
6 return
7 klass = node.parent.frame(future=True)
8 for stmt in node.nodes_of_class(nodes.Call):
9 if node_frame_class(stmt) != node_frame_class(node):
10 # Don't look down in other scopes.
11 continue
12
13 expr = stmt.func
14 if not isinstance(expr, nodes.Attribute):
15 continue
16
17 call = expr.expr
18 # skip the test if using super
19 if not (
20 isinstance(call, nodes.Call)
21 and isinstance(call.func, nodes.Name)
22 and call.func.name == "super"
23 ):
24 continue
25
26 # super should not be used on an old style class
27 if klass.newstyle or not has_known_bases(klass):
28 # super first arg should not be the class
29 if not call.args:
30 continue
31
32 # calling super(type(self), self) can lead to recursion loop
33 # in derived classes
34 arg0 = call.args[0]
35 if (
36 isinstance(arg0, nodes.Call)
37 and isinstance(arg0.func, nodes.Name)
38 and arg0.func.name == "type"
39 ):
40 self.add_message("bad-super-call", node=call, args=("type",))
41 continue
42
43 # calling super(self.__class__, self) can lead to recursion loop
44 # in derived classes
45 if (
46 len(call.args) >= 2
47 and isinstance(call.args[1], nodes.Name)
48 and call.args[1].name == "self"
49 and isinstance(arg0, nodes.Attribute)
50 and arg0.attrname == "__class__"
51 ):
52 self.add_message(
53 "bad-super-call", node=call, args=("self.__class__",)
54 )
55 continue
56
57 try:
58 supcls = call.args and next(call.args[0].infer(), None)
59 except astroid.InferenceError:
60 continue
61
62 # If the supcls is in the ancestors of klass super can be used to skip
63 # a step in the mro() and get a method from a higher parent
64 if klass is not supcls and all(i != supcls for i in klass.ancestors()):
65 name = None
66 # if supcls is not Uninferable, then supcls was inferred
67 # and use its name. Otherwise, try to look
68 # for call.args[0].name
69 if supcls:
70 name = supcls.name
71 elif call.args and hasattr(call.args[0], "name"):
72 name = call.args[0].name
73 if name:
74 self.add_message("bad-super-call", node=call, args=(name,))
Path 16: 1 calls (0.0)
FunctionDef (1)
GeneratorExit (1)
1@only_required_for_messages("bad-super-call")
2 def visit_functiondef(self, node: nodes.FunctionDef) -> None:
3 """Check use of super."""
4 # ignore actual functions or method within a new style class
5 if not node.is_method():
6 return
7 klass = node.parent.frame(future=True)
8 for stmt in node.nodes_of_class(nodes.Call):
9 if node_frame_class(stmt) != node_frame_class(node):
10 # Don't look down in other scopes.
11 continue
12
13 expr = stmt.func
14 if not isinstance(expr, nodes.Attribute):
15 continue
16
17 call = expr.expr
18 # skip the test if using super
19 if not (
20 isinstance(call, nodes.Call)
21 and isinstance(call.func, nodes.Name)
22 and call.func.name == "super"
23 ):
24 continue
25
26 # super should not be used on an old style class
27 if klass.newstyle or not has_known_bases(klass):
28 # super first arg should not be the class
29 if not call.args:
30 continue
31
32 # calling super(type(self), self) can lead to recursion loop
33 # in derived classes
34 arg0 = call.args[0]
35 if (
36 isinstance(arg0, nodes.Call)
37 and isinstance(arg0.func, nodes.Name)
38 and arg0.func.name == "type"
39 ):
40 self.add_message("bad-super-call", node=call, args=("type",))
41 continue
42
43 # calling super(self.__class__, self) can lead to recursion loop
44 # in derived classes
45 if (
46 len(call.args) >= 2
47 and isinstance(call.args[1], nodes.Name)
48 and call.args[1].name == "self"
49 and isinstance(arg0, nodes.Attribute)
50 and arg0.attrname == "__class__"
51 ):
52 self.add_message(
53 "bad-super-call", node=call, args=("self.__class__",)
54 )
55 continue
56
57 try:
58 supcls = call.args and next(call.args[0].infer(), None)
59 except astroid.InferenceError:
60 continue
61
62 # If the supcls is in the ancestors of klass super can be used to skip
63 # a step in the mro() and get a method from a higher parent
64 if klass is not supcls and all(i != supcls for i in klass.ancestors()):
65 name = None
66 # if supcls is not Uninferable, then supcls was inferred
67 # and use its name. Otherwise, try to look
68 # for call.args[0].name
69 if supcls:
70 name = supcls.name
71 elif call.args and hasattr(call.args[0], "name"):
72 name = call.args[0].name
73 if name:
74 self.add_message("bad-super-call", node=call, args=(name,))
Path 17: 1 calls (0.0)
FunctionDef (1)
1@only_required_for_messages("bad-super-call")
2 def visit_functiondef(self, node: nodes.FunctionDef) -> None:
3 """Check use of super."""
4 # ignore actual functions or method within a new style class
5 if not node.is_method():
6 return
7 klass = node.parent.frame(future=True)
8 for stmt in node.nodes_of_class(nodes.Call):
9 if node_frame_class(stmt) != node_frame_class(node):
10 # Don't look down in other scopes.
11 continue
12
13 expr = stmt.func
14 if not isinstance(expr, nodes.Attribute):
15 continue
16
17 call = expr.expr
18 # skip the test if using super
19 if not (
20 isinstance(call, nodes.Call)
21 and isinstance(call.func, nodes.Name)
22 and call.func.name == "super"
23 ):
24 continue
25
26 # super should not be used on an old style class
27 if klass.newstyle or not has_known_bases(klass):
28 # super first arg should not be the class
29 if not call.args:
30 continue
31
32 # calling super(type(self), self) can lead to recursion loop
33 # in derived classes
34 arg0 = call.args[0]
35 if (
36 isinstance(arg0, nodes.Call)
37 and isinstance(arg0.func, nodes.Name)
38 and arg0.func.name == "type"
39 ):
40 self.add_message("bad-super-call", node=call, args=("type",))
41 continue
42
43 # calling super(self.__class__, self) can lead to recursion loop
44 # in derived classes
45 if (
46 len(call.args) >= 2
47 and isinstance(call.args[1], nodes.Name)
48 and call.args[1].name == "self"
49 and isinstance(arg0, nodes.Attribute)
50 and arg0.attrname == "__class__"
51 ):
52 self.add_message(
53 "bad-super-call", node=call, args=("self.__class__",)
54 )
55 continue
56
57 try:
58 supcls = call.args and next(call.args[0].infer(), None)
59 except astroid.InferenceError:
60 continue
61
62 # If the supcls is in the ancestors of klass super can be used to skip
63 # a step in the mro() and get a method from a higher parent
64 if klass is not supcls and all(i != supcls for i in klass.ancestors()):
65 name = None
66 # if supcls is not Uninferable, then supcls was inferred
67 # and use its name. Otherwise, try to look
68 # for call.args[0].name
69 if supcls:
70 name = supcls.name
71 elif call.args and hasattr(call.args[0], "name"):
72 name = call.args[0].name
73 if name:
74 self.add_message("bad-super-call", node=call, args=(name,))
Path 18: 1 calls (0.0)
FunctionDef (1)
1@only_required_for_messages("bad-super-call")
2 def visit_functiondef(self, node: nodes.FunctionDef) -> None:
3 """Check use of super."""
4 # ignore actual functions or method within a new style class
5 if not node.is_method():
6 return
7 klass = node.parent.frame(future=True)
8 for stmt in node.nodes_of_class(nodes.Call):
9 if node_frame_class(stmt) != node_frame_class(node):
10 # Don't look down in other scopes.
11 continue
12
13 expr = stmt.func
14 if not isinstance(expr, nodes.Attribute):
15 continue
16
17 call = expr.expr
18 # skip the test if using super
19 if not (
20 isinstance(call, nodes.Call)
21 and isinstance(call.func, nodes.Name)
22 and call.func.name == "super"
23 ):
24 continue
25
26 # super should not be used on an old style class
27 if klass.newstyle or not has_known_bases(klass):
28 # super first arg should not be the class
29 if not call.args:
30 continue
31
32 # calling super(type(self), self) can lead to recursion loop
33 # in derived classes
34 arg0 = call.args[0]
35 if (
36 isinstance(arg0, nodes.Call)
37 and isinstance(arg0.func, nodes.Name)
38 and arg0.func.name == "type"
39 ):
40 self.add_message("bad-super-call", node=call, args=("type",))
41 continue
42
43 # calling super(self.__class__, self) can lead to recursion loop
44 # in derived classes
45 if (
46 len(call.args) >= 2
47 and isinstance(call.args[1], nodes.Name)
48 and call.args[1].name == "self"
49 and isinstance(arg0, nodes.Attribute)
50 and arg0.attrname == "__class__"
51 ):
52 self.add_message(
53 "bad-super-call", node=call, args=("self.__class__",)
54 )
55 continue
56
57 try:
58 supcls = call.args and next(call.args[0].infer(), None)
59 except astroid.InferenceError:
60 continue
61
62 # If the supcls is in the ancestors of klass super can be used to skip
63 # a step in the mro() and get a method from a higher parent
64 if klass is not supcls and all(i != supcls for i in klass.ancestors()):
65 name = None
66 # if supcls is not Uninferable, then supcls was inferred
67 # and use its name. Otherwise, try to look
68 # for call.args[0].name
69 if supcls:
70 name = supcls.name
71 elif call.args and hasattr(call.args[0], "name"):
72 name = call.args[0].name
73 if name:
74 self.add_message("bad-super-call", node=call, args=(name,))
Path 19: 1 calls (0.0)
FunctionDef (1)
1@only_required_for_messages("bad-super-call")
2 def visit_functiondef(self, node: nodes.FunctionDef) -> None:
3 """Check use of super."""
4 # ignore actual functions or method within a new style class
5 if not node.is_method():
6 return
7 klass = node.parent.frame(future=True)
8 for stmt in node.nodes_of_class(nodes.Call):
9 if node_frame_class(stmt) != node_frame_class(node):
10 # Don't look down in other scopes.
11 continue
12
13 expr = stmt.func
14 if not isinstance(expr, nodes.Attribute):
15 continue
16
17 call = expr.expr
18 # skip the test if using super
19 if not (
20 isinstance(call, nodes.Call)
21 and isinstance(call.func, nodes.Name)
22 and call.func.name == "super"
23 ):
24 continue
25
26 # super should not be used on an old style class
27 if klass.newstyle or not has_known_bases(klass):
28 # super first arg should not be the class
29 if not call.args:
30 continue
31
32 # calling super(type(self), self) can lead to recursion loop
33 # in derived classes
34 arg0 = call.args[0]
35 if (
36 isinstance(arg0, nodes.Call)
37 and isinstance(arg0.func, nodes.Name)
38 and arg0.func.name == "type"
39 ):
40 self.add_message("bad-super-call", node=call, args=("type",))
41 continue
42
43 # calling super(self.__class__, self) can lead to recursion loop
44 # in derived classes
45 if (
46 len(call.args) >= 2
47 and isinstance(call.args[1], nodes.Name)
48 and call.args[1].name == "self"
49 and isinstance(arg0, nodes.Attribute)
50 and arg0.attrname == "__class__"
51 ):
52 self.add_message(
53 "bad-super-call", node=call, args=("self.__class__",)
54 )
55 continue
56
57 try:
58 supcls = call.args and next(call.args[0].infer(), None)
59 except astroid.InferenceError:
60 continue
61
62 # If the supcls is in the ancestors of klass super can be used to skip
63 # a step in the mro() and get a method from a higher parent
64 if klass is not supcls and all(i != supcls for i in klass.ancestors()):
65 name = None
66 # if supcls is not Uninferable, then supcls was inferred
67 # and use its name. Otherwise, try to look
68 # for call.args[0].name
69 if supcls:
70 name = supcls.name
71 elif call.args and hasattr(call.args[0], "name"):
72 name = call.args[0].name
73 if name:
74 self.add_message("bad-super-call", node=call, args=(name,))