From 8bef1e948b18f4fc01548a71dc07c109aa55cf9f Mon Sep 17 00:00:00 2001 From: Sarthak Khattar Date: Wed, 9 Jun 2021 23:23:30 +0530 Subject: [PATCH] handle path being None --- client/commands/v2/pysa_server.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/client/commands/v2/pysa_server.py b/client/commands/v2/pysa_server.py index 26c13376757..2990021330e 100644 --- a/client/commands/v2/pysa_server.py +++ b/client/commands/v2/pysa_server.py @@ -91,9 +91,14 @@ def invalid_models_to_diagnostics( ) -> Dict[Path, List[lsp.Diagnostic]]: result: Dict[Path, List[lsp.Diagnostic]] = {} for model in invalid_models: - result.setdefault(Path(model.path), []).append( - self.invalid_model_to_diagnostic(model) - ) + if model.path is None: + self.log_and_show_message_to_client( + "Path cannot be None", lsp.MessageType.WARNING + ) + else: + result.setdefault(Path(model.path), []).append( + self.invalid_model_to_diagnostic(model) + ) return result async def update_errors(self, document_path: Path) -> None: