Method: pylint.checkers.imports.ImportsChecker._check_position
Calls: 1075, Exceptions: 0, Paths: 3Back
Path 1: 927 calls (0.86)
ImportFrom (503) Import (424)
1def _check_position(self, node: ImportNode) -> None:
2 """Check `node` import or importfrom node position is correct.
3
4 Send a message if `node` comes before another instruction
5 """
6 # if a first non-import instruction has already been encountered,
7 # it means the import comes after it and therefore is not well placed
8 if self._first_non_import_node:
9 if self.linter.is_message_enabled(
10 "wrong-import-position", self._first_non_import_node.fromlineno
11 ):
12 self.add_message(
13 "wrong-import-position", node=node, args=node.as_string()
14 )
15 else:
16 self.linter.add_ignored_message(
17 "wrong-import-position", node.fromlineno, node
18 )
Path 2: 111 calls (0.1)
ImportFrom (61) Import (50)
1def _check_position(self, node: ImportNode) -> None:
2 """Check `node` import or importfrom node position is correct.
3
4 Send a message if `node` comes before another instruction
5 """
6 # if a first non-import instruction has already been encountered,
7 # it means the import comes after it and therefore is not well placed
8 if self._first_non_import_node:
9 if self.linter.is_message_enabled(
10 "wrong-import-position", self._first_non_import_node.fromlineno
11 ):
12 self.add_message(
13 "wrong-import-position", node=node, args=node.as_string()
14 )
15 else:
16 self.linter.add_ignored_message(
17 "wrong-import-position", node.fromlineno, node
18 )
Path 3: 37 calls (0.03)
Import (29) ImportFrom (8)
1def _check_position(self, node: ImportNode) -> None:
2 """Check `node` import or importfrom node position is correct.
3
4 Send a message if `node` comes before another instruction
5 """
6 # if a first non-import instruction has already been encountered,
7 # it means the import comes after it and therefore is not well placed
8 if self._first_non_import_node:
9 if self.linter.is_message_enabled(
10 "wrong-import-position", self._first_non_import_node.fromlineno
11 ):
12 self.add_message(
13 "wrong-import-position", node=node, args=node.as_string()
14 )
15 else:
16 self.linter.add_ignored_message(
17 "wrong-import-position", node.fromlineno, node
18 )