diff --git a/tools/chpl-language-server/src/chpl-language-server.py b/tools/chpl-language-server/src/chpl-language-server.py index ee3281e878fe..0e3902746128 100755 --- a/tools/chpl-language-server/src/chpl-language-server.py +++ b/tools/chpl-language-server/src/chpl-language-server.py @@ -152,6 +152,7 @@ chplcheck_path = os.path.join(chpl_home, "tools", "chplcheck", "src") # Add chplcheck to the path, but load via importlib sys.path.append(chplcheck_path) + def load_module(module_name: str): file_path = os.path.join(chplcheck_path, module_name + ".py") spec = importlib.util.spec_from_file_location(module_name, file_path) @@ -163,6 +164,7 @@ def load_module(module_name: str): raise ValueError(f"Could not load module from {file_path}") spec.loader.exec_module(module) return module + chplcheck = load_module("chplcheck") chplcheck_lsp = load_module("lsp") chplcheck_config = load_module("config") @@ -992,7 +994,6 @@ def add_bool_flag(name: str, dest: str, default: bool): if chplcheck_config: chplcheck_config.Config.add_arguments(self.parser, "chplcheck-") - def _parse_end_markers(self): self.args["end_markers"] = [ a.strip() for a in self.args["end_markers"].split(",") @@ -1069,7 +1070,14 @@ def _setup_linter(self, clsConfig: CLSConfig): """ Setup the linter, if it is enabled """ - if not (self.do_linting and chplcheck and chplcheck_lsp and chplcheck_config and chplcheck_driver and chplcheck_rules): + if not ( + self.do_linting + and chplcheck + and chplcheck_lsp + and chplcheck_config + and chplcheck_driver + and chplcheck_rules + ): return config = chplcheck_config.Config.from_args(clsConfig.args) @@ -1083,7 +1091,6 @@ def _setup_linter(self, clsConfig: CLSConfig): self.lint_driver.disable_rules(*config.disabled_rules) self.lint_driver.enable_rules(*config.enabled_rules) - def get_deprecation_replacement( self, text: str ) -> Tuple[Optional[str], Optional[str]]: @@ -1197,7 +1204,9 @@ def build_diagnostics(self, uri: str) -> List[Diagnostic]: # get lint diagnostics if applicable if self.lint_driver: assert chplcheck_lsp - lint_diagnostics = chplcheck_lsp.get_lint_diagnostics(fi.context.context, self.lint_driver, fi.get_asts()) + lint_diagnostics = chplcheck_lsp.get_lint_diagnostics( + fi.context.context, self.lint_driver, fi.get_asts() + ) diagnostics.extend(lint_diagnostics) return diagnostics @@ -1758,7 +1767,9 @@ async def code_action(ls: ChapelLanguageServer, params: CodeActionParams): # get lint fixits if applicable if ls.lint_driver: assert chplcheck_lsp - lint_actions = chplcheck_lsp.get_lint_actions(params.context.diagnostics) + lint_actions = chplcheck_lsp.get_lint_actions( + params.context.diagnostics + ) actions.extend(lint_actions) return actions diff --git a/tools/chplcheck/src/driver.py b/tools/chplcheck/src/driver.py index 1060724ec1a5..f456930ca762 100644 --- a/tools/chplcheck/src/driver.py +++ b/tools/chplcheck/src/driver.py @@ -109,7 +109,9 @@ def _should_check_rule( def _has_internal_name(self, node: chapel.AstNode): if not hasattr(node, "name"): return False - return any(node.name().startswith(p) for p in self.config.internal_prefixes) + return any( + node.name().startswith(p) for p in self.config.internal_prefixes + ) @staticmethod def _is_unstable_module(node: chapel.AstNode): @@ -202,7 +204,9 @@ def _check_advanced_rule( # so we can't stop it from going into unstable modules. Instead, # once the rule emits a warning, check by traversing the AST # if the warning target should be skipped. - if self.config.skip_unstable and LintDriver._in_unstable_module(node): + if self.config.skip_unstable and LintDriver._in_unstable_module( + node + ): continue yield (node, name, fixits)