-
-
Notifications
You must be signed in to change notification settings - Fork 28.5k
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
Fix ruff version conflict in vscode devcontainer #117569
Conversation
.devcontainer/devcontainer.json
Outdated
@@ -50,7 +50,8 @@ | |||
], | |||
"[python]": { | |||
"editor.defaultFormatter": "charliermarsh.ruff" | |||
} | |||
}, | |||
"ruff.path": ["/home/vscode/.local/bin/ruff"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to set this instead:
"ruff.importStrategy": "fromEnvironment"
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"ruff.importStrategy": "fromEnvironment"
doesn't work for me.
=> it uses 0.4.1 from /usr/local/bin/ruff
"ruff.importStrategy": "useBundled"
doesn't work either
=> it uses 0.4.1 from /home/vscode/.vscode-server/extensions/charliermarsh.ruff-2024.20.0-linux-x64/bundled/libs/bin/ruff
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sounds like you haven't set / used the environment/interpreter in vscode?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on further discussions on discord, it looks like the issue stems from ruff being installed once as root (as part of Dev Container creation) then again as regular user.
vscode ➜ /workspaces/home-assistant-core (20240516-1644) $ sudo ruff --version
ruff 0.4.1
vscode ➜ /workspaces/home-assistant-core (20240516-1644) $ ruff --version
ruff 0.4.4
So maybe this needs further thought - any help is welcome.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we not install it as root?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, ruff gets installed as part of requirements_test_pre_commit.txt
, which in included in requirements_test.txt
It gets installed three times:
- first, from
dockerfile.dev
viaLine 51 in bbf8633
RUN pip3 install -r requirements_test.txt - second, from
"postCreateCommand": "script/setup"
indevcontainer.json
viaLine 24 in bbfc245
script/bootstrap - third, from
"postStartCommand": "script/bootstrap"
indevcontainer.json
viaLine 12 in 1589226
python3 -m pip install -r requirements_test.txt -c homeassistant/package_constraints.txt --upgrade
If I remove the corresponding lines from dockerfile.dev
and rebuild the container, then ruff
only gets installed as regular user, and it uses the correct version.
vscode ➜ /workspaces/home-assistant-core (20240516-1644) $ whereis ruff
ruff: /home/vscode/.local/bin/ruff
I've tested this a few times - kept hitting issues with permissions, tried some ugly hacks, but I think this is good now. |
Proposed change
Based on discussion with @balloob and @autinerd on Discord
The vscode extension ships with an older version of ruff, which causes conflict with the required version in
pyproject.toml
.Type of change
Additional information
Checklist
ruff format homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.To help with the load of incoming pull requests: