Skip to content

Commit

Permalink
feat: Improve VS Code integration
Browse files Browse the repository at this point in the history
  • Loading branch information
wulmer committed Oct 18, 2024
1 parent 64528d1 commit b8d6cd1
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 4 deletions.
15 changes: 13 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,16 @@
"coverage-gutters.coverageFileNames": [
"bazel-out/_coverage/_coverage_report.dat"
],
"coverage-gutters.ignoredPathGlobs": "**/{node_modules,venv,.venv,vendor,bazel-bin,bazel-out,bazel-testlogs}/**"
}
"coverage-gutters.ignoredPathGlobs": "**/{node_modules,venv,.venv,vendor,bazel-bin,bazel-out,bazel-testlogs}/**",
"[python]": {
"diffEditor.ignoreTrimWhitespace": false,
"gitlens.codeLens.symbolScopes": [
"!Module"
],
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.formatOnType": true,
"editor.formatOnSave": false,
"editor.wordBasedSuggestions": "off"
},
"python.defaultInterpreterPath": "yaku-apps-python/3rdparty/.venv/bin/python"
}
25 changes: 24 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,25 @@
[tool.pyright]
include = ["yaku-apps-python"]
include = ["yaku-apps-python"]
extraPaths = [
"yaku-apps-python/packages/autopilot-utils/src",
"yaku-apps-python/packages/autopilot-utils/tests/app_multi_evaluator/src",
"yaku-apps-python/packages/autopilot-utils/tests/app_subprocess_steps/src",
"yaku-apps-python/packages/autopilot-utils/tests/app_single_evaluator/src",
"yaku-apps-python/packages/autopilot-utils/tests/app_multi_command/src",
"yaku-apps-python/packages/autopilot-utils/tests/app_chained_multi_evaluator/src",
"yaku-apps-python/packages/autopilot-utils/tests/demo_app/src",
"yaku-apps-python/packages/autopilot-utils/tests/app_super_simple_evaluator/src",
"yaku-apps-python/packages/autopilot-utils/tests/app_single_command/src",
"yaku-apps-python/apps/splunk-fetcher/src",
"yaku-apps-python/apps/sharepoint-fetcher/src",
"yaku-apps-python/apps/papsr/src",
"yaku-apps-python/apps/sharepoint/src",
"yaku-apps-python/apps/sharepoint-evaluator/src",
"yaku-apps-python/apps/pdf-signature-evaluator/src",
"yaku-apps-python/apps/filecheck/src",
"yaku-apps-python/apps/artifactory-fetcher/src",
"yaku-apps-python/apps/excel-tools/src",
"yaku-apps-python/apps/security-scanner/src",
"yaku-apps-python/apps/pex-tool/src",

]
34 changes: 33 additions & 1 deletion yaku-apps-python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
2. or use <https://philuvarov.io/bazel-can-be-ruff/>
3. or use Aspect rules: <https://github.com/aspect-build/rules_lint>
* How can we debug with VS Code or other remote debugging tools?
* Can we somehow ignore the `BUILD` files from pants?

## Development instructions

Expand Down Expand Up @@ -59,3 +58,36 @@ You will find the coverage report in <../htmlcov/index.html>.
```bash
bazel build //yaku-apps-python/packages/autopilot-utils:wheel
```

## IDE Integration (VS Code)

You need to tell the IDE where all the different Python packages are. This can be done in the `pyproject.toml` in
the root workspace folder.

Just add the paths received from `find yaku-apps-python -type d -name src` to the `extraPaths` list in the `pyproject.toml`.

## Extra virtual environment for VS Code auto-completion and linting

As VS Code doesn't know about the Python dependencies declared in Bazel for the different packages,
we can instead create a virtual environment with all the dependencies installed.

Then, we can point VS Code to this virtual environment for auto-completion and linting.

```bash
cd yaku-apps-python/3rdparty/
python3 -m venv .venv
.venv/bin/pip install -r requirements_lock.txt
```

Then, in VS Code, you can select this virtual environment as the Python interpreter.

If you have `uv` installed, you can do this of course with `uv`:

```bash
cd yaku-apps-python/3rdparty/
uv venv create
uv pip install -r requirements_lock.txt
```

Note: I got a build error in the pip install step, due to some build issue with pyyaml 6.0.
Perhaps other (older) versions of pyyaml work better.

0 comments on commit b8d6cd1

Please sign in to comment.