Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return early if Python version check fails #517

Merged
merged 1 commit into from
Jul 5, 2024

Conversation

dhruvmanila
Copy link
Member

@dhruvmanila dhruvmanila commented Jul 5, 2024

Summary

This is a follow-up from #516 and adopted from microsoft/vscode-python-tools-extension-template@723f297.

Test Plan

Same test plan as #516 but validate that the script failure doesn't occur now that we exit early.

@dhruvmanila dhruvmanila marked this pull request as ready for review July 5, 2024 04:01
@dhruvmanila dhruvmanila added the bug Something isn't working label Jul 5, 2024
dhruvmanila added a commit that referenced this pull request Jul 5, 2024
## Summary

I'm not sure why this check was removed looking back at
#431, but this validation
should be done for both native server and `ruff-lsp`. Both uses a Python
script which requires Python 3.7 or later and `ruff` in general also
supports 3.7 and later.

Without this change, if someone were to use Python 3.6, the extension
would give the following error:
```
2024-07-05 09:26:21.378 [error] Error while trying to find the Ruff binary: Error: Command failed: /Users/dhruv/.pyenv/versions/3.6.15/bin/python /Users/dhruv/work/astral/ruff-vscode/bundled/tool/find_ruff_binary_path.py
Traceback (most recent call last):
  File "/Users/dhruv/work/astral/ruff-vscode/bundled/tool/find_ruff_binary_path.py", line 33, in <module>
    ruff_binary_path = find_ruff_binary_path()
  File "/Users/dhruv/work/astral/ruff-vscode/bundled/tool/find_ruff_binary_path.py", line 20, in find_ruff_binary_path
    elif sys.platform == "darwin" and sys._framework:
AttributeError: module 'sys' has no attribute '_framework'
```

## Test Plan

The above error still occurs and the fix for that is in a follow-up PR
(#517).

Using the below settings:
```json
{
  "ruff.nativeServer":true,
  "ruff.interpreter": ["/Users/dhruv/.pyenv/versions/3.6.15/bin/python"]
}
```

The logs shows that the version isn't supported:
```
2024-07-05 09:27:38.086 [error] Python version 3.6 is not supported.
2024-07-05 09:27:38.086 [error] Selected python path: /Users/dhruv/.pyenv/versions/3.6.15/bin/python
2024-07-05 09:27:38.086 [error] Supported versions are 3.7 and above.
```
Base automatically changed from dhruv/python-version-check to main July 5, 2024 11:36
@dhruvmanila dhruvmanila force-pushed the dhruv/python-version-check-2 branch from af924b0 to e048d71 Compare July 5, 2024 11:36
@dhruvmanila dhruvmanila merged commit e665ec7 into main Jul 5, 2024
6 checks passed
@dhruvmanila dhruvmanila deleted the dhruv/python-version-check-2 branch July 5, 2024 11:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants