Skip to content

Commit

Permalink
Update advice for VSCode setup (#163)
Browse files Browse the repository at this point in the history
Co-authored-by: Michael Franklin <illusional@users.noreply.github.com>
  • Loading branch information
illusional and illusional authored Aug 18, 2024
1 parent f747851 commit b325d55
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 26 deletions.
45 changes: 21 additions & 24 deletions code_editors.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,37 +16,34 @@ VSCode is the most prominent IDE at the centre as it very quickly supports langu

For Python, we recommend enabling the following settings:

- Black formatter (on save)
- Type Checking: strict (through your `settings.json`)
- Ruff
- iSort (configure the extra `black` mode in your `settings.json`)
- Type Checking: basic (or strict, through your `settings.json`)
- Ruff (by installing the ruff extension)
- Auto Import Completions: true (makes life so much easier)

Note that ruff should automatically pick up the `pyproject.toml` in the root of the project you're editing.

![Alt text](code_editors/python-settings.png)

Some cherry-picked `settings.json` options that might be handy:

```json
{
"python.analysis.typeCheckingMode": "strict",
"isort.args": [
"--profile=black"
"python.analysis.typeCheckingMode": "strict",
"[python]": {
"editor.formatOnType": true,
"editor.rulers": [
{
"column": 88,
"color": "#ff9900"
}
],
"[python]": {
"editor.formatOnType": true,
"editor.rulers": [
{
"column": 88,
"color": "#ff9900"
}
],
"editor.formatOnSave": true,
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit",
"source.fixAll": "explicit"
},
},

"editor.formatOnSave": true,
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit",
"source.fixAll": "explicit"
}
}
}
```

Expand Down Expand Up @@ -100,7 +97,7 @@ If you're working on Hail's Scala code, the setup is slightly different. Assumin

- Back in Visual Studio Code, run the _Metals: Import build_ command. This might take a few minutes to complete.
- Make sure everything worked out by running the _Metals: Run doctor_ command. It should look like this:
![Metals doctor](figures/metals_doctor.png)
![Metals doctor](figures/metals_doctor.png)

### Hail in PyCharm

Expand Down
Binary file modified code_editors/python-settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 1 addition & 2 deletions python.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ pyenv install 3.10.12
pyenv global 3.10.12
```


### Named virtual environments

If you like named virtual environments (rather than many `env/` directories in your repos), take inspiration from this snippet you could add to your `.zshrc` file:
Expand Down Expand Up @@ -77,4 +76,4 @@ due to some caveats with the use of `Optional` but also to keep the codebase sim

## Visual Studio Code

See [Code editors](code_editors.md#vscode---python) for more information on configuring Python in VSCode.
See [Code editors](code_editors.md) for more information on configuring Python in VSCode.

0 comments on commit b325d55

Please sign in to comment.