Method: pylint.lint.pylinter.PyLinter._check_file
Calls: 3, Exceptions: 0, Paths: 1Back
Path 1: 3 calls (1.0)
PyLinter.get_ast def (3)
partial (3)
FileItem (3)
1def _check_file(
2 self,
3 get_ast: GetAstProtocol,
4 check_astroid_module: Callable[[nodes.Module], bool | None],
5 file: FileItem,
6 ) -> None:
7 """Check a file using the passed utility functions (get_ast and
8 check_astroid_module).
9
10 :param callable get_ast: callable returning AST from defined file taking the following arguments
11 - filepath: path to the file to check
12 - name: Python module name
13 :param callable check_astroid_module: callable checking an AST taking the following arguments
14 - ast: AST of the module
15 :param FileItem file: data about the file
16 :raises AstroidError: for any failures stemming from astroid
17 """
18 self.set_current_module(file.name, file.filepath)
19 # get the module representation
20 ast_node = get_ast(file.filepath, file.name)
21 if ast_node is None:
22 return
23
24 self._ignore_file = False
25
26 self.file_state = FileState(file.modpath, self.msgs_store, ast_node)
27 # fix the current file (if the source file was not available or
28 # if it's actually a c extension)
29 self.current_file = ast_node.file
30 try:
31 check_astroid_module(ast_node)
32 except Exception as e: # pragma: no cover
33 raise astroid.AstroidError from e
34 # warn about spurious inline messages handling
35 spurious_messages = self.file_state.iter_spurious_suppression_messages(
36 self.msgs_store
37 )
38 for msgid, line, args in spurious_messages:
39 self.add_message(msgid, line, None, args)