Skip to content

Refactor: add RunResult exit_code and align lsp_runner sys.path#623

Merged
edvilme merged 1 commit intomainfrom
phase4/runresult-runner-alignment
Apr 9, 2026
Merged

Refactor: add RunResult exit_code and align lsp_runner sys.path#623
edvilme merged 1 commit intomainfrom
phase4/runresult-runner-alignment

Conversation

@edvilme
Copy link
Copy Markdown
Contributor

@edvilme edvilme commented Apr 7, 2026

Summary

Two small refactors to align isort's bundled tool infrastructure with the upstream extension template and sibling extensions (black, flake8, pylint).

Change 1: RunResult.exit_code (lsp_utils.py)

Add an \�xit_code: Optional[Union[int, str]] = None\ parameter to \RunResult.init, matching mypy's implementation pattern. The default of \None\ keeps this fully backward-compatible — all existing callers continue to work unchanged.

Change 2: lsp_runner.py sys.path setup

Add the missing \ ool\ directory to \sys.path\ via a new \BUNDLE_DIR\ variable, matching the pattern used by black, flake8, and pylint runners. Isort's runner was the only one missing this path entry, which could cause import failures when the runner is invoked under a different interpreter.


Part of #620
Ref: microsoft/vscode-python-tools-extension-template#290

@edvilme edvilme added the debt Code quality issues label Apr 7, 2026
@edvilme edvilme requested a review from rchiodo April 7, 2026 21:57
1. Add Optional[Union[int, str]] exit_code parameter with None default to RunResult,
   matching mypy's implementation. Backward-compatible.

2. Add BUNDLE_DIR variable and 'tool' path to lsp_runner.py sys.path setup,
   matching black/flake8/pylint pattern. Isort was missing the tool directory.

Part of #620
Ref: microsoft/vscode-python-tools-extension-template#290

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@edvilme edvilme force-pushed the phase4/runresult-runner-alignment branch from 2d53240 to 2127fed Compare April 9, 2026 20:12
@edvilme
Copy link
Copy Markdown
Contributor Author

edvilme commented Apr 9, 2026

Both comments addressed: (1) exit_code tightened to Optional[int] since isort uses subprocess. Applied same fix to black #700 and flake8 #468. (2) lsp_runner comment updated to clarify why tool path is always bundled.

@edvilme edvilme requested a review from rchiodo April 9, 2026 20:15
Copy link
Copy Markdown
Contributor

@rchiodo rchiodo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved via Review Center.

@edvilme edvilme merged commit 4b33601 into main Apr 9, 2026
20 checks passed
@edvilme edvilme deleted the phase4/runresult-runner-alignment branch April 9, 2026 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

debt Code quality issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants