🔄 Template Sync Required
Changes from the upstream vscode-python-tools-extension-template have not yet been incorporated into this repository.
Source PR
Summary
The template replaced bare try: ... except SomeException: pass patterns with the idiomatic contextlib.suppress(SomeException) context manager in bundled/tool/lsp_utils.py. This improves readability and avoids bare-except pylint warnings.
Files with missing changes
-
bundled/tool/lsp_utils.py: The _run_api function still uses the old try/except SystemExit: pass pattern.
Note: _run_module's except SystemExit as ex: block was intentionally kept as-is since it captures exit_code = ex.code (mypy-specific behavior that cannot be replaced with suppress).
Suggested fix
--- a/bundled/tool/lsp_utils.py
+++ b/bundled/tool/lsp_utils.py
@@ -... @@
def _run_api(...) -> RunResult:
str_output = None
str_error = None
- try:
+ with contextlib.suppress(SystemExit):
with substitute_attr(sys, "argv", argv):
if use_stdin and source is not None:
str_input = CustomIO("(stdin)", encoding="utf-8", newline="\n")
with redirect_io("stdin", str_input):
str_input.write(source)
str_input.seek(0)
str_output, str_error, exit_code = callback(argv, str_input)
else:
str_output, str_error, exit_code = callback(argv, None)
- except SystemExit:
- pass
return RunResult(str_output, str_error, exit_code)
You will also need to ensure import contextlib is present at the top of lsp_utils.py (it is already imported for change_cwd).
Files skipped
bundled/tool/lsp_jsonrpc.py: This file does not exist in this repository (the template's lsp_jsonrpc.py changes are not applicable here).
🤖 This issue was auto-generated by the extension-template-sync workflow.
Generated by Extension Template Sync
🔄 Template Sync Required
Changes from the upstream vscode-python-tools-extension-template have not yet been incorporated into this repository.
Source PR
contextlib.suppressinstead of try-except-passSummary
The template replaced bare
try: ... except SomeException: passpatterns with the idiomaticcontextlib.suppress(SomeException)context manager inbundled/tool/lsp_utils.py. This improves readability and avoids bare-except pylint warnings.Files with missing changes
bundled/tool/lsp_utils.py: The_run_apifunction still uses the oldtry/except SystemExit: passpattern.Note:
_run_module'sexcept SystemExit as ex:block was intentionally kept as-is since it capturesexit_code = ex.code(mypy-specific behavior that cannot be replaced withsuppress).Suggested fix
You will also need to ensure
import contextlibis present at the top oflsp_utils.py(it is already imported forchange_cwd).Files skipped
bundled/tool/lsp_jsonrpc.py: This file does not exist in this repository (the template'slsp_jsonrpc.pychanges are not applicable here).🤖 This issue was auto-generated by the
extension-template-syncworkflow.