diff --git a/.vscode/settings.json b/.vscode/settings.json index f92e9fdb..28fac4fe 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -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}/**" -} \ No newline at end of file + "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" +} diff --git a/pyproject.toml b/pyproject.toml index e468add8..818d3688 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,2 +1,25 @@ [tool.pyright] -include = ["yaku-apps-python"] \ No newline at end of file +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", + +] diff --git a/yaku-apps-python/README.md b/yaku-apps-python/README.md index 1c8e3572..10bf4434 100644 --- a/yaku-apps-python/README.md +++ b/yaku-apps-python/README.md @@ -20,7 +20,6 @@ 2. or use 3. or use Aspect rules: * How can we debug with VS Code or other remote debugging tools? -* Can we somehow ignore the `BUILD` files from pants? ## Development instructions @@ -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.