π 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 except: pass and except SystemExit: pass patterns with the idiomatic contextlib.suppress(...) context manager. This improves code clarity and eliminates pylint bare-except warnings.
Files with missing changes
bundled/tool/lsp_jsonrpc.py: Three bare-except blocks (except: # pylint: disable=bare-except followed by pass) in the close() and stop_all_processes() methods have not been replaced with contextlib.suppress(Exception). The import contextlib statement is also missing.
bundled/tool/lsp_utils.py: Two try...except SystemExit: pass blocks in _run_module() (line ~161) and _run_api() (line ~240) have not been replaced with with contextlib.suppress(SystemExit):.
Suggested fix
bundled/tool/lsp_jsonrpc.py β add import contextlib and replace bare-except blocks:
import atexit
+import contextlib
import io
def close(self):
"""Closes the underlying streams."""
- try:
+ with contextlib.suppress(Exception):
self._reader.close()
- except: # pylint: disable=bare-except
- pass
- try:
+ with contextlib.suppress(Exception):
self._writer.close()
- except: # pylint: disable=bare-except
- pass
def stop_all_processes(self):
"""Send exit command to all processes and shutdown transport."""
for i in self._rpc.values():
- try:
+ with contextlib.suppress(Exception):
i.send_data({"id": str(uuid.uuid4()), "method": "exit"})
- except: # pylint: disable=bare-except
- pass
self._thread_pool.shutdown(wait=False)
bundled/tool/lsp_utils.py β replace both except SystemExit: pass blocks (in _run_module and _run_api):
- try:
+ with contextlib.suppress(SystemExit):
with substitute_attr(sys, "argv", argv):
with redirect_io("stdout", str_output):
with redirect_io("stderr", str_error):
if use_stdin and source is not None:
...
else:
runpy.run_module(module, run_name="__main__")
- except SystemExit:
- pass
Apply the same pattern for the _run_api function.
Files skipped
src/test/python_tests/ β test files are tool-specific and don't need to be synced directly.
π€ 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
Summary
The template replaced bare
except: passandexcept SystemExit: passpatterns with the idiomaticcontextlib.suppress(...)context manager. This improves code clarity and eliminates pylint bare-except warnings.Files with missing changes
bundled/tool/lsp_jsonrpc.py: Three bare-except blocks (except: # pylint: disable=bare-exceptfollowed bypass) in theclose()andstop_all_processes()methods have not been replaced withcontextlib.suppress(Exception). Theimport contextlibstatement is also missing.bundled/tool/lsp_utils.py: Twotry...except SystemExit: passblocks in_run_module()(line ~161) and_run_api()(line ~240) have not been replaced withwith contextlib.suppress(SystemExit):.Suggested fix
bundled/tool/lsp_jsonrpc.pyβ addimport contextliband replace bare-except blocks:import atexit +import contextlib import iodef close(self): """Closes the underlying streams.""" - try: + with contextlib.suppress(Exception): self._reader.close() - except: # pylint: disable=bare-except - pass - try: + with contextlib.suppress(Exception): self._writer.close() - except: # pylint: disable=bare-except - passdef stop_all_processes(self): """Send exit command to all processes and shutdown transport.""" for i in self._rpc.values(): - try: + with contextlib.suppress(Exception): i.send_data({"id": str(uuid.uuid4()), "method": "exit"}) - except: # pylint: disable=bare-except - pass self._thread_pool.shutdown(wait=False)bundled/tool/lsp_utils.pyβ replace bothexcept SystemExit: passblocks (in_run_moduleand_run_api):Apply the same pattern for the
_run_apifunction.Files skipped
src/test/python_tests/β test files are tool-specific and don't need to be synced directly.π€ This issue was auto-generated by the
extension-template-syncworkflow.