Method: pylint.checkers.variables.VariablesChecker.visit_functiondef
Calls: 3528, Exceptions: 2, Paths: 10Back
Path 1: 3050 calls (0.86)
FunctionDef (3011) AsyncFunctionDef (39)
1def visit_functiondef(self, node: nodes.FunctionDef) -> None:
2 """Visit function: update consumption analysis variable and check locals."""
3 self._to_consume.append(NamesConsumer(node, "function"))
4 if not (
5 self.linter.is_message_enabled("redefined-outer-name")
6 or self.linter.is_message_enabled("redefined-builtin")
7 ):
8 return
9 globs = node.root().globals
10 for name, stmt in node.items():
11 if name in globs and not isinstance(stmt, nodes.Global):
12 definition = globs[name][0]
13 if (
14 isinstance(definition, nodes.ImportFrom)
15 and definition.modname == FUTURE
16 ):
17 # It is a __future__ directive, not a symbol.
18 continue
19
20 # Do not take in account redefined names for the purpose
21 # of type checking.:
22 if any(
23 in_type_checking_block(definition) for definition in globs[name]
24 ):
25 continue
26
27 line = definition.fromlineno
28 if not self._is_name_ignored(stmt, name):
29 self.add_message(
30 "redefined-outer-name", args=(name, line), node=stmt
31 )
32
33 elif (
34 utils.is_builtin(name)
35 and not self._allowed_redefined_builtin(name)
36 and not self._should_ignore_redefined_builtin(stmt)
37 ):
38 # do not print Redefining builtin for additional builtins
39 self.add_message("redefined-builtin", args=name, node=stmt)
Path 2: 428 calls (0.12)
FunctionDef (413) AsyncFunctionDef (15)
1def visit_functiondef(self, node: nodes.FunctionDef) -> None:
2 """Visit function: update consumption analysis variable and check locals."""
3 self._to_consume.append(NamesConsumer(node, "function"))
4 if not (
5 self.linter.is_message_enabled("redefined-outer-name")
6 or self.linter.is_message_enabled("redefined-builtin")
7 ):
8 return
9 globs = node.root().globals
10 for name, stmt in node.items():
11 if name in globs and not isinstance(stmt, nodes.Global):
12 definition = globs[name][0]
13 if (
14 isinstance(definition, nodes.ImportFrom)
15 and definition.modname == FUTURE
16 ):
17 # It is a __future__ directive, not a symbol.
18 continue
19
20 # Do not take in account redefined names for the purpose
21 # of type checking.:
22 if any(
23 in_type_checking_block(definition) for definition in globs[name]
24 ):
25 continue
26
27 line = definition.fromlineno
28 if not self._is_name_ignored(stmt, name):
29 self.add_message(
30 "redefined-outer-name", args=(name, line), node=stmt
31 )
32
33 elif (
34 utils.is_builtin(name)
35 and not self._allowed_redefined_builtin(name)
36 and not self._should_ignore_redefined_builtin(stmt)
37 ):
38 # do not print Redefining builtin for additional builtins
39 self.add_message("redefined-builtin", args=name, node=stmt)
Path 3: 15 calls (0.0)
FunctionDef (15)
1def visit_functiondef(self, node: nodes.FunctionDef) -> None:
2 """Visit function: update consumption analysis variable and check locals."""
3 self._to_consume.append(NamesConsumer(node, "function"))
4 if not (
5 self.linter.is_message_enabled("redefined-outer-name")
6 or self.linter.is_message_enabled("redefined-builtin")
7 ):
8 return
9 globs = node.root().globals
10 for name, stmt in node.items():
11 if name in globs and not isinstance(stmt, nodes.Global):
12 definition = globs[name][0]
13 if (
14 isinstance(definition, nodes.ImportFrom)
15 and definition.modname == FUTURE
16 ):
17 # It is a __future__ directive, not a symbol.
18 continue
19
20 # Do not take in account redefined names for the purpose
21 # of type checking.:
22 if any(
23 in_type_checking_block(definition) for definition in globs[name]
24 ):
25 continue
26
27 line = definition.fromlineno
28 if not self._is_name_ignored(stmt, name):
29 self.add_message(
30 "redefined-outer-name", args=(name, line), node=stmt
31 )
32
33 elif (
34 utils.is_builtin(name)
35 and not self._allowed_redefined_builtin(name)
36 and not self._should_ignore_redefined_builtin(stmt)
37 ):
38 # do not print Redefining builtin for additional builtins
39 self.add_message("redefined-builtin", args=name, node=stmt)
Path 4: 15 calls (0.0)
FunctionDef (15)
1def visit_functiondef(self, node: nodes.FunctionDef) -> None:
2 """Visit function: update consumption analysis variable and check locals."""
3 self._to_consume.append(NamesConsumer(node, "function"))
4 if not (
5 self.linter.is_message_enabled("redefined-outer-name")
6 or self.linter.is_message_enabled("redefined-builtin")
7 ):
8 return
9 globs = node.root().globals
10 for name, stmt in node.items():
11 if name in globs and not isinstance(stmt, nodes.Global):
12 definition = globs[name][0]
13 if (
14 isinstance(definition, nodes.ImportFrom)
15 and definition.modname == FUTURE
16 ):
17 # It is a __future__ directive, not a symbol.
18 continue
19
20 # Do not take in account redefined names for the purpose
21 # of type checking.:
22 if any(
23 in_type_checking_block(definition) for definition in globs[name]
24 ):
25 continue
26
27 line = definition.fromlineno
28 if not self._is_name_ignored(stmt, name):
29 self.add_message(
30 "redefined-outer-name", args=(name, line), node=stmt
31 )
32
33 elif (
34 utils.is_builtin(name)
35 and not self._allowed_redefined_builtin(name)
36 and not self._should_ignore_redefined_builtin(stmt)
37 ):
38 # do not print Redefining builtin for additional builtins
39 self.add_message("redefined-builtin", args=name, node=stmt)
Path 5: 14 calls (0.0)
FunctionDef (14)
1def visit_functiondef(self, node: nodes.FunctionDef) -> None:
2 """Visit function: update consumption analysis variable and check locals."""
3 self._to_consume.append(NamesConsumer(node, "function"))
4 if not (
5 self.linter.is_message_enabled("redefined-outer-name")
6 or self.linter.is_message_enabled("redefined-builtin")
7 ):
8 return
9 globs = node.root().globals
10 for name, stmt in node.items():
11 if name in globs and not isinstance(stmt, nodes.Global):
12 definition = globs[name][0]
13 if (
14 isinstance(definition, nodes.ImportFrom)
15 and definition.modname == FUTURE
16 ):
17 # It is a __future__ directive, not a symbol.
18 continue
19
20 # Do not take in account redefined names for the purpose
21 # of type checking.:
22 if any(
23 in_type_checking_block(definition) for definition in globs[name]
24 ):
25 continue
26
27 line = definition.fromlineno
28 if not self._is_name_ignored(stmt, name):
29 self.add_message(
30 "redefined-outer-name", args=(name, line), node=stmt
31 )
32
33 elif (
34 utils.is_builtin(name)
35 and not self._allowed_redefined_builtin(name)
36 and not self._should_ignore_redefined_builtin(stmt)
37 ):
38 # do not print Redefining builtin for additional builtins
39 self.add_message("redefined-builtin", args=name, node=stmt)
Path 6: 2 calls (0.0)
FunctionDef (2)
1def visit_functiondef(self, node: nodes.FunctionDef) -> None:
2 """Visit function: update consumption analysis variable and check locals."""
3 self._to_consume.append(NamesConsumer(node, "function"))
4 if not (
5 self.linter.is_message_enabled("redefined-outer-name")
6 or self.linter.is_message_enabled("redefined-builtin")
7 ):
8 return
9 globs = node.root().globals
10 for name, stmt in node.items():
11 if name in globs and not isinstance(stmt, nodes.Global):
12 definition = globs[name][0]
13 if (
14 isinstance(definition, nodes.ImportFrom)
15 and definition.modname == FUTURE
16 ):
17 # It is a __future__ directive, not a symbol.
18 continue
19
20 # Do not take in account redefined names for the purpose
21 # of type checking.:
22 if any(
23 in_type_checking_block(definition) for definition in globs[name]
24 ):
25 continue
26
27 line = definition.fromlineno
28 if not self._is_name_ignored(stmt, name):
29 self.add_message(
30 "redefined-outer-name", args=(name, line), node=stmt
31 )
32
33 elif (
34 utils.is_builtin(name)
35 and not self._allowed_redefined_builtin(name)
36 and not self._should_ignore_redefined_builtin(stmt)
37 ):
38 # do not print Redefining builtin for additional builtins
39 self.add_message("redefined-builtin", args=name, node=stmt)
Path 7: 1 calls (0.0)
FunctionDef (1)
1def visit_functiondef(self, node: nodes.FunctionDef) -> None:
2 """Visit function: update consumption analysis variable and check locals."""
3 self._to_consume.append(NamesConsumer(node, "function"))
4 if not (
5 self.linter.is_message_enabled("redefined-outer-name")
6 or self.linter.is_message_enabled("redefined-builtin")
7 ):
8 return
9 globs = node.root().globals
10 for name, stmt in node.items():
11 if name in globs and not isinstance(stmt, nodes.Global):
12 definition = globs[name][0]
13 if (
14 isinstance(definition, nodes.ImportFrom)
15 and definition.modname == FUTURE
16 ):
17 # It is a __future__ directive, not a symbol.
18 continue
19
20 # Do not take in account redefined names for the purpose
21 # of type checking.:
22 if any(
23 in_type_checking_block(definition) for definition in globs[name]
24 ):
25 continue
26
27 line = definition.fromlineno
28 if not self._is_name_ignored(stmt, name):
29 self.add_message(
30 "redefined-outer-name", args=(name, line), node=stmt
31 )
32
33 elif (
34 utils.is_builtin(name)
35 and not self._allowed_redefined_builtin(name)
36 and not self._should_ignore_redefined_builtin(stmt)
37 ):
38 # do not print Redefining builtin for additional builtins
39 self.add_message("redefined-builtin", args=name, node=stmt)
Path 8: 1 calls (0.0)
FunctionDef (1)
GeneratorExit (1)
1def visit_functiondef(self, node: nodes.FunctionDef) -> None:
2 """Visit function: update consumption analysis variable and check locals."""
3 self._to_consume.append(NamesConsumer(node, "function"))
4 if not (
5 self.linter.is_message_enabled("redefined-outer-name")
6 or self.linter.is_message_enabled("redefined-builtin")
7 ):
8 return
9 globs = node.root().globals
10 for name, stmt in node.items():
11 if name in globs and not isinstance(stmt, nodes.Global):
12 definition = globs[name][0]
13 if (
14 isinstance(definition, nodes.ImportFrom)
15 and definition.modname == FUTURE
16 ):
17 # It is a __future__ directive, not a symbol.
18 continue
19
20 # Do not take in account redefined names for the purpose
21 # of type checking.:
22 if any(
23 in_type_checking_block(definition) for definition in globs[name]
24 ):
25 continue
26
27 line = definition.fromlineno
28 if not self._is_name_ignored(stmt, name):
29 self.add_message(
30 "redefined-outer-name", args=(name, line), node=stmt
31 )
32
33 elif (
34 utils.is_builtin(name)
35 and not self._allowed_redefined_builtin(name)
36 and not self._should_ignore_redefined_builtin(stmt)
37 ):
38 # do not print Redefining builtin for additional builtins
39 self.add_message("redefined-builtin", args=name, node=stmt)
Path 9: 1 calls (0.0)
FunctionDef (1)
GeneratorExit (1)
1def visit_functiondef(self, node: nodes.FunctionDef) -> None:
2 """Visit function: update consumption analysis variable and check locals."""
3 self._to_consume.append(NamesConsumer(node, "function"))
4 if not (
5 self.linter.is_message_enabled("redefined-outer-name")
6 or self.linter.is_message_enabled("redefined-builtin")
7 ):
8 return
9 globs = node.root().globals
10 for name, stmt in node.items():
11 if name in globs and not isinstance(stmt, nodes.Global):
12 definition = globs[name][0]
13 if (
14 isinstance(definition, nodes.ImportFrom)
15 and definition.modname == FUTURE
16 ):
17 # It is a __future__ directive, not a symbol.
18 continue
19
20 # Do not take in account redefined names for the purpose
21 # of type checking.:
22 if any(
23 in_type_checking_block(definition) for definition in globs[name]
24 ):
25 continue
26
27 line = definition.fromlineno
28 if not self._is_name_ignored(stmt, name):
29 self.add_message(
30 "redefined-outer-name", args=(name, line), node=stmt
31 )
32
33 elif (
34 utils.is_builtin(name)
35 and not self._allowed_redefined_builtin(name)
36 and not self._should_ignore_redefined_builtin(stmt)
37 ):
38 # do not print Redefining builtin for additional builtins
39 self.add_message("redefined-builtin", args=name, node=stmt)
Path 10: 1 calls (0.0)
FunctionDef (1)
1def visit_functiondef(self, node: nodes.FunctionDef) -> None:
2 """Visit function: update consumption analysis variable and check locals."""
3 self._to_consume.append(NamesConsumer(node, "function"))
4 if not (
5 self.linter.is_message_enabled("redefined-outer-name")
6 or self.linter.is_message_enabled("redefined-builtin")
7 ):
8 return
9 globs = node.root().globals
10 for name, stmt in node.items():
11 if name in globs and not isinstance(stmt, nodes.Global):
12 definition = globs[name][0]
13 if (
14 isinstance(definition, nodes.ImportFrom)
15 and definition.modname == FUTURE
16 ):
17 # It is a __future__ directive, not a symbol.
18 continue
19
20 # Do not take in account redefined names for the purpose
21 # of type checking.:
22 if any(
23 in_type_checking_block(definition) for definition in globs[name]
24 ):
25 continue
26
27 line = definition.fromlineno
28 if not self._is_name_ignored(stmt, name):
29 self.add_message(
30 "redefined-outer-name", args=(name, line), node=stmt
31 )
32
33 elif (
34 utils.is_builtin(name)
35 and not self._allowed_redefined_builtin(name)
36 and not self._should_ignore_redefined_builtin(stmt)
37 ):
38 # do not print Redefining builtin for additional builtins
39 self.add_message("redefined-builtin", args=name, node=stmt)