Open zpoint opened 2 weeks ago
Thanks @zpoint! I was testing it in one of my PR #4264 and trying to use the commit in vscode/cursor's GUI, but it seems the pre-commit hook was not triggered. Do you know how to get it work?
Did u put the .pre-commit-config.yaml
in your project root directory?
Open a terminal, cd to your project root, try command pre-commit
, it should output like my screenshots, if not check your $PATH
variable, the pre-commit
installed with the pip needs to be in your $PATH
Could you take a look when you have time? Thanks @Michaelvll
Fixing sky/jobs/controller.py
fix end of files.........................................................Passed
check yaml...........................................(no files to check)Skipped
check for added large files..............................................Passed
black................................................(no files to check)Skipped
isort....................................................................Passed
isort................................................(no files to check)Skipped
yapf.....................................................................Failed
- hook id: yapf
- files were modified by this hook
pylint...................................................................Passed
mypy.....................................................................Failed
- hook id: mypy
- exit code: 1
Executable `mypy` not found
Thanks @zpoint! Just realized that I did not install pre-commit in my python env. After installing it, it shows the above error for failing to find mypy
in VSCode/Cursor's git integration, although I do have mypy installed in my separate python env for skypilot. Is there away for the VSCode git integration to correctly pick up the env?
@Michaelvll
VSCode seems not to provide a way to configure the environment when you click the commit
on the GUI menu.
This issue is still opened for VSCode after 4 years.
The workaround is to start VSCode from the command line after you activate your environment; in this way, VSCode will carry all the environment variables from your command line.
If you are not using zsh
, refer to: how-to-open-cursor-from-terminal
# add this to the tail of your ~/.zshrc
function cursor {
open -a "/Applications/Cursor.app" "$@"
}
# activate my env
conda activate sky
# now, cursor will start with current env
cursor .
# Or you can activate your env inside the cursor function, then just type cursor will do
Install mypy
globally in the global Python environment, which is not elegant.
Step 1 install pre-commit
Step 2, now just run
git commit
. The command will use thepre-commit
hook on any unstaged file changesTested (run the relevant ones):
bash format.sh
pytest tests/test_smoke.py
pytest tests/test_smoke.py::test_fill_in_the_name
conda deactivate; bash -i tests/backward_compatibility_tests.sh