Path 1: 1805 calls (0.51)

FunctionDef (1768) AsyncFunctionDef (37)

None (1805)

1def visit_functiondef(self, node: nodes.FunctionDef) -> None:
2        """Check method arguments, overriding."""
3        # ignore actual functions
4        if not node.is_method():
5            return
6
7        self._check_useless_super_delegation(node)
8        self._check_property_with_parameters(node)
9
10        # 'is_method()' is called and makes sure that this is a 'nodes.ClassDef'
11        klass = node.parent.frame(future=True)  # type: nodes.ClassDef
12        # check first argument is self if this is actually a method
13        self._check_first_arg_for_type(node, klass.type == "metaclass")
14        if node.name == "__init__":
15            self._check_init(node, klass)
16            return
17        # check signature if the method overloads inherited method
18        for overridden in klass.local_attr_ancestors(node.name):
19            # get astroid for the searched method
20            try:
21                parent_function = overridden[node.name]
22            except KeyError:
23                # we have found the method but it's not in the local
24                # dictionary.
25                # This may happen with astroid build from living objects
26                continue
27            if not isinstance(parent_function, nodes.FunctionDef):
28                continue
29            self._check_signature(node, parent_function, klass)
30            self._check_invalid_overridden_method(node, parent_function)
31            break
32
33        if node.decorators:
34            for decorator in node.decorators.nodes:
35                if isinstance(decorator, nodes.Attribute) and decorator.attrname in {
36                    "getter",
37                    "setter",
38                    "deleter",
39                }:
40                    # attribute affectation will call this method, not hiding it
41                    return
42                if isinstance(decorator, nodes.Name):
43                    if decorator.name == "property":
44                        # attribute affectation will either call a setter or raise
45                        # an attribute error, anyway not hiding the function
46                        return
47
48                # Infer the decorator and see if it returns something useful
49                inferred = safe_infer(decorator)
50                if not inferred:
51                    return
52                if isinstance(inferred, nodes.FunctionDef):
53                    # Okay, it's a decorator, let's see what it can infer.
54                    try:
55                        inferred = next(inferred.infer_call_result(inferred))
56                    except astroid.InferenceError:
57                        return
58                try:
59                    if (
60                        isinstance(inferred, (astroid.Instance, nodes.ClassDef))
61                        and inferred.getattr("__get__")
62                        and inferred.getattr("__set__")
63                    ):
64                        return
65                except astroid.AttributeInferenceError:
66                    pass
67
68        # check if the method is hidden by an attribute
69        # pylint: disable = too-many-try-statements
70        try:
71            overridden = klass.instance_attr(node.name)[0]
72            overridden_frame = overridden.frame(future=True)
73            if (
74                isinstance(overridden_frame, nodes.FunctionDef)
75                and overridden_frame.type == "method"
76            ):
77                overridden_frame = overridden_frame.parent.frame(future=True)
78            if not (
79                isinstance(overridden_frame, nodes.ClassDef)
80                and klass.is_subtype_of(overridden_frame.qname())
81            ):
82                return
83
84            # If a subclass defined the method then it's not our fault.
85            for ancestor in klass.ancestors():
86                if node.name in ancestor.instance_attrs and is_attr_private(node.name):
87                    return
88                for obj in ancestor.lookup(node.name)[1]:
89                    if isinstance(obj, nodes.FunctionDef):
90                        return
91            args = (overridden.root().name, overridden.fromlineno)
92            self.add_message("method-hidden", args=args, node=node)
93        except astroid.NotFoundError:
94            pass
            

Path 2: 834 calls (0.24)

FunctionDef (822) AsyncFunctionDef (12)

AttributeInferenceError (834)

1def visit_functiondef(self, node: nodes.FunctionDef) -> None:
2        """Check method arguments, overriding."""
3        # ignore actual functions
4        if not node.is_method():
5            return
6
7        self._check_useless_super_delegation(node)
8        self._check_property_with_parameters(node)
9
10        # 'is_method()' is called and makes sure that this is a 'nodes.ClassDef'
11        klass = node.parent.frame(future=True)  # type: nodes.ClassDef
12        # check first argument is self if this is actually a method
13        self._check_first_arg_for_type(node, klass.type == "metaclass")
14        if node.name == "__init__":
15            self._check_init(node, klass)
16            return
17        # check signature if the method overloads inherited method
18        for overridden in klass.local_attr_ancestors(node.name):
19            # get astroid for the searched method
20            try:
21                parent_function = overridden[node.name]
22            except KeyError:
23                # we have found the method but it's not in the local
24                # dictionary.
25                # This may happen with astroid build from living objects
26                continue
27            if not isinstance(parent_function, nodes.FunctionDef):
28                continue
29            self._check_signature(node, parent_function, klass)
30            self._check_invalid_overridden_method(node, parent_function)
31            break
32
33        if node.decorators:
34            for decorator in node.decorators.nodes:
35                if isinstance(decorator, nodes.Attribute) and decorator.attrname in {
36                    "getter",
37                    "setter",
38                    "deleter",
39                }:
40                    # attribute affectation will call this method, not hiding it
41                    return
42                if isinstance(decorator, nodes.Name):
43                    if decorator.name == "property":
44                        # attribute affectation will either call a setter or raise
45                        # an attribute error, anyway not hiding the function
46                        return
47
48                # Infer the decorator and see if it returns something useful
49                inferred = safe_infer(decorator)
50                if not inferred:
51                    return
52                if isinstance(inferred, nodes.FunctionDef):
53                    # Okay, it's a decorator, let's see what it can infer.
54                    try:
55                        inferred = next(inferred.infer_call_result(inferred))
56                    except astroid.InferenceError:
57                        return
58                try:
59                    if (
60                        isinstance(inferred, (astroid.Instance, nodes.ClassDef))
61                        and inferred.getattr("__get__")
62                        and inferred.getattr("__set__")
63                    ):
64                        return
65                except astroid.AttributeInferenceError:
66                    pass
67
68        # check if the method is hidden by an attribute
69        # pylint: disable = too-many-try-statements
70        try:
71            overridden = klass.instance_attr(node.name)[0]
72            overridden_frame = overridden.frame(future=True)
73            if (
74                isinstance(overridden_frame, nodes.FunctionDef)
75                and overridden_frame.type == "method"
76            ):
77                overridden_frame = overridden_frame.parent.frame(future=True)
78            if not (
79                isinstance(overridden_frame, nodes.ClassDef)
80                and klass.is_subtype_of(overridden_frame.qname())
81            ):
82                return
83
84            # If a subclass defined the method then it's not our fault.
85            for ancestor in klass.ancestors():
86                if node.name in ancestor.instance_attrs and is_attr_private(node.name):
87                    return
88                for obj in ancestor.lookup(node.name)[1]:
89                    if isinstance(obj, nodes.FunctionDef):
90                        return
91            args = (overridden.root().name, overridden.fromlineno)
92            self.add_message("method-hidden", args=args, node=node)
93        except astroid.NotFoundError:
94            pass
            

Path 3: 319 calls (0.09)

FunctionDef (319)

None (319)

1def visit_functiondef(self, node: nodes.FunctionDef) -> None:
2        """Check method arguments, overriding."""
3        # ignore actual functions
4        if not node.is_method():
5            return
6
7        self._check_useless_super_delegation(node)
8        self._check_property_with_parameters(node)
9
10        # 'is_method()' is called and makes sure that this is a 'nodes.ClassDef'
11        klass = node.parent.frame(future=True)  # type: nodes.ClassDef
12        # check first argument is self if this is actually a method
13        self._check_first_arg_for_type(node, klass.type == "metaclass")
14        if node.name == "__init__":
15            self._check_init(node, klass)
16            return
17        # check signature if the method overloads inherited method
18        for overridden in klass.local_attr_ancestors(node.name):
19            # get astroid for the searched method
20            try:
21                parent_function = overridden[node.name]
22            except KeyError:
23                # we have found the method but it's not in the local
24                # dictionary.
25                # This may happen with astroid build from living objects
26                continue
27            if not isinstance(parent_function, nodes.FunctionDef):
28                continue
29            self._check_signature(node, parent_function, klass)
30            self._check_invalid_overridden_method(node, parent_function)
31            break
32
33        if node.decorators:
34            for decorator in node.decorators.nodes:
35                if isinstance(decorator, nodes.Attribute) and decorator.attrname in {
36                    "getter",
37                    "setter",
38                    "deleter",
39                }:
40                    # attribute affectation will call this method, not hiding it
41                    return
42                if isinstance(decorator, nodes.Name):
43                    if decorator.name == "property":
44                        # attribute affectation will either call a setter or raise
45                        # an attribute error, anyway not hiding the function
46                        return
47
48                # Infer the decorator and see if it returns something useful
49                inferred = safe_infer(decorator)
50                if not inferred:
51                    return
52                if isinstance(inferred, nodes.FunctionDef):
53                    # Okay, it's a decorator, let's see what it can infer.
54                    try:
55                        inferred = next(inferred.infer_call_result(inferred))
56                    except astroid.InferenceError:
57                        return
58                try:
59                    if (
60                        isinstance(inferred, (astroid.Instance, nodes.ClassDef))
61                        and inferred.getattr("__get__")
62                        and inferred.getattr("__set__")
63                    ):
64                        return
65                except astroid.AttributeInferenceError:
66                    pass
67
68        # check if the method is hidden by an attribute
69        # pylint: disable = too-many-try-statements
70        try:
71            overridden = klass.instance_attr(node.name)[0]
72            overridden_frame = overridden.frame(future=True)
73            if (
74                isinstance(overridden_frame, nodes.FunctionDef)
75                and overridden_frame.type == "method"
76            ):
77                overridden_frame = overridden_frame.parent.frame(future=True)
78            if not (
79                isinstance(overridden_frame, nodes.ClassDef)
80                and klass.is_subtype_of(overridden_frame.qname())
81            ):
82                return
83
84            # If a subclass defined the method then it's not our fault.
85            for ancestor in klass.ancestors():
86                if node.name in ancestor.instance_attrs and is_attr_private(node.name):
87                    return
88                for obj in ancestor.lookup(node.name)[1]:
89                    if isinstance(obj, nodes.FunctionDef):
90                        return
91            args = (overridden.root().name, overridden.fromlineno)
92            self.add_message("method-hidden", args=args, node=node)
93        except astroid.NotFoundError:
94            pass
            

Path 4: 227 calls (0.06)

FunctionDef (224) AsyncFunctionDef (3)

AttributeInferenceError (227)

1def visit_functiondef(self, node: nodes.FunctionDef) -> None:
2        """Check method arguments, overriding."""
3        # ignore actual functions
4        if not node.is_method():
5            return
6
7        self._check_useless_super_delegation(node)
8        self._check_property_with_parameters(node)
9
10        # 'is_method()' is called and makes sure that this is a 'nodes.ClassDef'
11        klass = node.parent.frame(future=True)  # type: nodes.ClassDef
12        # check first argument is self if this is actually a method
13        self._check_first_arg_for_type(node, klass.type == "metaclass")
14        if node.name == "__init__":
15            self._check_init(node, klass)
16            return
17        # check signature if the method overloads inherited method
18        for overridden in klass.local_attr_ancestors(node.name):
19            # get astroid for the searched method
20            try:
21                parent_function = overridden[node.name]
22            except KeyError:
23                # we have found the method but it's not in the local
24                # dictionary.
25                # This may happen with astroid build from living objects
26                continue
27            if not isinstance(parent_function, nodes.FunctionDef):
28                continue
29            self._check_signature(node, parent_function, klass)
30            self._check_invalid_overridden_method(node, parent_function)
31            break
32
33        if node.decorators:
34            for decorator in node.decorators.nodes:
35                if isinstance(decorator, nodes.Attribute) and decorator.attrname in {
36                    "getter",
37                    "setter",
38                    "deleter",
39                }:
40                    # attribute affectation will call this method, not hiding it
41                    return
42                if isinstance(decorator, nodes.Name):
43                    if decorator.name == "property":
44                        # attribute affectation will either call a setter or raise
45                        # an attribute error, anyway not hiding the function
46                        return
47
48                # Infer the decorator and see if it returns something useful
49                inferred = safe_infer(decorator)
50                if not inferred:
51                    return
52                if isinstance(inferred, nodes.FunctionDef):
53                    # Okay, it's a decorator, let's see what it can infer.
54                    try:
55                        inferred = next(inferred.infer_call_result(inferred))
56                    except astroid.InferenceError:
57                        return
58                try:
59                    if (
60                        isinstance(inferred, (astroid.Instance, nodes.ClassDef))
61                        and inferred.getattr("__get__")
62                        and inferred.getattr("__set__")
63                    ):
64                        return
65                except astroid.AttributeInferenceError:
66                    pass
67
68        # check if the method is hidden by an attribute
69        # pylint: disable = too-many-try-statements
70        try:
71            overridden = klass.instance_attr(node.name)[0]
72            overridden_frame = overridden.frame(future=True)
73            if (
74                isinstance(overridden_frame, nodes.FunctionDef)
75                and overridden_frame.type == "method"
76            ):
77                overridden_frame = overridden_frame.parent.frame(future=True)
78            if not (
79                isinstance(overridden_frame, nodes.ClassDef)
80                and klass.is_subtype_of(overridden_frame.qname())
81            ):
82                return
83
84            # If a subclass defined the method then it's not our fault.
85            for ancestor in klass.ancestors():
86                if node.name in ancestor.instance_attrs and is_attr_private(node.name):
87                    return
88                for obj in ancestor.lookup(node.name)[1]:
89                    if isinstance(obj, nodes.FunctionDef):
90                        return
91            args = (overridden.root().name, overridden.fromlineno)
92            self.add_message("method-hidden", args=args, node=node)
93        except astroid.NotFoundError:
94            pass
            

Path 5: 97 calls (0.03)

FunctionDef (96) AsyncFunctionDef (1)

AttributeInferenceError (97)

1def visit_functiondef(self, node: nodes.FunctionDef) -> None:
2        """Check method arguments, overriding."""
3        # ignore actual functions
4        if not node.is_method():
5            return
6
7        self._check_useless_super_delegation(node)
8        self._check_property_with_parameters(node)
9
10        # 'is_method()' is called and makes sure that this is a 'nodes.ClassDef'
11        klass = node.parent.frame(future=True)  # type: nodes.ClassDef
12        # check first argument is self if this is actually a method
13        self._check_first_arg_for_type(node, klass.type == "metaclass")
14        if node.name == "__init__":
15            self._check_init(node, klass)
16            return
17        # check signature if the method overloads inherited method
18        for overridden in klass.local_attr_ancestors(node.name):
19            # get astroid for the searched method
20            try:
21                parent_function = overridden[node.name]
22            except KeyError:
23                # we have found the method but it's not in the local
24                # dictionary.
25                # This may happen with astroid build from living objects
26                continue
27            if not isinstance(parent_function, nodes.FunctionDef):
28                continue
29            self._check_signature(node, parent_function, klass)
30            self._check_invalid_overridden_method(node, parent_function)
31            break
32
33        if node.decorators:
34            for decorator in node.decorators.nodes:
35                if isinstance(decorator, nodes.Attribute) and decorator.attrname in {
36                    "getter",
37                    "setter",
38                    "deleter",
39                }:
40                    # attribute affectation will call this method, not hiding it
41                    return
42                if isinstance(decorator, nodes.Name):
43                    if decorator.name == "property":
44                        # attribute affectation will either call a setter or raise
45                        # an attribute error, anyway not hiding the function
46                        return
47
48                # Infer the decorator and see if it returns something useful
49                inferred = safe_infer(decorator)
50                if not inferred:
51                    return
52                if isinstance(inferred, nodes.FunctionDef):
53                    # Okay, it's a decorator, let's see what it can infer.
54                    try:
55                        inferred = next(inferred.infer_call_result(inferred))
56                    except astroid.InferenceError:
57                        return
58                try:
59                    if (
60                        isinstance(inferred, (astroid.Instance, nodes.ClassDef))
61                        and inferred.getattr("__get__")
62                        and inferred.getattr("__set__")
63                    ):
64                        return
65                except astroid.AttributeInferenceError:
66                    pass
67
68        # check if the method is hidden by an attribute
69        # pylint: disable = too-many-try-statements
70        try:
71            overridden = klass.instance_attr(node.name)[0]
72            overridden_frame = overridden.frame(future=True)
73            if (
74                isinstance(overridden_frame, nodes.FunctionDef)
75                and overridden_frame.type == "method"
76            ):
77                overridden_frame = overridden_frame.parent.frame(future=True)
78            if not (
79                isinstance(overridden_frame, nodes.ClassDef)
80                and klass.is_subtype_of(overridden_frame.qname())
81            ):
82                return
83
84            # If a subclass defined the method then it's not our fault.
85            for ancestor in klass.ancestors():
86                if node.name in ancestor.instance_attrs and is_attr_private(node.name):
87                    return
88                for obj in ancestor.lookup(node.name)[1]:
89                    if isinstance(obj, nodes.FunctionDef):
90                        return
91            args = (overridden.root().name, overridden.fromlineno)
92            self.add_message("method-hidden", args=args, node=node)
93        except astroid.NotFoundError:
94            pass
            

Path 6: 79 calls (0.02)

FunctionDef (79)

None (79)

1def visit_functiondef(self, node: nodes.FunctionDef) -> None:
2        """Check method arguments, overriding."""
3        # ignore actual functions
4        if not node.is_method():
5            return
6
7        self._check_useless_super_delegation(node)
8        self._check_property_with_parameters(node)
9
10        # 'is_method()' is called and makes sure that this is a 'nodes.ClassDef'
11        klass = node.parent.frame(future=True)  # type: nodes.ClassDef
12        # check first argument is self if this is actually a method
13        self._check_first_arg_for_type(node, klass.type == "metaclass")
14        if node.name == "__init__":
15            self._check_init(node, klass)
16            return
17        # check signature if the method overloads inherited method
18        for overridden in klass.local_attr_ancestors(node.name):
19            # get astroid for the searched method
20            try:
21                parent_function = overridden[node.name]
22            except KeyError:
23                # we have found the method but it's not in the local
24                # dictionary.
25                # This may happen with astroid build from living objects
26                continue
27            if not isinstance(parent_function, nodes.FunctionDef):
28                continue
29            self._check_signature(node, parent_function, klass)
30            self._check_invalid_overridden_method(node, parent_function)
31            break
32
33        if node.decorators:
34            for decorator in node.decorators.nodes:
35                if isinstance(decorator, nodes.Attribute) and decorator.attrname in {
36                    "getter",
37                    "setter",
38                    "deleter",
39                }:
40                    # attribute affectation will call this method, not hiding it
41                    return
42                if isinstance(decorator, nodes.Name):
43                    if decorator.name == "property":
44                        # attribute affectation will either call a setter or raise
45                        # an attribute error, anyway not hiding the function
46                        return
47
48                # Infer the decorator and see if it returns something useful
49                inferred = safe_infer(decorator)
50                if not inferred:
51                    return
52                if isinstance(inferred, nodes.FunctionDef):
53                    # Okay, it's a decorator, let's see what it can infer.
54                    try:
55                        inferred = next(inferred.infer_call_result(inferred))
56                    except astroid.InferenceError:
57                        return
58                try:
59                    if (
60                        isinstance(inferred, (astroid.Instance, nodes.ClassDef))
61                        and inferred.getattr("__get__")
62                        and inferred.getattr("__set__")
63                    ):
64                        return
65                except astroid.AttributeInferenceError:
66                    pass
67
68        # check if the method is hidden by an attribute
69        # pylint: disable = too-many-try-statements
70        try:
71            overridden = klass.instance_attr(node.name)[0]
72            overridden_frame = overridden.frame(future=True)
73            if (
74                isinstance(overridden_frame, nodes.FunctionDef)
75                and overridden_frame.type == "method"
76            ):
77                overridden_frame = overridden_frame.parent.frame(future=True)
78            if not (
79                isinstance(overridden_frame, nodes.ClassDef)
80                and klass.is_subtype_of(overridden_frame.qname())
81            ):
82                return
83
84            # If a subclass defined the method then it's not our fault.
85            for ancestor in klass.ancestors():
86                if node.name in ancestor.instance_attrs and is_attr_private(node.name):
87                    return
88                for obj in ancestor.lookup(node.name)[1]:
89                    if isinstance(obj, nodes.FunctionDef):
90                        return
91            args = (overridden.root().name, overridden.fromlineno)
92            self.add_message("method-hidden", args=args, node=node)
93        except astroid.NotFoundError:
94            pass
            

Path 7: 27 calls (0.01)

FunctionDef (26) AsyncFunctionDef (1)

AttributeInferenceError (27)

1def visit_functiondef(self, node: nodes.FunctionDef) -> None:
2        """Check method arguments, overriding."""
3        # ignore actual functions
4        if not node.is_method():
5            return
6
7        self._check_useless_super_delegation(node)
8        self._check_property_with_parameters(node)
9
10        # 'is_method()' is called and makes sure that this is a 'nodes.ClassDef'
11        klass = node.parent.frame(future=True)  # type: nodes.ClassDef
12        # check first argument is self if this is actually a method
13        self._check_first_arg_for_type(node, klass.type == "metaclass")
14        if node.name == "__init__":
15            self._check_init(node, klass)
16            return
17        # check signature if the method overloads inherited method
18        for overridden in klass.local_attr_ancestors(node.name):
19            # get astroid for the searched method
20            try:
21                parent_function = overridden[node.name]
22            except KeyError:
23                # we have found the method but it's not in the local
24                # dictionary.
25                # This may happen with astroid build from living objects
26                continue
27            if not isinstance(parent_function, nodes.FunctionDef):
28                continue
29            self._check_signature(node, parent_function, klass)
30            self._check_invalid_overridden_method(node, parent_function)
31            break
32
33        if node.decorators:
34            for decorator in node.decorators.nodes:
35                if isinstance(decorator, nodes.Attribute) and decorator.attrname in {
36                    "getter",
37                    "setter",
38                    "deleter",
39                }:
40                    # attribute affectation will call this method, not hiding it
41                    return
42                if isinstance(decorator, nodes.Name):
43                    if decorator.name == "property":
44                        # attribute affectation will either call a setter or raise
45                        # an attribute error, anyway not hiding the function
46                        return
47
48                # Infer the decorator and see if it returns something useful
49                inferred = safe_infer(decorator)
50                if not inferred:
51                    return
52                if isinstance(inferred, nodes.FunctionDef):
53                    # Okay, it's a decorator, let's see what it can infer.
54                    try:
55                        inferred = next(inferred.infer_call_result(inferred))
56                    except astroid.InferenceError:
57                        return
58                try:
59                    if (
60                        isinstance(inferred, (astroid.Instance, nodes.ClassDef))
61                        and inferred.getattr("__get__")
62                        and inferred.getattr("__set__")
63                    ):
64                        return
65                except astroid.AttributeInferenceError:
66                    pass
67
68        # check if the method is hidden by an attribute
69        # pylint: disable = too-many-try-statements
70        try:
71            overridden = klass.instance_attr(node.name)[0]
72            overridden_frame = overridden.frame(future=True)
73            if (
74                isinstance(overridden_frame, nodes.FunctionDef)
75                and overridden_frame.type == "method"
76            ):
77                overridden_frame = overridden_frame.parent.frame(future=True)
78            if not (
79                isinstance(overridden_frame, nodes.ClassDef)
80                and klass.is_subtype_of(overridden_frame.qname())
81            ):
82                return
83
84            # If a subclass defined the method then it's not our fault.
85            for ancestor in klass.ancestors():
86                if node.name in ancestor.instance_attrs and is_attr_private(node.name):
87                    return
88                for obj in ancestor.lookup(node.name)[1]:
89                    if isinstance(obj, nodes.FunctionDef):
90                        return
91            args = (overridden.root().name, overridden.fromlineno)
92            self.add_message("method-hidden", args=args, node=node)
93        except astroid.NotFoundError:
94            pass
            

Path 8: 26 calls (0.01)

FunctionDef (26)

None (26)

1def visit_functiondef(self, node: nodes.FunctionDef) -> None:
2        """Check method arguments, overriding."""
3        # ignore actual functions
4        if not node.is_method():
5            return
6
7        self._check_useless_super_delegation(node)
8        self._check_property_with_parameters(node)
9
10        # 'is_method()' is called and makes sure that this is a 'nodes.ClassDef'
11        klass = node.parent.frame(future=True)  # type: nodes.ClassDef
12        # check first argument is self if this is actually a method
13        self._check_first_arg_for_type(node, klass.type == "metaclass")
14        if node.name == "__init__":
15            self._check_init(node, klass)
16            return
17        # check signature if the method overloads inherited method
18        for overridden in klass.local_attr_ancestors(node.name):
19            # get astroid for the searched method
20            try:
21                parent_function = overridden[node.name]
22            except KeyError:
23                # we have found the method but it's not in the local
24                # dictionary.
25                # This may happen with astroid build from living objects
26                continue
27            if not isinstance(parent_function, nodes.FunctionDef):
28                continue
29            self._check_signature(node, parent_function, klass)
30            self._check_invalid_overridden_method(node, parent_function)
31            break
32
33        if node.decorators:
34            for decorator in node.decorators.nodes:
35                if isinstance(decorator, nodes.Attribute) and decorator.attrname in {
36                    "getter",
37                    "setter",
38                    "deleter",
39                }:
40                    # attribute affectation will call this method, not hiding it
41                    return
42                if isinstance(decorator, nodes.Name):
43                    if decorator.name == "property":
44                        # attribute affectation will either call a setter or raise
45                        # an attribute error, anyway not hiding the function
46                        return
47
48                # Infer the decorator and see if it returns something useful
49                inferred = safe_infer(decorator)
50                if not inferred:
51                    return
52                if isinstance(inferred, nodes.FunctionDef):
53                    # Okay, it's a decorator, let's see what it can infer.
54                    try:
55                        inferred = next(inferred.infer_call_result(inferred))
56                    except astroid.InferenceError:
57                        return
58                try:
59                    if (
60                        isinstance(inferred, (astroid.Instance, nodes.ClassDef))
61                        and inferred.getattr("__get__")
62                        and inferred.getattr("__set__")
63                    ):
64                        return
65                except astroid.AttributeInferenceError:
66                    pass
67
68        # check if the method is hidden by an attribute
69        # pylint: disable = too-many-try-statements
70        try:
71            overridden = klass.instance_attr(node.name)[0]
72            overridden_frame = overridden.frame(future=True)
73            if (
74                isinstance(overridden_frame, nodes.FunctionDef)
75                and overridden_frame.type == "method"
76            ):
77                overridden_frame = overridden_frame.parent.frame(future=True)
78            if not (
79                isinstance(overridden_frame, nodes.ClassDef)
80                and klass.is_subtype_of(overridden_frame.qname())
81            ):
82                return
83
84            # If a subclass defined the method then it's not our fault.
85            for ancestor in klass.ancestors():
86                if node.name in ancestor.instance_attrs and is_attr_private(node.name):
87                    return
88                for obj in ancestor.lookup(node.name)[1]:
89                    if isinstance(obj, nodes.FunctionDef):
90                        return
91            args = (overridden.root().name, overridden.fromlineno)
92            self.add_message("method-hidden", args=args, node=node)
93        except astroid.NotFoundError:
94            pass
            

Path 9: 23 calls (0.01)

FunctionDef (23)

AttributeInferenceError (23)

1def visit_functiondef(self, node: nodes.FunctionDef) -> None:
2        """Check method arguments, overriding."""
3        # ignore actual functions
4        if not node.is_method():
5            return
6
7        self._check_useless_super_delegation(node)
8        self._check_property_with_parameters(node)
9
10        # 'is_method()' is called and makes sure that this is a 'nodes.ClassDef'
11        klass = node.parent.frame(future=True)  # type: nodes.ClassDef
12        # check first argument is self if this is actually a method
13        self._check_first_arg_for_type(node, klass.type == "metaclass")
14        if node.name == "__init__":
15            self._check_init(node, klass)
16            return
17        # check signature if the method overloads inherited method
18        for overridden in klass.local_attr_ancestors(node.name):
19            # get astroid for the searched method
20            try:
21                parent_function = overridden[node.name]
22            except KeyError:
23                # we have found the method but it's not in the local
24                # dictionary.
25                # This may happen with astroid build from living objects
26                continue
27            if not isinstance(parent_function, nodes.FunctionDef):
28                continue
29            self._check_signature(node, parent_function, klass)
30            self._check_invalid_overridden_method(node, parent_function)
31            break
32
33        if node.decorators:
34            for decorator in node.decorators.nodes:
35                if isinstance(decorator, nodes.Attribute) and decorator.attrname in {
36                    "getter",
37                    "setter",
38                    "deleter",
39                }:
40                    # attribute affectation will call this method, not hiding it
41                    return
42                if isinstance(decorator, nodes.Name):
43                    if decorator.name == "property":
44                        # attribute affectation will either call a setter or raise
45                        # an attribute error, anyway not hiding the function
46                        return
47
48                # Infer the decorator and see if it returns something useful
49                inferred = safe_infer(decorator)
50                if not inferred:
51                    return
52                if isinstance(inferred, nodes.FunctionDef):
53                    # Okay, it's a decorator, let's see what it can infer.
54                    try:
55                        inferred = next(inferred.infer_call_result(inferred))
56                    except astroid.InferenceError:
57                        return
58                try:
59                    if (
60                        isinstance(inferred, (astroid.Instance, nodes.ClassDef))
61                        and inferred.getattr("__get__")
62                        and inferred.getattr("__set__")
63                    ):
64                        return
65                except astroid.AttributeInferenceError:
66                    pass
67
68        # check if the method is hidden by an attribute
69        # pylint: disable = too-many-try-statements
70        try:
71            overridden = klass.instance_attr(node.name)[0]
72            overridden_frame = overridden.frame(future=True)
73            if (
74                isinstance(overridden_frame, nodes.FunctionDef)
75                and overridden_frame.type == "method"
76            ):
77                overridden_frame = overridden_frame.parent.frame(future=True)
78            if not (
79                isinstance(overridden_frame, nodes.ClassDef)
80                and klass.is_subtype_of(overridden_frame.qname())
81            ):
82                return
83
84            # If a subclass defined the method then it's not our fault.
85            for ancestor in klass.ancestors():
86                if node.name in ancestor.instance_attrs and is_attr_private(node.name):
87                    return
88                for obj in ancestor.lookup(node.name)[1]:
89                    if isinstance(obj, nodes.FunctionDef):
90                        return
91            args = (overridden.root().name, overridden.fromlineno)
92            self.add_message("method-hidden", args=args, node=node)
93        except astroid.NotFoundError:
94            pass
            

Path 10: 22 calls (0.01)

FunctionDef (22)

None (22)

1def visit_functiondef(self, node: nodes.FunctionDef) -> None:
2        """Check method arguments, overriding."""
3        # ignore actual functions
4        if not node.is_method():
5            return
6
7        self._check_useless_super_delegation(node)
8        self._check_property_with_parameters(node)
9
10        # 'is_method()' is called and makes sure that this is a 'nodes.ClassDef'
11        klass = node.parent.frame(future=True)  # type: nodes.ClassDef
12        # check first argument is self if this is actually a method
13        self._check_first_arg_for_type(node, klass.type == "metaclass")
14        if node.name == "__init__":
15            self._check_init(node, klass)
16            return
17        # check signature if the method overloads inherited method
18        for overridden in klass.local_attr_ancestors(node.name):
19            # get astroid for the searched method
20            try:
21                parent_function = overridden[node.name]
22            except KeyError:
23                # we have found the method but it's not in the local
24                # dictionary.
25                # This may happen with astroid build from living objects
26                continue
27            if not isinstance(parent_function, nodes.FunctionDef):
28                continue
29            self._check_signature(node, parent_function, klass)
30            self._check_invalid_overridden_method(node, parent_function)
31            break
32
33        if node.decorators:
34            for decorator in node.decorators.nodes:
35                if isinstance(decorator, nodes.Attribute) and decorator.attrname in {
36                    "getter",
37                    "setter",
38                    "deleter",
39                }:
40                    # attribute affectation will call this method, not hiding it
41                    return
42                if isinstance(decorator, nodes.Name):
43                    if decorator.name == "property":
44                        # attribute affectation will either call a setter or raise
45                        # an attribute error, anyway not hiding the function
46                        return
47
48                # Infer the decorator and see if it returns something useful
49                inferred = safe_infer(decorator)
50                if not inferred:
51                    return
52                if isinstance(inferred, nodes.FunctionDef):
53                    # Okay, it's a decorator, let's see what it can infer.
54                    try:
55                        inferred = next(inferred.infer_call_result(inferred))
56                    except astroid.InferenceError:
57                        return
58                try:
59                    if (
60                        isinstance(inferred, (astroid.Instance, nodes.ClassDef))
61                        and inferred.getattr("__get__")
62                        and inferred.getattr("__set__")
63                    ):
64                        return
65                except astroid.AttributeInferenceError:
66                    pass
67
68        # check if the method is hidden by an attribute
69        # pylint: disable = too-many-try-statements
70        try:
71            overridden = klass.instance_attr(node.name)[0]
72            overridden_frame = overridden.frame(future=True)
73            if (
74                isinstance(overridden_frame, nodes.FunctionDef)
75                and overridden_frame.type == "method"
76            ):
77                overridden_frame = overridden_frame.parent.frame(future=True)
78            if not (
79                isinstance(overridden_frame, nodes.ClassDef)
80                and klass.is_subtype_of(overridden_frame.qname())
81            ):
82                return
83
84            # If a subclass defined the method then it's not our fault.
85            for ancestor in klass.ancestors():
86                if node.name in ancestor.instance_attrs and is_attr_private(node.name):
87                    return
88                for obj in ancestor.lookup(node.name)[1]:
89                    if isinstance(obj, nodes.FunctionDef):
90                        return
91            args = (overridden.root().name, overridden.fromlineno)
92            self.add_message("method-hidden", args=args, node=node)
93        except astroid.NotFoundError:
94            pass
            

Path 11: 14 calls (0.0)

FunctionDef (14)

AttributeInferenceError (14)

1def visit_functiondef(self, node: nodes.FunctionDef) -> None:
2        """Check method arguments, overriding."""
3        # ignore actual functions
4        if not node.is_method():
5            return
6
7        self._check_useless_super_delegation(node)
8        self._check_property_with_parameters(node)
9
10        # 'is_method()' is called and makes sure that this is a 'nodes.ClassDef'
11        klass = node.parent.frame(future=True)  # type: nodes.ClassDef
12        # check first argument is self if this is actually a method
13        self._check_first_arg_for_type(node, klass.type == "metaclass")
14        if node.name == "__init__":
15            self._check_init(node, klass)
16            return
17        # check signature if the method overloads inherited method
18        for overridden in klass.local_attr_ancestors(node.name):
19            # get astroid for the searched method
20            try:
21                parent_function = overridden[node.name]
22            except KeyError:
23                # we have found the method but it's not in the local
24                # dictionary.
25                # This may happen with astroid build from living objects
26                continue
27            if not isinstance(parent_function, nodes.FunctionDef):
28                continue
29            self._check_signature(node, parent_function, klass)
30            self._check_invalid_overridden_method(node, parent_function)
31            break
32
33        if node.decorators:
34            for decorator in node.decorators.nodes:
35                if isinstance(decorator, nodes.Attribute) and decorator.attrname in {
36                    "getter",
37                    "setter",
38                    "deleter",
39                }:
40                    # attribute affectation will call this method, not hiding it
41                    return
42                if isinstance(decorator, nodes.Name):
43                    if decorator.name == "property":
44                        # attribute affectation will either call a setter or raise
45                        # an attribute error, anyway not hiding the function
46                        return
47
48                # Infer the decorator and see if it returns something useful
49                inferred = safe_infer(decorator)
50                if not inferred:
51                    return
52                if isinstance(inferred, nodes.FunctionDef):
53                    # Okay, it's a decorator, let's see what it can infer.
54                    try:
55                        inferred = next(inferred.infer_call_result(inferred))
56                    except astroid.InferenceError:
57                        return
58                try:
59                    if (
60                        isinstance(inferred, (astroid.Instance, nodes.ClassDef))
61                        and inferred.getattr("__get__")
62                        and inferred.getattr("__set__")
63                    ):
64                        return
65                except astroid.AttributeInferenceError:
66                    pass
67
68        # check if the method is hidden by an attribute
69        # pylint: disable = too-many-try-statements
70        try:
71            overridden = klass.instance_attr(node.name)[0]
72            overridden_frame = overridden.frame(future=True)
73            if (
74                isinstance(overridden_frame, nodes.FunctionDef)
75                and overridden_frame.type == "method"
76            ):
77                overridden_frame = overridden_frame.parent.frame(future=True)
78            if not (
79                isinstance(overridden_frame, nodes.ClassDef)
80                and klass.is_subtype_of(overridden_frame.qname())
81            ):
82                return
83
84            # If a subclass defined the method then it's not our fault.
85            for ancestor in klass.ancestors():
86                if node.name in ancestor.instance_attrs and is_attr_private(node.name):
87                    return
88                for obj in ancestor.lookup(node.name)[1]:
89                    if isinstance(obj, nodes.FunctionDef):
90                        return
91            args = (overridden.root().name, overridden.fromlineno)
92            self.add_message("method-hidden", args=args, node=node)
93        except astroid.NotFoundError:
94            pass
            

Path 12: 7 calls (0.0)

FunctionDef (7)

AttributeInferenceError (7)

1def visit_functiondef(self, node: nodes.FunctionDef) -> None:
2        """Check method arguments, overriding."""
3        # ignore actual functions
4        if not node.is_method():
5            return
6
7        self._check_useless_super_delegation(node)
8        self._check_property_with_parameters(node)
9
10        # 'is_method()' is called and makes sure that this is a 'nodes.ClassDef'
11        klass = node.parent.frame(future=True)  # type: nodes.ClassDef
12        # check first argument is self if this is actually a method
13        self._check_first_arg_for_type(node, klass.type == "metaclass")
14        if node.name == "__init__":
15            self._check_init(node, klass)
16            return
17        # check signature if the method overloads inherited method
18        for overridden in klass.local_attr_ancestors(node.name):
19            # get astroid for the searched method
20            try:
21                parent_function = overridden[node.name]
22            except KeyError:
23                # we have found the method but it's not in the local
24                # dictionary.
25                # This may happen with astroid build from living objects
26                continue
27            if not isinstance(parent_function, nodes.FunctionDef):
28                continue
29            self._check_signature(node, parent_function, klass)
30            self._check_invalid_overridden_method(node, parent_function)
31            break
32
33        if node.decorators:
34            for decorator in node.decorators.nodes:
35                if isinstance(decorator, nodes.Attribute) and decorator.attrname in {
36                    "getter",
37                    "setter",
38                    "deleter",
39                }:
40                    # attribute affectation will call this method, not hiding it
41                    return
42                if isinstance(decorator, nodes.Name):
43                    if decorator.name == "property":
44                        # attribute affectation will either call a setter or raise
45                        # an attribute error, anyway not hiding the function
46                        return
47
48                # Infer the decorator and see if it returns something useful
49                inferred = safe_infer(decorator)
50                if not inferred:
51                    return
52                if isinstance(inferred, nodes.FunctionDef):
53                    # Okay, it's a decorator, let's see what it can infer.
54                    try:
55                        inferred = next(inferred.infer_call_result(inferred))
56                    except astroid.InferenceError:
57                        return
58                try:
59                    if (
60                        isinstance(inferred, (astroid.Instance, nodes.ClassDef))
61                        and inferred.getattr("__get__")
62                        and inferred.getattr("__set__")
63                    ):
64                        return
65                except astroid.AttributeInferenceError:
66                    pass
67
68        # check if the method is hidden by an attribute
69        # pylint: disable = too-many-try-statements
70        try:
71            overridden = klass.instance_attr(node.name)[0]
72            overridden_frame = overridden.frame(future=True)
73            if (
74                isinstance(overridden_frame, nodes.FunctionDef)
75                and overridden_frame.type == "method"
76            ):
77                overridden_frame = overridden_frame.parent.frame(future=True)
78            if not (
79                isinstance(overridden_frame, nodes.ClassDef)
80                and klass.is_subtype_of(overridden_frame.qname())
81            ):
82                return
83
84            # If a subclass defined the method then it's not our fault.
85            for ancestor in klass.ancestors():
86                if node.name in ancestor.instance_attrs and is_attr_private(node.name):
87                    return
88                for obj in ancestor.lookup(node.name)[1]:
89                    if isinstance(obj, nodes.FunctionDef):
90                        return
91            args = (overridden.root().name, overridden.fromlineno)
92            self.add_message("method-hidden", args=args, node=node)
93        except astroid.NotFoundError:
94            pass
            

Path 13: 5 calls (0.0)

FunctionDef (5)

None (5)

1def visit_functiondef(self, node: nodes.FunctionDef) -> None:
2        """Check method arguments, overriding."""
3        # ignore actual functions
4        if not node.is_method():
5            return
6
7        self._check_useless_super_delegation(node)
8        self._check_property_with_parameters(node)
9
10        # 'is_method()' is called and makes sure that this is a 'nodes.ClassDef'
11        klass = node.parent.frame(future=True)  # type: nodes.ClassDef
12        # check first argument is self if this is actually a method
13        self._check_first_arg_for_type(node, klass.type == "metaclass")
14        if node.name == "__init__":
15            self._check_init(node, klass)
16            return
17        # check signature if the method overloads inherited method
18        for overridden in klass.local_attr_ancestors(node.name):
19            # get astroid for the searched method
20            try:
21                parent_function = overridden[node.name]
22            except KeyError:
23                # we have found the method but it's not in the local
24                # dictionary.
25                # This may happen with astroid build from living objects
26                continue
27            if not isinstance(parent_function, nodes.FunctionDef):
28                continue
29            self._check_signature(node, parent_function, klass)
30            self._check_invalid_overridden_method(node, parent_function)
31            break
32
33        if node.decorators:
34            for decorator in node.decorators.nodes:
35                if isinstance(decorator, nodes.Attribute) and decorator.attrname in {
36                    "getter",
37                    "setter",
38                    "deleter",
39                }:
40                    # attribute affectation will call this method, not hiding it
41                    return
42                if isinstance(decorator, nodes.Name):
43                    if decorator.name == "property":
44                        # attribute affectation will either call a setter or raise
45                        # an attribute error, anyway not hiding the function
46                        return
47
48                # Infer the decorator and see if it returns something useful
49                inferred = safe_infer(decorator)
50                if not inferred:
51                    return
52                if isinstance(inferred, nodes.FunctionDef):
53                    # Okay, it's a decorator, let's see what it can infer.
54                    try:
55                        inferred = next(inferred.infer_call_result(inferred))
56                    except astroid.InferenceError:
57                        return
58                try:
59                    if (
60                        isinstance(inferred, (astroid.Instance, nodes.ClassDef))
61                        and inferred.getattr("__get__")
62                        and inferred.getattr("__set__")
63                    ):
64                        return
65                except astroid.AttributeInferenceError:
66                    pass
67
68        # check if the method is hidden by an attribute
69        # pylint: disable = too-many-try-statements
70        try:
71            overridden = klass.instance_attr(node.name)[0]
72            overridden_frame = overridden.frame(future=True)
73            if (
74                isinstance(overridden_frame, nodes.FunctionDef)
75                and overridden_frame.type == "method"
76            ):
77                overridden_frame = overridden_frame.parent.frame(future=True)
78            if not (
79                isinstance(overridden_frame, nodes.ClassDef)
80                and klass.is_subtype_of(overridden_frame.qname())
81            ):
82                return
83
84            # If a subclass defined the method then it's not our fault.
85            for ancestor in klass.ancestors():
86                if node.name in ancestor.instance_attrs and is_attr_private(node.name):
87                    return
88                for obj in ancestor.lookup(node.name)[1]:
89                    if isinstance(obj, nodes.FunctionDef):
90                        return
91            args = (overridden.root().name, overridden.fromlineno)
92            self.add_message("method-hidden", args=args, node=node)
93        except astroid.NotFoundError:
94            pass
            

Path 14: 5 calls (0.0)

FunctionDef (5)

AttributeInferenceError (5)

1def visit_functiondef(self, node: nodes.FunctionDef) -> None:
2        """Check method arguments, overriding."""
3        # ignore actual functions
4        if not node.is_method():
5            return
6
7        self._check_useless_super_delegation(node)
8        self._check_property_with_parameters(node)
9
10        # 'is_method()' is called and makes sure that this is a 'nodes.ClassDef'
11        klass = node.parent.frame(future=True)  # type: nodes.ClassDef
12        # check first argument is self if this is actually a method
13        self._check_first_arg_for_type(node, klass.type == "metaclass")
14        if node.name == "__init__":
15            self._check_init(node, klass)
16            return
17        # check signature if the method overloads inherited method
18        for overridden in klass.local_attr_ancestors(node.name):
19            # get astroid for the searched method
20            try:
21                parent_function = overridden[node.name]
22            except KeyError:
23                # we have found the method but it's not in the local
24                # dictionary.
25                # This may happen with astroid build from living objects
26                continue
27            if not isinstance(parent_function, nodes.FunctionDef):
28                continue
29            self._check_signature(node, parent_function, klass)
30            self._check_invalid_overridden_method(node, parent_function)
31            break
32
33        if node.decorators:
34            for decorator in node.decorators.nodes:
35                if isinstance(decorator, nodes.Attribute) and decorator.attrname in {
36                    "getter",
37                    "setter",
38                    "deleter",
39                }:
40                    # attribute affectation will call this method, not hiding it
41                    return
42                if isinstance(decorator, nodes.Name):
43                    if decorator.name == "property":
44                        # attribute affectation will either call a setter or raise
45                        # an attribute error, anyway not hiding the function
46                        return
47
48                # Infer the decorator and see if it returns something useful
49                inferred = safe_infer(decorator)
50                if not inferred:
51                    return
52                if isinstance(inferred, nodes.FunctionDef):
53                    # Okay, it's a decorator, let's see what it can infer.
54                    try:
55                        inferred = next(inferred.infer_call_result(inferred))
56                    except astroid.InferenceError:
57                        return
58                try:
59                    if (
60                        isinstance(inferred, (astroid.Instance, nodes.ClassDef))
61                        and inferred.getattr("__get__")
62                        and inferred.getattr("__set__")
63                    ):
64                        return
65                except astroid.AttributeInferenceError:
66                    pass
67
68        # check if the method is hidden by an attribute
69        # pylint: disable = too-many-try-statements
70        try:
71            overridden = klass.instance_attr(node.name)[0]
72            overridden_frame = overridden.frame(future=True)
73            if (
74                isinstance(overridden_frame, nodes.FunctionDef)
75                and overridden_frame.type == "method"
76            ):
77                overridden_frame = overridden_frame.parent.frame(future=True)
78            if not (
79                isinstance(overridden_frame, nodes.ClassDef)
80                and klass.is_subtype_of(overridden_frame.qname())
81            ):
82                return
83
84            # If a subclass defined the method then it's not our fault.
85            for ancestor in klass.ancestors():
86                if node.name in ancestor.instance_attrs and is_attr_private(node.name):
87                    return
88                for obj in ancestor.lookup(node.name)[1]:
89                    if isinstance(obj, nodes.FunctionDef):
90                        return
91            args = (overridden.root().name, overridden.fromlineno)
92            self.add_message("method-hidden", args=args, node=node)
93        except astroid.NotFoundError:
94            pass
            

Path 15: 4 calls (0.0)

FunctionDef (4)

None (4)

1def visit_functiondef(self, node: nodes.FunctionDef) -> None:
2        """Check method arguments, overriding."""
3        # ignore actual functions
4        if not node.is_method():
5            return
6
7        self._check_useless_super_delegation(node)
8        self._check_property_with_parameters(node)
9
10        # 'is_method()' is called and makes sure that this is a 'nodes.ClassDef'
11        klass = node.parent.frame(future=True)  # type: nodes.ClassDef
12        # check first argument is self if this is actually a method
13        self._check_first_arg_for_type(node, klass.type == "metaclass")
14        if node.name == "__init__":
15            self._check_init(node, klass)
16            return
17        # check signature if the method overloads inherited method
18        for overridden in klass.local_attr_ancestors(node.name):
19            # get astroid for the searched method
20            try:
21                parent_function = overridden[node.name]
22            except KeyError:
23                # we have found the method but it's not in the local
24                # dictionary.
25                # This may happen with astroid build from living objects
26                continue
27            if not isinstance(parent_function, nodes.FunctionDef):
28                continue
29            self._check_signature(node, parent_function, klass)
30            self._check_invalid_overridden_method(node, parent_function)
31            break
32
33        if node.decorators:
34            for decorator in node.decorators.nodes:
35                if isinstance(decorator, nodes.Attribute) and decorator.attrname in {
36                    "getter",
37                    "setter",
38                    "deleter",
39                }:
40                    # attribute affectation will call this method, not hiding it
41                    return
42                if isinstance(decorator, nodes.Name):
43                    if decorator.name == "property":
44                        # attribute affectation will either call a setter or raise
45                        # an attribute error, anyway not hiding the function
46                        return
47
48                # Infer the decorator and see if it returns something useful
49                inferred = safe_infer(decorator)
50                if not inferred:
51                    return
52                if isinstance(inferred, nodes.FunctionDef):
53                    # Okay, it's a decorator, let's see what it can infer.
54                    try:
55                        inferred = next(inferred.infer_call_result(inferred))
56                    except astroid.InferenceError:
57                        return
58                try:
59                    if (
60                        isinstance(inferred, (astroid.Instance, nodes.ClassDef))
61                        and inferred.getattr("__get__")
62                        and inferred.getattr("__set__")
63                    ):
64                        return
65                except astroid.AttributeInferenceError:
66                    pass
67
68        # check if the method is hidden by an attribute
69        # pylint: disable = too-many-try-statements
70        try:
71            overridden = klass.instance_attr(node.name)[0]
72            overridden_frame = overridden.frame(future=True)
73            if (
74                isinstance(overridden_frame, nodes.FunctionDef)
75                and overridden_frame.type == "method"
76            ):
77                overridden_frame = overridden_frame.parent.frame(future=True)
78            if not (
79                isinstance(overridden_frame, nodes.ClassDef)
80                and klass.is_subtype_of(overridden_frame.qname())
81            ):
82                return
83
84            # If a subclass defined the method then it's not our fault.
85            for ancestor in klass.ancestors():
86                if node.name in ancestor.instance_attrs and is_attr_private(node.name):
87                    return
88                for obj in ancestor.lookup(node.name)[1]:
89                    if isinstance(obj, nodes.FunctionDef):
90                        return
91            args = (overridden.root().name, overridden.fromlineno)
92            self.add_message("method-hidden", args=args, node=node)
93        except astroid.NotFoundError:
94            pass
            

Path 16: 4 calls (0.0)

FunctionDef (4)

AttributeInferenceError (4)

1def visit_functiondef(self, node: nodes.FunctionDef) -> None:
2        """Check method arguments, overriding."""
3        # ignore actual functions
4        if not node.is_method():
5            return
6
7        self._check_useless_super_delegation(node)
8        self._check_property_with_parameters(node)
9
10        # 'is_method()' is called and makes sure that this is a 'nodes.ClassDef'
11        klass = node.parent.frame(future=True)  # type: nodes.ClassDef
12        # check first argument is self if this is actually a method
13        self._check_first_arg_for_type(node, klass.type == "metaclass")
14        if node.name == "__init__":
15            self._check_init(node, klass)
16            return
17        # check signature if the method overloads inherited method
18        for overridden in klass.local_attr_ancestors(node.name):
19            # get astroid for the searched method
20            try:
21                parent_function = overridden[node.name]
22            except KeyError:
23                # we have found the method but it's not in the local
24                # dictionary.
25                # This may happen with astroid build from living objects
26                continue
27            if not isinstance(parent_function, nodes.FunctionDef):
28                continue
29            self._check_signature(node, parent_function, klass)
30            self._check_invalid_overridden_method(node, parent_function)
31            break
32
33        if node.decorators:
34            for decorator in node.decorators.nodes:
35                if isinstance(decorator, nodes.Attribute) and decorator.attrname in {
36                    "getter",
37                    "setter",
38                    "deleter",
39                }:
40                    # attribute affectation will call this method, not hiding it
41                    return
42                if isinstance(decorator, nodes.Name):
43                    if decorator.name == "property":
44                        # attribute affectation will either call a setter or raise
45                        # an attribute error, anyway not hiding the function
46                        return
47
48                # Infer the decorator and see if it returns something useful
49                inferred = safe_infer(decorator)
50                if not inferred:
51                    return
52                if isinstance(inferred, nodes.FunctionDef):
53                    # Okay, it's a decorator, let's see what it can infer.
54                    try:
55                        inferred = next(inferred.infer_call_result(inferred))
56                    except astroid.InferenceError:
57                        return
58                try:
59                    if (
60                        isinstance(inferred, (astroid.Instance, nodes.ClassDef))
61                        and inferred.getattr("__get__")
62                        and inferred.getattr("__set__")
63                    ):
64                        return
65                except astroid.AttributeInferenceError:
66                    pass
67
68        # check if the method is hidden by an attribute
69        # pylint: disable = too-many-try-statements
70        try:
71            overridden = klass.instance_attr(node.name)[0]
72            overridden_frame = overridden.frame(future=True)
73            if (
74                isinstance(overridden_frame, nodes.FunctionDef)
75                and overridden_frame.type == "method"
76            ):
77                overridden_frame = overridden_frame.parent.frame(future=True)
78            if not (
79                isinstance(overridden_frame, nodes.ClassDef)
80                and klass.is_subtype_of(overridden_frame.qname())
81            ):
82                return
83
84            # If a subclass defined the method then it's not our fault.
85            for ancestor in klass.ancestors():
86                if node.name in ancestor.instance_attrs and is_attr_private(node.name):
87                    return
88                for obj in ancestor.lookup(node.name)[1]:
89                    if isinstance(obj, nodes.FunctionDef):
90                        return
91            args = (overridden.root().name, overridden.fromlineno)
92            self.add_message("method-hidden", args=args, node=node)
93        except astroid.NotFoundError:
94            pass
            

Path 17: 3 calls (0.0)

FunctionDef (3)

1def visit_functiondef(self, node: nodes.FunctionDef) -> None:
2        """Check method arguments, overriding."""
3        # ignore actual functions
4        if not node.is_method():
5            return
6
7        self._check_useless_super_delegation(node)
8        self._check_property_with_parameters(node)
9
10        # 'is_method()' is called and makes sure that this is a 'nodes.ClassDef'
11        klass = node.parent.frame(future=True)  # type: nodes.ClassDef
12        # check first argument is self if this is actually a method
13        self._check_first_arg_for_type(node, klass.type == "metaclass")
14        if node.name == "__init__":
15            self._check_init(node, klass)
16            return
17        # check signature if the method overloads inherited method
18        for overridden in klass.local_attr_ancestors(node.name):
19            # get astroid for the searched method
20            try:
21                parent_function = overridden[node.name]
22            except KeyError:
23                # we have found the method but it's not in the local
24                # dictionary.
25                # This may happen with astroid build from living objects
26                continue
27            if not isinstance(parent_function, nodes.FunctionDef):
28                continue
29            self._check_signature(node, parent_function, klass)
30            self._check_invalid_overridden_method(node, parent_function)
31            break
32
33        if node.decorators:
34            for decorator in node.decorators.nodes:
35                if isinstance(decorator, nodes.Attribute) and decorator.attrname in {
36                    "getter",
37                    "setter",
38                    "deleter",
39                }:
40                    # attribute affectation will call this method, not hiding it
41                    return
42                if isinstance(decorator, nodes.Name):
43                    if decorator.name == "property":
44                        # attribute affectation will either call a setter or raise
45                        # an attribute error, anyway not hiding the function
46                        return
47
48                # Infer the decorator and see if it returns something useful
49                inferred = safe_infer(decorator)
50                if not inferred:
51                    return
52                if isinstance(inferred, nodes.FunctionDef):
53                    # Okay, it's a decorator, let's see what it can infer.
54                    try:
55                        inferred = next(inferred.infer_call_result(inferred))
56                    except astroid.InferenceError:
57                        return
58                try:
59                    if (
60                        isinstance(inferred, (astroid.Instance, nodes.ClassDef))
61                        and inferred.getattr("__get__")
62                        and inferred.getattr("__set__")
63                    ):
64                        return
65                except astroid.AttributeInferenceError:
66                    pass
67
68        # check if the method is hidden by an attribute
69        # pylint: disable = too-many-try-statements
70        try:
71            overridden = klass.instance_attr(node.name)[0]
72            overridden_frame = overridden.frame(future=True)
73            if (
74                isinstance(overridden_frame, nodes.FunctionDef)
75                and overridden_frame.type == "method"
76            ):
77                overridden_frame = overridden_frame.parent.frame(future=True)
78            if not (
79                isinstance(overridden_frame, nodes.ClassDef)
80                and klass.is_subtype_of(overridden_frame.qname())
81            ):
82                return
83
84            # If a subclass defined the method then it's not our fault.
85            for ancestor in klass.ancestors():
86                if node.name in ancestor.instance_attrs and is_attr_private(node.name):
87                    return
88                for obj in ancestor.lookup(node.name)[1]:
89                    if isinstance(obj, nodes.FunctionDef):
90                        return
91            args = (overridden.root().name, overridden.fromlineno)
92            self.add_message("method-hidden", args=args, node=node)
93        except astroid.NotFoundError:
94            pass
            

Path 18: 2 calls (0.0)

FunctionDef (2)

AttributeInferenceError (2)

1def visit_functiondef(self, node: nodes.FunctionDef) -> None:
2        """Check method arguments, overriding."""
3        # ignore actual functions
4        if not node.is_method():
5            return
6
7        self._check_useless_super_delegation(node)
8        self._check_property_with_parameters(node)
9
10        # 'is_method()' is called and makes sure that this is a 'nodes.ClassDef'
11        klass = node.parent.frame(future=True)  # type: nodes.ClassDef
12        # check first argument is self if this is actually a method
13        self._check_first_arg_for_type(node, klass.type == "metaclass")
14        if node.name == "__init__":
15            self._check_init(node, klass)
16            return
17        # check signature if the method overloads inherited method
18        for overridden in klass.local_attr_ancestors(node.name):
19            # get astroid for the searched method
20            try:
21                parent_function = overridden[node.name]
22            except KeyError:
23                # we have found the method but it's not in the local
24                # dictionary.
25                # This may happen with astroid build from living objects
26                continue
27            if not isinstance(parent_function, nodes.FunctionDef):
28                continue
29            self._check_signature(node, parent_function, klass)
30            self._check_invalid_overridden_method(node, parent_function)
31            break
32
33        if node.decorators:
34            for decorator in node.decorators.nodes:
35                if isinstance(decorator, nodes.Attribute) and decorator.attrname in {
36                    "getter",
37                    "setter",
38                    "deleter",
39                }:
40                    # attribute affectation will call this method, not hiding it
41                    return
42                if isinstance(decorator, nodes.Name):
43                    if decorator.name == "property":
44                        # attribute affectation will either call a setter or raise
45                        # an attribute error, anyway not hiding the function
46                        return
47
48                # Infer the decorator and see if it returns something useful
49                inferred = safe_infer(decorator)
50                if not inferred:
51                    return
52                if isinstance(inferred, nodes.FunctionDef):
53                    # Okay, it's a decorator, let's see what it can infer.
54                    try:
55                        inferred = next(inferred.infer_call_result(inferred))
56                    except astroid.InferenceError:
57                        return
58                try:
59                    if (
60                        isinstance(inferred, (astroid.Instance, nodes.ClassDef))
61                        and inferred.getattr("__get__")
62                        and inferred.getattr("__set__")
63                    ):
64                        return
65                except astroid.AttributeInferenceError:
66                    pass
67
68        # check if the method is hidden by an attribute
69        # pylint: disable = too-many-try-statements
70        try:
71            overridden = klass.instance_attr(node.name)[0]
72            overridden_frame = overridden.frame(future=True)
73            if (
74                isinstance(overridden_frame, nodes.FunctionDef)
75                and overridden_frame.type == "method"
76            ):
77                overridden_frame = overridden_frame.parent.frame(future=True)
78            if not (
79                isinstance(overridden_frame, nodes.ClassDef)
80                and klass.is_subtype_of(overridden_frame.qname())
81            ):
82                return
83
84            # If a subclass defined the method then it's not our fault.
85            for ancestor in klass.ancestors():
86                if node.name in ancestor.instance_attrs and is_attr_private(node.name):
87                    return
88                for obj in ancestor.lookup(node.name)[1]:
89                    if isinstance(obj, nodes.FunctionDef):
90                        return
91            args = (overridden.root().name, overridden.fromlineno)
92            self.add_message("method-hidden", args=args, node=node)
93        except astroid.NotFoundError:
94            pass
            

Path 19: 2 calls (0.0)

FunctionDef (2)

AttributeInferenceError (2)

1def visit_functiondef(self, node: nodes.FunctionDef) -> None:
2        """Check method arguments, overriding."""
3        # ignore actual functions
4        if not node.is_method():
5            return
6
7        self._check_useless_super_delegation(node)
8        self._check_property_with_parameters(node)
9
10        # 'is_method()' is called and makes sure that this is a 'nodes.ClassDef'
11        klass = node.parent.frame(future=True)  # type: nodes.ClassDef
12        # check first argument is self if this is actually a method
13        self._check_first_arg_for_type(node, klass.type == "metaclass")
14        if node.name == "__init__":
15            self._check_init(node, klass)
16            return
17        # check signature if the method overloads inherited method
18        for overridden in klass.local_attr_ancestors(node.name):
19            # get astroid for the searched method
20            try:
21                parent_function = overridden[node.name]
22            except KeyError:
23                # we have found the method but it's not in the local
24                # dictionary.
25                # This may happen with astroid build from living objects
26                continue
27            if not isinstance(parent_function, nodes.FunctionDef):
28                continue
29            self._check_signature(node, parent_function, klass)
30            self._check_invalid_overridden_method(node, parent_function)
31            break
32
33        if node.decorators:
34            for decorator in node.decorators.nodes:
35                if isinstance(decorator, nodes.Attribute) and decorator.attrname in {
36                    "getter",
37                    "setter",
38                    "deleter",
39                }:
40                    # attribute affectation will call this method, not hiding it
41                    return
42                if isinstance(decorator, nodes.Name):
43                    if decorator.name == "property":
44                        # attribute affectation will either call a setter or raise
45                        # an attribute error, anyway not hiding the function
46                        return
47
48                # Infer the decorator and see if it returns something useful
49                inferred = safe_infer(decorator)
50                if not inferred:
51                    return
52                if isinstance(inferred, nodes.FunctionDef):
53                    # Okay, it's a decorator, let's see what it can infer.
54                    try:
55                        inferred = next(inferred.infer_call_result(inferred))
56                    except astroid.InferenceError:
57                        return
58                try:
59                    if (
60                        isinstance(inferred, (astroid.Instance, nodes.ClassDef))
61                        and inferred.getattr("__get__")
62                        and inferred.getattr("__set__")
63                    ):
64                        return
65                except astroid.AttributeInferenceError:
66                    pass
67
68        # check if the method is hidden by an attribute
69        # pylint: disable = too-many-try-statements
70        try:
71            overridden = klass.instance_attr(node.name)[0]
72            overridden_frame = overridden.frame(future=True)
73            if (
74                isinstance(overridden_frame, nodes.FunctionDef)
75                and overridden_frame.type == "method"
76            ):
77                overridden_frame = overridden_frame.parent.frame(future=True)
78            if not (
79                isinstance(overridden_frame, nodes.ClassDef)
80                and klass.is_subtype_of(overridden_frame.qname())
81            ):
82                return
83
84            # If a subclass defined the method then it's not our fault.
85            for ancestor in klass.ancestors():
86                if node.name in ancestor.instance_attrs and is_attr_private(node.name):
87                    return
88                for obj in ancestor.lookup(node.name)[1]:
89                    if isinstance(obj, nodes.FunctionDef):
90                        return
91            args = (overridden.root().name, overridden.fromlineno)
92            self.add_message("method-hidden", args=args, node=node)
93        except astroid.NotFoundError:
94            pass
            

Path 20: 2 calls (0.0)

FunctionDef (2)

None (2)

1def visit_functiondef(self, node: nodes.FunctionDef) -> None:
2        """Check method arguments, overriding."""
3        # ignore actual functions
4        if not node.is_method():
5            return
6
7        self._check_useless_super_delegation(node)
8        self._check_property_with_parameters(node)
9
10        # 'is_method()' is called and makes sure that this is a 'nodes.ClassDef'
11        klass = node.parent.frame(future=True)  # type: nodes.ClassDef
12        # check first argument is self if this is actually a method
13        self._check_first_arg_for_type(node, klass.type == "metaclass")
14        if node.name == "__init__":
15            self._check_init(node, klass)
16            return
17        # check signature if the method overloads inherited method
18        for overridden in klass.local_attr_ancestors(node.name):
19            # get astroid for the searched method
20            try:
21                parent_function = overridden[node.name]
22            except KeyError:
23                # we have found the method but it's not in the local
24                # dictionary.
25                # This may happen with astroid build from living objects
26                continue
27            if not isinstance(parent_function, nodes.FunctionDef):
28                continue
29            self._check_signature(node, parent_function, klass)
30            self._check_invalid_overridden_method(node, parent_function)
31            break
32
33        if node.decorators:
34            for decorator in node.decorators.nodes:
35                if isinstance(decorator, nodes.Attribute) and decorator.attrname in {
36                    "getter",
37                    "setter",
38                    "deleter",
39                }:
40                    # attribute affectation will call this method, not hiding it
41                    return
42                if isinstance(decorator, nodes.Name):
43                    if decorator.name == "property":
44                        # attribute affectation will either call a setter or raise
45                        # an attribute error, anyway not hiding the function
46                        return
47
48                # Infer the decorator and see if it returns something useful
49                inferred = safe_infer(decorator)
50                if not inferred:
51                    return
52                if isinstance(inferred, nodes.FunctionDef):
53                    # Okay, it's a decorator, let's see what it can infer.
54                    try:
55                        inferred = next(inferred.infer_call_result(inferred))
56                    except astroid.InferenceError:
57                        return
58                try:
59                    if (
60                        isinstance(inferred, (astroid.Instance, nodes.ClassDef))
61                        and inferred.getattr("__get__")
62                        and inferred.getattr("__set__")
63                    ):
64                        return
65                except astroid.AttributeInferenceError:
66                    pass
67
68        # check if the method is hidden by an attribute
69        # pylint: disable = too-many-try-statements
70        try:
71            overridden = klass.instance_attr(node.name)[0]
72            overridden_frame = overridden.frame(future=True)
73            if (
74                isinstance(overridden_frame, nodes.FunctionDef)
75                and overridden_frame.type == "method"
76            ):
77                overridden_frame = overridden_frame.parent.frame(future=True)
78            if not (
79                isinstance(overridden_frame, nodes.ClassDef)
80                and klass.is_subtype_of(overridden_frame.qname())
81            ):
82                return
83
84            # If a subclass defined the method then it's not our fault.
85            for ancestor in klass.ancestors():
86                if node.name in ancestor.instance_attrs and is_attr_private(node.name):
87                    return
88                for obj in ancestor.lookup(node.name)[1]:
89                    if isinstance(obj, nodes.FunctionDef):
90                        return
91            args = (overridden.root().name, overridden.fromlineno)
92            self.add_message("method-hidden", args=args, node=node)
93        except astroid.NotFoundError:
94            pass
            

Path 21: 2 calls (0.0)

FunctionDef (2)

None (2)

1def visit_functiondef(self, node: nodes.FunctionDef) -> None:
2        """Check method arguments, overriding."""
3        # ignore actual functions
4        if not node.is_method():
5            return
6
7        self._check_useless_super_delegation(node)
8        self._check_property_with_parameters(node)
9
10        # 'is_method()' is called and makes sure that this is a 'nodes.ClassDef'
11        klass = node.parent.frame(future=True)  # type: nodes.ClassDef
12        # check first argument is self if this is actually a method
13        self._check_first_arg_for_type(node, klass.type == "metaclass")
14        if node.name == "__init__":
15            self._check_init(node, klass)
16            return
17        # check signature if the method overloads inherited method
18        for overridden in klass.local_attr_ancestors(node.name):
19            # get astroid for the searched method
20            try:
21                parent_function = overridden[node.name]
22            except KeyError:
23                # we have found the method but it's not in the local
24                # dictionary.
25                # This may happen with astroid build from living objects
26                continue
27            if not isinstance(parent_function, nodes.FunctionDef):
28                continue
29            self._check_signature(node, parent_function, klass)
30            self._check_invalid_overridden_method(node, parent_function)
31            break
32
33        if node.decorators:
34            for decorator in node.decorators.nodes:
35                if isinstance(decorator, nodes.Attribute) and decorator.attrname in {
36                    "getter",
37                    "setter",
38                    "deleter",
39                }:
40                    # attribute affectation will call this method, not hiding it
41                    return
42                if isinstance(decorator, nodes.Name):
43                    if decorator.name == "property":
44                        # attribute affectation will either call a setter or raise
45                        # an attribute error, anyway not hiding the function
46                        return
47
48                # Infer the decorator and see if it returns something useful
49                inferred = safe_infer(decorator)
50                if not inferred:
51                    return
52                if isinstance(inferred, nodes.FunctionDef):
53                    # Okay, it's a decorator, let's see what it can infer.
54                    try:
55                        inferred = next(inferred.infer_call_result(inferred))
56                    except astroid.InferenceError:
57                        return
58                try:
59                    if (
60                        isinstance(inferred, (astroid.Instance, nodes.ClassDef))
61                        and inferred.getattr("__get__")
62                        and inferred.getattr("__set__")
63                    ):
64                        return
65                except astroid.AttributeInferenceError:
66                    pass
67
68        # check if the method is hidden by an attribute
69        # pylint: disable = too-many-try-statements
70        try:
71            overridden = klass.instance_attr(node.name)[0]
72            overridden_frame = overridden.frame(future=True)
73            if (
74                isinstance(overridden_frame, nodes.FunctionDef)
75                and overridden_frame.type == "method"
76            ):
77                overridden_frame = overridden_frame.parent.frame(future=True)
78            if not (
79                isinstance(overridden_frame, nodes.ClassDef)
80                and klass.is_subtype_of(overridden_frame.qname())
81            ):
82                return
83
84            # If a subclass defined the method then it's not our fault.
85            for ancestor in klass.ancestors():
86                if node.name in ancestor.instance_attrs and is_attr_private(node.name):
87                    return
88                for obj in ancestor.lookup(node.name)[1]:
89                    if isinstance(obj, nodes.FunctionDef):
90                        return
91            args = (overridden.root().name, overridden.fromlineno)
92            self.add_message("method-hidden", args=args, node=node)
93        except astroid.NotFoundError:
94            pass
            

Path 22: 2 calls (0.0)

FunctionDef (2)

None (2)

1def visit_functiondef(self, node: nodes.FunctionDef) -> None:
2        """Check method arguments, overriding."""
3        # ignore actual functions
4        if not node.is_method():
5            return
6
7        self._check_useless_super_delegation(node)
8        self._check_property_with_parameters(node)
9
10        # 'is_method()' is called and makes sure that this is a 'nodes.ClassDef'
11        klass = node.parent.frame(future=True)  # type: nodes.ClassDef
12        # check first argument is self if this is actually a method
13        self._check_first_arg_for_type(node, klass.type == "metaclass")
14        if node.name == "__init__":
15            self._check_init(node, klass)
16            return
17        # check signature if the method overloads inherited method
18        for overridden in klass.local_attr_ancestors(node.name):
19            # get astroid for the searched method
20            try:
21                parent_function = overridden[node.name]
22            except KeyError:
23                # we have found the method but it's not in the local
24                # dictionary.
25                # This may happen with astroid build from living objects
26                continue
27            if not isinstance(parent_function, nodes.FunctionDef):
28                continue
29            self._check_signature(node, parent_function, klass)
30            self._check_invalid_overridden_method(node, parent_function)
31            break
32
33        if node.decorators:
34            for decorator in node.decorators.nodes:
35                if isinstance(decorator, nodes.Attribute) and decorator.attrname in {
36                    "getter",
37                    "setter",
38                    "deleter",
39                }:
40                    # attribute affectation will call this method, not hiding it
41                    return
42                if isinstance(decorator, nodes.Name):
43                    if decorator.name == "property":
44                        # attribute affectation will either call a setter or raise
45                        # an attribute error, anyway not hiding the function
46                        return
47
48                # Infer the decorator and see if it returns something useful
49                inferred = safe_infer(decorator)
50                if not inferred:
51                    return
52                if isinstance(inferred, nodes.FunctionDef):
53                    # Okay, it's a decorator, let's see what it can infer.
54                    try:
55                        inferred = next(inferred.infer_call_result(inferred))
56                    except astroid.InferenceError:
57                        return
58                try:
59                    if (
60                        isinstance(inferred, (astroid.Instance, nodes.ClassDef))
61                        and inferred.getattr("__get__")
62                        and inferred.getattr("__set__")
63                    ):
64                        return
65                except astroid.AttributeInferenceError:
66                    pass
67
68        # check if the method is hidden by an attribute
69        # pylint: disable = too-many-try-statements
70        try:
71            overridden = klass.instance_attr(node.name)[0]
72            overridden_frame = overridden.frame(future=True)
73            if (
74                isinstance(overridden_frame, nodes.FunctionDef)
75                and overridden_frame.type == "method"
76            ):
77                overridden_frame = overridden_frame.parent.frame(future=True)
78            if not (
79                isinstance(overridden_frame, nodes.ClassDef)
80                and klass.is_subtype_of(overridden_frame.qname())
81            ):
82                return
83
84            # If a subclass defined the method then it's not our fault.
85            for ancestor in klass.ancestors():
86                if node.name in ancestor.instance_attrs and is_attr_private(node.name):
87                    return
88                for obj in ancestor.lookup(node.name)[1]:
89                    if isinstance(obj, nodes.FunctionDef):
90                        return
91            args = (overridden.root().name, overridden.fromlineno)
92            self.add_message("method-hidden", args=args, node=node)
93        except astroid.NotFoundError:
94            pass
            

Path 23: 1 calls (0.0)

FunctionDef (1)

None (1)

1def visit_functiondef(self, node: nodes.FunctionDef) -> None:
2        """Check method arguments, overriding."""
3        # ignore actual functions
4        if not node.is_method():
5            return
6
7        self._check_useless_super_delegation(node)
8        self._check_property_with_parameters(node)
9
10        # 'is_method()' is called and makes sure that this is a 'nodes.ClassDef'
11        klass = node.parent.frame(future=True)  # type: nodes.ClassDef
12        # check first argument is self if this is actually a method
13        self._check_first_arg_for_type(node, klass.type == "metaclass")
14        if node.name == "__init__":
15            self._check_init(node, klass)
16            return
17        # check signature if the method overloads inherited method
18        for overridden in klass.local_attr_ancestors(node.name):
19            # get astroid for the searched method
20            try:
21                parent_function = overridden[node.name]
22            except KeyError:
23                # we have found the method but it's not in the local
24                # dictionary.
25                # This may happen with astroid build from living objects
26                continue
27            if not isinstance(parent_function, nodes.FunctionDef):
28                continue
29            self._check_signature(node, parent_function, klass)
30            self._check_invalid_overridden_method(node, parent_function)
31            break
32
33        if node.decorators:
34            for decorator in node.decorators.nodes:
35                if isinstance(decorator, nodes.Attribute) and decorator.attrname in {
36                    "getter",
37                    "setter",
38                    "deleter",
39                }:
40                    # attribute affectation will call this method, not hiding it
41                    return
42                if isinstance(decorator, nodes.Name):
43                    if decorator.name == "property":
44                        # attribute affectation will either call a setter or raise
45                        # an attribute error, anyway not hiding the function
46                        return
47
48                # Infer the decorator and see if it returns something useful
49                inferred = safe_infer(decorator)
50                if not inferred:
51                    return
52                if isinstance(inferred, nodes.FunctionDef):
53                    # Okay, it's a decorator, let's see what it can infer.
54                    try:
55                        inferred = next(inferred.infer_call_result(inferred))
56                    except astroid.InferenceError:
57                        return
58                try:
59                    if (
60                        isinstance(inferred, (astroid.Instance, nodes.ClassDef))
61                        and inferred.getattr("__get__")
62                        and inferred.getattr("__set__")
63                    ):
64                        return
65                except astroid.AttributeInferenceError:
66                    pass
67
68        # check if the method is hidden by an attribute
69        # pylint: disable = too-many-try-statements
70        try:
71            overridden = klass.instance_attr(node.name)[0]
72            overridden_frame = overridden.frame(future=True)
73            if (
74                isinstance(overridden_frame, nodes.FunctionDef)
75                and overridden_frame.type == "method"
76            ):
77                overridden_frame = overridden_frame.parent.frame(future=True)
78            if not (
79                isinstance(overridden_frame, nodes.ClassDef)
80                and klass.is_subtype_of(overridden_frame.qname())
81            ):
82                return
83
84            # If a subclass defined the method then it's not our fault.
85            for ancestor in klass.ancestors():
86                if node.name in ancestor.instance_attrs and is_attr_private(node.name):
87                    return
88                for obj in ancestor.lookup(node.name)[1]:
89                    if isinstance(obj, nodes.FunctionDef):
90                        return
91            args = (overridden.root().name, overridden.fromlineno)
92            self.add_message("method-hidden", args=args, node=node)
93        except astroid.NotFoundError:
94            pass
            

Path 24: 1 calls (0.0)

FunctionDef (1)

AttributeInferenceError (1)

1def visit_functiondef(self, node: nodes.FunctionDef) -> None:
2        """Check method arguments, overriding."""
3        # ignore actual functions
4        if not node.is_method():
5            return
6
7        self._check_useless_super_delegation(node)
8        self._check_property_with_parameters(node)
9
10        # 'is_method()' is called and makes sure that this is a 'nodes.ClassDef'
11        klass = node.parent.frame(future=True)  # type: nodes.ClassDef
12        # check first argument is self if this is actually a method
13        self._check_first_arg_for_type(node, klass.type == "metaclass")
14        if node.name == "__init__":
15            self._check_init(node, klass)
16            return
17        # check signature if the method overloads inherited method
18        for overridden in klass.local_attr_ancestors(node.name):
19            # get astroid for the searched method
20            try:
21                parent_function = overridden[node.name]
22            except KeyError:
23                # we have found the method but it's not in the local
24                # dictionary.
25                # This may happen with astroid build from living objects
26                continue
27            if not isinstance(parent_function, nodes.FunctionDef):
28                continue
29            self._check_signature(node, parent_function, klass)
30            self._check_invalid_overridden_method(node, parent_function)
31            break
32
33        if node.decorators:
34            for decorator in node.decorators.nodes:
35                if isinstance(decorator, nodes.Attribute) and decorator.attrname in {
36                    "getter",
37                    "setter",
38                    "deleter",
39                }:
40                    # attribute affectation will call this method, not hiding it
41                    return
42                if isinstance(decorator, nodes.Name):
43                    if decorator.name == "property":
44                        # attribute affectation will either call a setter or raise
45                        # an attribute error, anyway not hiding the function
46                        return
47
48                # Infer the decorator and see if it returns something useful
49                inferred = safe_infer(decorator)
50                if not inferred:
51                    return
52                if isinstance(inferred, nodes.FunctionDef):
53                    # Okay, it's a decorator, let's see what it can infer.
54                    try:
55                        inferred = next(inferred.infer_call_result(inferred))
56                    except astroid.InferenceError:
57                        return
58                try:
59                    if (
60                        isinstance(inferred, (astroid.Instance, nodes.ClassDef))
61                        and inferred.getattr("__get__")
62                        and inferred.getattr("__set__")
63                    ):
64                        return
65                except astroid.AttributeInferenceError:
66                    pass
67
68        # check if the method is hidden by an attribute
69        # pylint: disable = too-many-try-statements
70        try:
71            overridden = klass.instance_attr(node.name)[0]
72            overridden_frame = overridden.frame(future=True)
73            if (
74                isinstance(overridden_frame, nodes.FunctionDef)
75                and overridden_frame.type == "method"
76            ):
77                overridden_frame = overridden_frame.parent.frame(future=True)
78            if not (
79                isinstance(overridden_frame, nodes.ClassDef)
80                and klass.is_subtype_of(overridden_frame.qname())
81            ):
82                return
83
84            # If a subclass defined the method then it's not our fault.
85            for ancestor in klass.ancestors():
86                if node.name in ancestor.instance_attrs and is_attr_private(node.name):
87                    return
88                for obj in ancestor.lookup(node.name)[1]:
89                    if isinstance(obj, nodes.FunctionDef):
90                        return
91            args = (overridden.root().name, overridden.fromlineno)
92            self.add_message("method-hidden", args=args, node=node)
93        except astroid.NotFoundError:
94            pass
            

Path 25: 1 calls (0.0)

FunctionDef (1)

AttributeInferenceError (1)

1def visit_functiondef(self, node: nodes.FunctionDef) -> None:
2        """Check method arguments, overriding."""
3        # ignore actual functions
4        if not node.is_method():
5            return
6
7        self._check_useless_super_delegation(node)
8        self._check_property_with_parameters(node)
9
10        # 'is_method()' is called and makes sure that this is a 'nodes.ClassDef'
11        klass = node.parent.frame(future=True)  # type: nodes.ClassDef
12        # check first argument is self if this is actually a method
13        self._check_first_arg_for_type(node, klass.type == "metaclass")
14        if node.name == "__init__":
15            self._check_init(node, klass)
16            return
17        # check signature if the method overloads inherited method
18        for overridden in klass.local_attr_ancestors(node.name):
19            # get astroid for the searched method
20            try:
21                parent_function = overridden[node.name]
22            except KeyError:
23                # we have found the method but it's not in the local
24                # dictionary.
25                # This may happen with astroid build from living objects
26                continue
27            if not isinstance(parent_function, nodes.FunctionDef):
28                continue
29            self._check_signature(node, parent_function, klass)
30            self._check_invalid_overridden_method(node, parent_function)
31            break
32
33        if node.decorators:
34            for decorator in node.decorators.nodes:
35                if isinstance(decorator, nodes.Attribute) and decorator.attrname in {
36                    "getter",
37                    "setter",
38                    "deleter",
39                }:
40                    # attribute affectation will call this method, not hiding it
41                    return
42                if isinstance(decorator, nodes.Name):
43                    if decorator.name == "property":
44                        # attribute affectation will either call a setter or raise
45                        # an attribute error, anyway not hiding the function
46                        return
47
48                # Infer the decorator and see if it returns something useful
49                inferred = safe_infer(decorator)
50                if not inferred:
51                    return
52                if isinstance(inferred, nodes.FunctionDef):
53                    # Okay, it's a decorator, let's see what it can infer.
54                    try:
55                        inferred = next(inferred.infer_call_result(inferred))
56                    except astroid.InferenceError:
57                        return
58                try:
59                    if (
60                        isinstance(inferred, (astroid.Instance, nodes.ClassDef))
61                        and inferred.getattr("__get__")
62                        and inferred.getattr("__set__")
63                    ):
64                        return
65                except astroid.AttributeInferenceError:
66                    pass
67
68        # check if the method is hidden by an attribute
69        # pylint: disable = too-many-try-statements
70        try:
71            overridden = klass.instance_attr(node.name)[0]
72            overridden_frame = overridden.frame(future=True)
73            if (
74                isinstance(overridden_frame, nodes.FunctionDef)
75                and overridden_frame.type == "method"
76            ):
77                overridden_frame = overridden_frame.parent.frame(future=True)
78            if not (
79                isinstance(overridden_frame, nodes.ClassDef)
80                and klass.is_subtype_of(overridden_frame.qname())
81            ):
82                return
83
84            # If a subclass defined the method then it's not our fault.
85            for ancestor in klass.ancestors():
86                if node.name in ancestor.instance_attrs and is_attr_private(node.name):
87                    return
88                for obj in ancestor.lookup(node.name)[1]:
89                    if isinstance(obj, nodes.FunctionDef):
90                        return
91            args = (overridden.root().name, overridden.fromlineno)
92            self.add_message("method-hidden", args=args, node=node)
93        except astroid.NotFoundError:
94            pass
            

Path 26: 1 calls (0.0)

FunctionDef (1)

None (1)

1def visit_functiondef(self, node: nodes.FunctionDef) -> None:
2        """Check method arguments, overriding."""
3        # ignore actual functions
4        if not node.is_method():
5            return
6
7        self._check_useless_super_delegation(node)
8        self._check_property_with_parameters(node)
9
10        # 'is_method()' is called and makes sure that this is a 'nodes.ClassDef'
11        klass = node.parent.frame(future=True)  # type: nodes.ClassDef
12        # check first argument is self if this is actually a method
13        self._check_first_arg_for_type(node, klass.type == "metaclass")
14        if node.name == "__init__":
15            self._check_init(node, klass)
16            return
17        # check signature if the method overloads inherited method
18        for overridden in klass.local_attr_ancestors(node.name):
19            # get astroid for the searched method
20            try:
21                parent_function = overridden[node.name]
22            except KeyError:
23                # we have found the method but it's not in the local
24                # dictionary.
25                # This may happen with astroid build from living objects
26                continue
27            if not isinstance(parent_function, nodes.FunctionDef):
28                continue
29            self._check_signature(node, parent_function, klass)
30            self._check_invalid_overridden_method(node, parent_function)
31            break
32
33        if node.decorators:
34            for decorator in node.decorators.nodes:
35                if isinstance(decorator, nodes.Attribute) and decorator.attrname in {
36                    "getter",
37                    "setter",
38                    "deleter",
39                }:
40                    # attribute affectation will call this method, not hiding it
41                    return
42                if isinstance(decorator, nodes.Name):
43                    if decorator.name == "property":
44                        # attribute affectation will either call a setter or raise
45                        # an attribute error, anyway not hiding the function
46                        return
47
48                # Infer the decorator and see if it returns something useful
49                inferred = safe_infer(decorator)
50                if not inferred:
51                    return
52                if isinstance(inferred, nodes.FunctionDef):
53                    # Okay, it's a decorator, let's see what it can infer.
54                    try:
55                        inferred = next(inferred.infer_call_result(inferred))
56                    except astroid.InferenceError:
57                        return
58                try:
59                    if (
60                        isinstance(inferred, (astroid.Instance, nodes.ClassDef))
61                        and inferred.getattr("__get__")
62                        and inferred.getattr("__set__")
63                    ):
64                        return
65                except astroid.AttributeInferenceError:
66                    pass
67
68        # check if the method is hidden by an attribute
69        # pylint: disable = too-many-try-statements
70        try:
71            overridden = klass.instance_attr(node.name)[0]
72            overridden_frame = overridden.frame(future=True)
73            if (
74                isinstance(overridden_frame, nodes.FunctionDef)
75                and overridden_frame.type == "method"
76            ):
77                overridden_frame = overridden_frame.parent.frame(future=True)
78            if not (
79                isinstance(overridden_frame, nodes.ClassDef)
80                and klass.is_subtype_of(overridden_frame.qname())
81            ):
82                return
83
84            # If a subclass defined the method then it's not our fault.
85            for ancestor in klass.ancestors():
86                if node.name in ancestor.instance_attrs and is_attr_private(node.name):
87                    return
88                for obj in ancestor.lookup(node.name)[1]:
89                    if isinstance(obj, nodes.FunctionDef):
90                        return
91            args = (overridden.root().name, overridden.fromlineno)
92            self.add_message("method-hidden", args=args, node=node)
93        except astroid.NotFoundError:
94            pass
            

Path 27: 1 calls (0.0)

FunctionDef (1)

AttributeInferenceError (1)

1def visit_functiondef(self, node: nodes.FunctionDef) -> None:
2        """Check method arguments, overriding."""
3        # ignore actual functions
4        if not node.is_method():
5            return
6
7        self._check_useless_super_delegation(node)
8        self._check_property_with_parameters(node)
9
10        # 'is_method()' is called and makes sure that this is a 'nodes.ClassDef'
11        klass = node.parent.frame(future=True)  # type: nodes.ClassDef
12        # check first argument is self if this is actually a method
13        self._check_first_arg_for_type(node, klass.type == "metaclass")
14        if node.name == "__init__":
15            self._check_init(node, klass)
16            return
17        # check signature if the method overloads inherited method
18        for overridden in klass.local_attr_ancestors(node.name):
19            # get astroid for the searched method
20            try:
21                parent_function = overridden[node.name]
22            except KeyError:
23                # we have found the method but it's not in the local
24                # dictionary.
25                # This may happen with astroid build from living objects
26                continue
27            if not isinstance(parent_function, nodes.FunctionDef):
28                continue
29            self._check_signature(node, parent_function, klass)
30            self._check_invalid_overridden_method(node, parent_function)
31            break
32
33        if node.decorators:
34            for decorator in node.decorators.nodes:
35                if isinstance(decorator, nodes.Attribute) and decorator.attrname in {
36                    "getter",
37                    "setter",
38                    "deleter",
39                }:
40                    # attribute affectation will call this method, not hiding it
41                    return
42                if isinstance(decorator, nodes.Name):
43                    if decorator.name == "property":
44                        # attribute affectation will either call a setter or raise
45                        # an attribute error, anyway not hiding the function
46                        return
47
48                # Infer the decorator and see if it returns something useful
49                inferred = safe_infer(decorator)
50                if not inferred:
51                    return
52                if isinstance(inferred, nodes.FunctionDef):
53                    # Okay, it's a decorator, let's see what it can infer.
54                    try:
55                        inferred = next(inferred.infer_call_result(inferred))
56                    except astroid.InferenceError:
57                        return
58                try:
59                    if (
60                        isinstance(inferred, (astroid.Instance, nodes.ClassDef))
61                        and inferred.getattr("__get__")
62                        and inferred.getattr("__set__")
63                    ):
64                        return
65                except astroid.AttributeInferenceError:
66                    pass
67
68        # check if the method is hidden by an attribute
69        # pylint: disable = too-many-try-statements
70        try:
71            overridden = klass.instance_attr(node.name)[0]
72            overridden_frame = overridden.frame(future=True)
73            if (
74                isinstance(overridden_frame, nodes.FunctionDef)
75                and overridden_frame.type == "method"
76            ):
77                overridden_frame = overridden_frame.parent.frame(future=True)
78            if not (
79                isinstance(overridden_frame, nodes.ClassDef)
80                and klass.is_subtype_of(overridden_frame.qname())
81            ):
82                return
83
84            # If a subclass defined the method then it's not our fault.
85            for ancestor in klass.ancestors():
86                if node.name in ancestor.instance_attrs and is_attr_private(node.name):
87                    return
88                for obj in ancestor.lookup(node.name)[1]:
89                    if isinstance(obj, nodes.FunctionDef):
90                        return
91            args = (overridden.root().name, overridden.fromlineno)
92            self.add_message("method-hidden", args=args, node=node)
93        except astroid.NotFoundError:
94            pass
            

Path 28: 1 calls (0.0)

FunctionDef (1)

None (1)

1def visit_functiondef(self, node: nodes.FunctionDef) -> None:
2        """Check method arguments, overriding."""
3        # ignore actual functions
4        if not node.is_method():
5            return
6
7        self._check_useless_super_delegation(node)
8        self._check_property_with_parameters(node)
9
10        # 'is_method()' is called and makes sure that this is a 'nodes.ClassDef'
11        klass = node.parent.frame(future=True)  # type: nodes.ClassDef
12        # check first argument is self if this is actually a method
13        self._check_first_arg_for_type(node, klass.type == "metaclass")
14        if node.name == "__init__":
15            self._check_init(node, klass)
16            return
17        # check signature if the method overloads inherited method
18        for overridden in klass.local_attr_ancestors(node.name):
19            # get astroid for the searched method
20            try:
21                parent_function = overridden[node.name]
22            except KeyError:
23                # we have found the method but it's not in the local
24                # dictionary.
25                # This may happen with astroid build from living objects
26                continue
27            if not isinstance(parent_function, nodes.FunctionDef):
28                continue
29            self._check_signature(node, parent_function, klass)
30            self._check_invalid_overridden_method(node, parent_function)
31            break
32
33        if node.decorators:
34            for decorator in node.decorators.nodes:
35                if isinstance(decorator, nodes.Attribute) and decorator.attrname in {
36                    "getter",
37                    "setter",
38                    "deleter",
39                }:
40                    # attribute affectation will call this method, not hiding it
41                    return
42                if isinstance(decorator, nodes.Name):
43                    if decorator.name == "property":
44                        # attribute affectation will either call a setter or raise
45                        # an attribute error, anyway not hiding the function
46                        return
47
48                # Infer the decorator and see if it returns something useful
49                inferred = safe_infer(decorator)
50                if not inferred:
51                    return
52                if isinstance(inferred, nodes.FunctionDef):
53                    # Okay, it's a decorator, let's see what it can infer.
54                    try:
55                        inferred = next(inferred.infer_call_result(inferred))
56                    except astroid.InferenceError:
57                        return
58                try:
59                    if (
60                        isinstance(inferred, (astroid.Instance, nodes.ClassDef))
61                        and inferred.getattr("__get__")
62                        and inferred.getattr("__set__")
63                    ):
64                        return
65                except astroid.AttributeInferenceError:
66                    pass
67
68        # check if the method is hidden by an attribute
69        # pylint: disable = too-many-try-statements
70        try:
71            overridden = klass.instance_attr(node.name)[0]
72            overridden_frame = overridden.frame(future=True)
73            if (
74                isinstance(overridden_frame, nodes.FunctionDef)
75                and overridden_frame.type == "method"
76            ):
77                overridden_frame = overridden_frame.parent.frame(future=True)
78            if not (
79                isinstance(overridden_frame, nodes.ClassDef)
80                and klass.is_subtype_of(overridden_frame.qname())
81            ):
82                return
83
84            # If a subclass defined the method then it's not our fault.
85            for ancestor in klass.ancestors():
86                if node.name in ancestor.instance_attrs and is_attr_private(node.name):
87                    return
88                for obj in ancestor.lookup(node.name)[1]:
89                    if isinstance(obj, nodes.FunctionDef):
90                        return
91            args = (overridden.root().name, overridden.fromlineno)
92            self.add_message("method-hidden", args=args, node=node)
93        except astroid.NotFoundError:
94            pass
            

Path 29: 1 calls (0.0)

FunctionDef (1)

None (1)

1def visit_functiondef(self, node: nodes.FunctionDef) -> None:
2        """Check method arguments, overriding."""
3        # ignore actual functions
4        if not node.is_method():
5            return
6
7        self._check_useless_super_delegation(node)
8        self._check_property_with_parameters(node)
9
10        # 'is_method()' is called and makes sure that this is a 'nodes.ClassDef'
11        klass = node.parent.frame(future=True)  # type: nodes.ClassDef
12        # check first argument is self if this is actually a method
13        self._check_first_arg_for_type(node, klass.type == "metaclass")
14        if node.name == "__init__":
15            self._check_init(node, klass)
16            return
17        # check signature if the method overloads inherited method
18        for overridden in klass.local_attr_ancestors(node.name):
19            # get astroid for the searched method
20            try:
21                parent_function = overridden[node.name]
22            except KeyError:
23                # we have found the method but it's not in the local
24                # dictionary.
25                # This may happen with astroid build from living objects
26                continue
27            if not isinstance(parent_function, nodes.FunctionDef):
28                continue
29            self._check_signature(node, parent_function, klass)
30            self._check_invalid_overridden_method(node, parent_function)
31            break
32
33        if node.decorators:
34            for decorator in node.decorators.nodes:
35                if isinstance(decorator, nodes.Attribute) and decorator.attrname in {
36                    "getter",
37                    "setter",
38                    "deleter",
39                }:
40                    # attribute affectation will call this method, not hiding it
41                    return
42                if isinstance(decorator, nodes.Name):
43                    if decorator.name == "property":
44                        # attribute affectation will either call a setter or raise
45                        # an attribute error, anyway not hiding the function
46                        return
47
48                # Infer the decorator and see if it returns something useful
49                inferred = safe_infer(decorator)
50                if not inferred:
51                    return
52                if isinstance(inferred, nodes.FunctionDef):
53                    # Okay, it's a decorator, let's see what it can infer.
54                    try:
55                        inferred = next(inferred.infer_call_result(inferred))
56                    except astroid.InferenceError:
57                        return
58                try:
59                    if (
60                        isinstance(inferred, (astroid.Instance, nodes.ClassDef))
61                        and inferred.getattr("__get__")
62                        and inferred.getattr("__set__")
63                    ):
64                        return
65                except astroid.AttributeInferenceError:
66                    pass
67
68        # check if the method is hidden by an attribute
69        # pylint: disable = too-many-try-statements
70        try:
71            overridden = klass.instance_attr(node.name)[0]
72            overridden_frame = overridden.frame(future=True)
73            if (
74                isinstance(overridden_frame, nodes.FunctionDef)
75                and overridden_frame.type == "method"
76            ):
77                overridden_frame = overridden_frame.parent.frame(future=True)
78            if not (
79                isinstance(overridden_frame, nodes.ClassDef)
80                and klass.is_subtype_of(overridden_frame.qname())
81            ):
82                return
83
84            # If a subclass defined the method then it's not our fault.
85            for ancestor in klass.ancestors():
86                if node.name in ancestor.instance_attrs and is_attr_private(node.name):
87                    return
88                for obj in ancestor.lookup(node.name)[1]:
89                    if isinstance(obj, nodes.FunctionDef):
90                        return
91            args = (overridden.root().name, overridden.fromlineno)
92            self.add_message("method-hidden", args=args, node=node)
93        except astroid.NotFoundError:
94            pass
            

Path 30: 1 calls (0.0)

FunctionDef (1)

None (1)

1def visit_functiondef(self, node: nodes.FunctionDef) -> None:
2        """Check method arguments, overriding."""
3        # ignore actual functions
4        if not node.is_method():
5            return
6
7        self._check_useless_super_delegation(node)
8        self._check_property_with_parameters(node)
9
10        # 'is_method()' is called and makes sure that this is a 'nodes.ClassDef'
11        klass = node.parent.frame(future=True)  # type: nodes.ClassDef
12        # check first argument is self if this is actually a method
13        self._check_first_arg_for_type(node, klass.type == "metaclass")
14        if node.name == "__init__":
15            self._check_init(node, klass)
16            return
17        # check signature if the method overloads inherited method
18        for overridden in klass.local_attr_ancestors(node.name):
19            # get astroid for the searched method
20            try:
21                parent_function = overridden[node.name]
22            except KeyError:
23                # we have found the method but it's not in the local
24                # dictionary.
25                # This may happen with astroid build from living objects
26                continue
27            if not isinstance(parent_function, nodes.FunctionDef):
28                continue
29            self._check_signature(node, parent_function, klass)
30            self._check_invalid_overridden_method(node, parent_function)
31            break
32
33        if node.decorators:
34            for decorator in node.decorators.nodes:
35                if isinstance(decorator, nodes.Attribute) and decorator.attrname in {
36                    "getter",
37                    "setter",
38                    "deleter",
39                }:
40                    # attribute affectation will call this method, not hiding it
41                    return
42                if isinstance(decorator, nodes.Name):
43                    if decorator.name == "property":
44                        # attribute affectation will either call a setter or raise
45                        # an attribute error, anyway not hiding the function
46                        return
47
48                # Infer the decorator and see if it returns something useful
49                inferred = safe_infer(decorator)
50                if not inferred:
51                    return
52                if isinstance(inferred, nodes.FunctionDef):
53                    # Okay, it's a decorator, let's see what it can infer.
54                    try:
55                        inferred = next(inferred.infer_call_result(inferred))
56                    except astroid.InferenceError:
57                        return
58                try:
59                    if (
60                        isinstance(inferred, (astroid.Instance, nodes.ClassDef))
61                        and inferred.getattr("__get__")
62                        and inferred.getattr("__set__")
63                    ):
64                        return
65                except astroid.AttributeInferenceError:
66                    pass
67
68        # check if the method is hidden by an attribute
69        # pylint: disable = too-many-try-statements
70        try:
71            overridden = klass.instance_attr(node.name)[0]
72            overridden_frame = overridden.frame(future=True)
73            if (
74                isinstance(overridden_frame, nodes.FunctionDef)
75                and overridden_frame.type == "method"
76            ):
77                overridden_frame = overridden_frame.parent.frame(future=True)
78            if not (
79                isinstance(overridden_frame, nodes.ClassDef)
80                and klass.is_subtype_of(overridden_frame.qname())
81            ):
82                return
83
84            # If a subclass defined the method then it's not our fault.
85            for ancestor in klass.ancestors():
86                if node.name in ancestor.instance_attrs and is_attr_private(node.name):
87                    return
88                for obj in ancestor.lookup(node.name)[1]:
89                    if isinstance(obj, nodes.FunctionDef):
90                        return
91            args = (overridden.root().name, overridden.fromlineno)
92            self.add_message("method-hidden", args=args, node=node)
93        except astroid.NotFoundError:
94            pass
            

Path 31: 1 calls (0.0)

FunctionDef (1)

None (1)

AttributeInferenceError (1)

1def visit_functiondef(self, node: nodes.FunctionDef) -> None:
2        """Check method arguments, overriding."""
3        # ignore actual functions
4        if not node.is_method():
5            return
6
7        self._check_useless_super_delegation(node)
8        self._check_property_with_parameters(node)
9
10        # 'is_method()' is called and makes sure that this is a 'nodes.ClassDef'
11        klass = node.parent.frame(future=True)  # type: nodes.ClassDef
12        # check first argument is self if this is actually a method
13        self._check_first_arg_for_type(node, klass.type == "metaclass")
14        if node.name == "__init__":
15            self._check_init(node, klass)
16            return
17        # check signature if the method overloads inherited method
18        for overridden in klass.local_attr_ancestors(node.name):
19            # get astroid for the searched method
20            try:
21                parent_function = overridden[node.name]
22            except KeyError:
23                # we have found the method but it's not in the local
24                # dictionary.
25                # This may happen with astroid build from living objects
26                continue
27            if not isinstance(parent_function, nodes.FunctionDef):
28                continue
29            self._check_signature(node, parent_function, klass)
30            self._check_invalid_overridden_method(node, parent_function)
31            break
32
33        if node.decorators:
34            for decorator in node.decorators.nodes:
35                if isinstance(decorator, nodes.Attribute) and decorator.attrname in {
36                    "getter",
37                    "setter",
38                    "deleter",
39                }:
40                    # attribute affectation will call this method, not hiding it
41                    return
42                if isinstance(decorator, nodes.Name):
43                    if decorator.name == "property":
44                        # attribute affectation will either call a setter or raise
45                        # an attribute error, anyway not hiding the function
46                        return
47
48                # Infer the decorator and see if it returns something useful
49                inferred = safe_infer(decorator)
50                if not inferred:
51                    return
52                if isinstance(inferred, nodes.FunctionDef):
53                    # Okay, it's a decorator, let's see what it can infer.
54                    try:
55                        inferred = next(inferred.infer_call_result(inferred))
56                    except astroid.InferenceError:
57                        return
58                try:
59                    if (
60                        isinstance(inferred, (astroid.Instance, nodes.ClassDef))
61                        and inferred.getattr("__get__")
62                        and inferred.getattr("__set__")
63                    ):
64                        return
65                except astroid.AttributeInferenceError:
66                    pass
67
68        # check if the method is hidden by an attribute
69        # pylint: disable = too-many-try-statements
70        try:
71            overridden = klass.instance_attr(node.name)[0]
72            overridden_frame = overridden.frame(future=True)
73            if (
74                isinstance(overridden_frame, nodes.FunctionDef)
75                and overridden_frame.type == "method"
76            ):
77                overridden_frame = overridden_frame.parent.frame(future=True)
78            if not (
79                isinstance(overridden_frame, nodes.ClassDef)
80                and klass.is_subtype_of(overridden_frame.qname())
81            ):
82                return
83
84            # If a subclass defined the method then it's not our fault.
85            for ancestor in klass.ancestors():
86                if node.name in ancestor.instance_attrs and is_attr_private(node.name):
87                    return
88                for obj in ancestor.lookup(node.name)[1]:
89                    if isinstance(obj, nodes.FunctionDef):
90                        return
91            args = (overridden.root().name, overridden.fromlineno)
92            self.add_message("method-hidden", args=args, node=node)
93        except astroid.NotFoundError:
94            pass
            

Path 32: 1 calls (0.0)

FunctionDef (1)

AttributeInferenceError (1)

1def visit_functiondef(self, node: nodes.FunctionDef) -> None:
2        """Check method arguments, overriding."""
3        # ignore actual functions
4        if not node.is_method():
5            return
6
7        self._check_useless_super_delegation(node)
8        self._check_property_with_parameters(node)
9
10        # 'is_method()' is called and makes sure that this is a 'nodes.ClassDef'
11        klass = node.parent.frame(future=True)  # type: nodes.ClassDef
12        # check first argument is self if this is actually a method
13        self._check_first_arg_for_type(node, klass.type == "metaclass")
14        if node.name == "__init__":
15            self._check_init(node, klass)
16            return
17        # check signature if the method overloads inherited method
18        for overridden in klass.local_attr_ancestors(node.name):
19            # get astroid for the searched method
20            try:
21                parent_function = overridden[node.name]
22            except KeyError:
23                # we have found the method but it's not in the local
24                # dictionary.
25                # This may happen with astroid build from living objects
26                continue
27            if not isinstance(parent_function, nodes.FunctionDef):
28                continue
29            self._check_signature(node, parent_function, klass)
30            self._check_invalid_overridden_method(node, parent_function)
31            break
32
33        if node.decorators:
34            for decorator in node.decorators.nodes:
35                if isinstance(decorator, nodes.Attribute) and decorator.attrname in {
36                    "getter",
37                    "setter",
38                    "deleter",
39                }:
40                    # attribute affectation will call this method, not hiding it
41                    return
42                if isinstance(decorator, nodes.Name):
43                    if decorator.name == "property":
44                        # attribute affectation will either call a setter or raise
45                        # an attribute error, anyway not hiding the function
46                        return
47
48                # Infer the decorator and see if it returns something useful
49                inferred = safe_infer(decorator)
50                if not inferred:
51                    return
52                if isinstance(inferred, nodes.FunctionDef):
53                    # Okay, it's a decorator, let's see what it can infer.
54                    try:
55                        inferred = next(inferred.infer_call_result(inferred))
56                    except astroid.InferenceError:
57                        return
58                try:
59                    if (
60                        isinstance(inferred, (astroid.Instance, nodes.ClassDef))
61                        and inferred.getattr("__get__")
62                        and inferred.getattr("__set__")
63                    ):
64                        return
65                except astroid.AttributeInferenceError:
66                    pass
67
68        # check if the method is hidden by an attribute
69        # pylint: disable = too-many-try-statements
70        try:
71            overridden = klass.instance_attr(node.name)[0]
72            overridden_frame = overridden.frame(future=True)
73            if (
74                isinstance(overridden_frame, nodes.FunctionDef)
75                and overridden_frame.type == "method"
76            ):
77                overridden_frame = overridden_frame.parent.frame(future=True)
78            if not (
79                isinstance(overridden_frame, nodes.ClassDef)
80                and klass.is_subtype_of(overridden_frame.qname())
81            ):
82                return
83
84            # If a subclass defined the method then it's not our fault.
85            for ancestor in klass.ancestors():
86                if node.name in ancestor.instance_attrs and is_attr_private(node.name):
87                    return
88                for obj in ancestor.lookup(node.name)[1]:
89                    if isinstance(obj, nodes.FunctionDef):
90                        return
91            args = (overridden.root().name, overridden.fromlineno)
92            self.add_message("method-hidden", args=args, node=node)
93        except astroid.NotFoundError:
94            pass