Method: pylint.checkers.classes.class_checker.ClassChecker._is_mandatory_method_param
Calls: 3699, Exceptions: 0, Paths: 3Back
Path 1: 1498 calls (0.4)
Name (1144) Attribute (150) Call (112) Const (45) Dict (38) Subscript (6) BinOp (2) Set (1)
False (1498)
1def _is_mandatory_method_param(self, node: nodes.NodeNG) -> bool:
2 """Check if nodes.Name corresponds to first attribute variable name.
3
4 Name is `self` for method, `cls` for classmethod and `mcs` for metaclass.
5 Static methods return False.
6 """
7 if self._first_attrs:
8 first_attr = self._first_attrs[-1]
9 else:
10 # It's possible the function was already unregistered.
11 closest_func = utils.get_node_first_ancestor_of_type(
12 node, nodes.FunctionDef
13 )
14 if closest_func is None:
15 return False
16 if not closest_func.is_bound():
17 return False
18 if not closest_func.args.args:
19 return False
20 first_attr = closest_func.args.args[0].name
21 return isinstance(node, nodes.Name) and node.name == first_attr
Path 2: 1264 calls (0.34)
Name (1004) Call (175) Attribute (79) Const (6)
True (714) False (550)
1def _is_mandatory_method_param(self, node: nodes.NodeNG) -> bool:
2 """Check if nodes.Name corresponds to first attribute variable name.
3
4 Name is `self` for method, `cls` for classmethod and `mcs` for metaclass.
5 Static methods return False.
6 """
7 if self._first_attrs:
8 first_attr = self._first_attrs[-1]
9 else:
10 # It's possible the function was already unregistered.
11 closest_func = utils.get_node_first_ancestor_of_type(
12 node, nodes.FunctionDef
13 )
14 if closest_func is None:
15 return False
16 if not closest_func.is_bound():
17 return False
18 if not closest_func.args.args:
19 return False
20 first_attr = closest_func.args.args[0].name
21 return isinstance(node, nodes.Name) and node.name == first_attr
Path 3: 937 calls (0.25)
Name (663) Const (136) Attribute (96) Call (30) Dict (4) IfExp (4) Subscript (2) JoinedStr (1) Compare (1)
False (937)
1def _is_mandatory_method_param(self, node: nodes.NodeNG) -> bool:
2 """Check if nodes.Name corresponds to first attribute variable name.
3
4 Name is `self` for method, `cls` for classmethod and `mcs` for metaclass.
5 Static methods return False.
6 """
7 if self._first_attrs:
8 first_attr = self._first_attrs[-1]
9 else:
10 # It's possible the function was already unregistered.
11 closest_func = utils.get_node_first_ancestor_of_type(
12 node, nodes.FunctionDef
13 )
14 if closest_func is None:
15 return False
16 if not closest_func.is_bound():
17 return False
18 if not closest_func.args.args:
19 return False
20 first_attr = closest_func.args.args[0].name
21 return isinstance(node, nodes.Name) and node.name == first_attr