From 22c475c9745a301861ed34396c92aaf637c79a7e Mon Sep 17 00:00:00 2001 From: d-eigo-hara Date: Fri, 9 Jan 2026 10:57:35 +0000 Subject: [PATCH 1/5] fix: devcontainer settings --- .devcontainer/devcontainer.json | 15 ++++++++++++++- .vscode/settings.json | 6 +++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 935bcd0..8de6cfe 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -6,6 +6,18 @@ "vscode" ], "workspaceFolder": "/workspace", + "mounts": [ + { + "source": "venv-${devcontainerId}", + "target": "${containerWorkspaceFolder}/.venv", + "type": "volume" + }, + { + "source": "${localEnv:HOME}/.ssh", + "target": "/home/${remoteUser}/.ssh", + "type": "bind" + } + ], "features": { "ghcr.io/dhoeric/features/hadolint:1": {} }, @@ -33,8 +45,9 @@ }, "containerEnv": { "DISPLAY": "dummy", - "UV_PROJECT_ENVIRONMENT": "/home/vscode/.venv" + "UV_PROJECT_ENVIRONMENT": "${containerWorkspaceFolder}/.venv" }, + "updateContentCommand": "sudo chown -R vscode ${containerWorkspaceFolder}/.venv /home/${remoteUser}/.ssh", "postCreateCommand": "uv sync --frozen", "postStartCommand": "uv run pre-commit install", "remoteUser": "vscode" diff --git a/.vscode/settings.json b/.vscode/settings.json index f7e8fdb..2e2a9c5 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -6,7 +6,7 @@ "notebook.source.organizeImports": "explicit" }, "notebook.formatOnSave.enabled": true, - "python.defaultInterpreterPath": "/home/vscode/.venv/bin/python", + "python.defaultInterpreterPath": ".venv/bin/python", "python.languageServer": "None", "python.testing.autoTestDiscoverOnSaveEnabled": false, "python.testing.pytestEnabled": true, @@ -14,8 +14,8 @@ "tests" ], "python.testing.unittestEnabled": false, - "sqlfluff.config": "${workspaceFolder}/.sqlfluff", - "sqlfluff.executablePath": "/home/vscode/.venv/bin/sqlfluff", + "sqlfluff.config": ".sqlfluff", + "sqlfluff.executablePath": ".venv/bin/sqlfluff", "sqlfluff.format.enabled": true, "sqlfluff.linter.run": "onType", "terminal.integrated.defaultProfile.linux": "zsh", From 618c26bb367807fa73708b97b7d086fb82b63fc4 Mon Sep 17 00:00:00 2001 From: d-eigo-hara Date: Fri, 9 Jan 2026 11:03:32 +0000 Subject: [PATCH 2/5] fix: named volume for cache --- .devcontainer/devcontainer.json | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 8de6cfe..6f6659c 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -7,6 +7,11 @@ ], "workspaceFolder": "/workspace", "mounts": [ + { + "source": "cache-${devcontainerId}", + "target": "/home/${remoteUser}/.cache", + "type": "volume" + }, { "source": "venv-${devcontainerId}", "target": "${containerWorkspaceFolder}/.venv", @@ -47,7 +52,7 @@ "DISPLAY": "dummy", "UV_PROJECT_ENVIRONMENT": "${containerWorkspaceFolder}/.venv" }, - "updateContentCommand": "sudo chown -R vscode ${containerWorkspaceFolder}/.venv /home/${remoteUser}/.ssh", + "updateContentCommand": "sudo chown -R vscode /home/${remoteUser}/.cache ${containerWorkspaceFolder}/.venv /home/${remoteUser}/.ssh", "postCreateCommand": "uv sync --frozen", "postStartCommand": "uv run pre-commit install", "remoteUser": "vscode" From f6d0813bd90d6107e41dd1a3ce976325440f98e1 Mon Sep 17 00:00:00 2001 From: d-eigo-hara Date: Fri, 9 Jan 2026 11:04:13 +0000 Subject: [PATCH 3/5] update: docs --- docs/configurations/ruff.md | 20 +++++++++---- docs/configurations/uv.md | 59 +++++++++++++++++++++++++++++-------- docs/usecases/jupyter.md | 2 +- 3 files changed, 62 insertions(+), 19 deletions(-) diff --git a/docs/configurations/ruff.md b/docs/configurations/ruff.md index a571980..8a74770 100644 --- a/docs/configurations/ruff.md +++ b/docs/configurations/ruff.md @@ -20,7 +20,7 @@ The Ruff formatter is an extremely fast Python code formatter designed as a drop They are set as default in this repository. === "ruff.toml" - ```{.toml hl_lines=42-57} + ```{.toml hl_lines=42-58 81-83} # Exclude a variety of commonly ignored directories. exclude = [ ".bzr", @@ -73,6 +73,7 @@ The Ruff formatter is an extremely fast Python code formatter designed as a drop "E117", "ISC001", "ISC002", + "PLC0415", "Q000", "Q001", "Q002", @@ -99,11 +100,15 @@ The Ruff formatter is an extremely fast Python code formatter designed as a drop # Like Black, automatically detect the appropriate line ending. line-ending = "auto" + + [lint.per-file-ignores] + # Ignore all directories named `tests`. + "tests/**" = ["INP001", "S101"] ``` === "pyproject.toml" - ```{.toml hl_lines=43-58} + ```{.toml hl_lines=43-59 82-84} [tool.ruff] # Exclude a variety of commonly ignored directories. exclude = [ @@ -139,8 +144,8 @@ The Ruff formatter is an extremely fast Python code formatter designed as a drop line-length = 88 indent-width = 4 - # Assume Python 3.12 - target-version = "py312" + # Assume Python 3.14 + target-version = "py314" [tool.ruff.lint] # Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default. @@ -157,6 +162,7 @@ The Ruff formatter is an extremely fast Python code formatter designed as a drop "E117", "ISC001", "ISC002", + "PLC0415", "Q000", "Q001", "Q002", @@ -183,13 +189,17 @@ The Ruff formatter is an extremely fast Python code formatter designed as a drop # Like Black, automatically detect the appropriate line ending. line-ending = "auto" + + [tool.ruff.lint.per-file-ignores] + # Ignore all directories named `tests`. + "tests/**" = ["INP001", "S101"] ``` ## extensions.json The following settings are required for automatic formatting on VSCode. ```{.json title=".vscode/extensions.json" } { - "python.defaultInterpreterPath": "/home/vscode/.venv/bin/python", + "python.defaultInterpreterPath": ".venv/bin/python", "[python]": { "editor.codeActionsOnSave": { "source.fixAll": "explicit", diff --git a/docs/configurations/uv.md b/docs/configurations/uv.md index 88cf336..544b1da 100644 --- a/docs/configurations/uv.md +++ b/docs/configurations/uv.md @@ -6,45 +6,78 @@ ## Virtual Environment Set the `UV_PROJECT_ENVIRONMENT` not to create a virtual environment in the project directory. -```{.dockerfile title=".devcontainer/Dockerfile" hl_lines="34"} +```json title=".devcontainer/devcontainer.json" hl_lines="48 10-19 50" { "name": "uv", - "build": { - "context": "..", - "dockerfile": "Dockerfile", - "args": { - "UV_VERSION": "0.5.11", - "DEBIAN_VERSION": "bookworm" + "dockerComposeFile": "../.devcontainer/docker-compose.yml", + "service": "vscode", + "runServices": [ + "vscode" + ], + "workspaceFolder": "/workspace", + "mounts": [ + { + "source": "cache-${devcontainerId}", + "target": "/home/${remoteUser}/.cache", + "type": "volume" + }, + { + "source": "venv-${devcontainerId}", + "target": "${containerWorkspaceFolder}/.venv", + "type": "volume" + }, + { + "source": "${localEnv:HOME}/.ssh", + "target": "/home/${remoteUser}/.ssh", + "type": "bind" } - }, + ], "features": { "ghcr.io/dhoeric/features/hadolint:1": {} }, "customizations": { "vscode": { "extensions": [ + "astral-sh.ty", "charliermarsh.ruff", + "dorzey.vscode-sqlfluff", "exiasr.hadolint", "kevinrose.vsc-python-indent", "mosapride.zenkaku", "ms-azuretools.vscode-docker", "ms-python.python", + "ms-python.vscode-pylance", + "ms-toolsai.jupyter", "njpwerner.autodocstring", "redhat.vscode-yaml", "shardulm94.trailing-spaces", - "tamasfe.even-better-toml" + "streetsidesoftware.code-spell-checker", + "tamasfe.even-better-toml", + "yzhang.markdown-all-in-one" ] } }, "containerEnv": { "DISPLAY": "dummy", - "PYTHONUNBUFFERED": "True", - "UV_LINK_MODE": "copy", - "UV_PROJECT_ENVIRONMENT": "/home/vscode/.venv" + "UV_PROJECT_ENVIRONMENT": "${containerWorkspaceFolder}/.venv" }, + "updateContentCommand": "sudo chown -R vscode ${containerWorkspaceFolder}/.venv /home/${remoteUser}/.ssh", "postCreateCommand": "uv sync --frozen", "postStartCommand": "uv run pre-commit install", "remoteUser": "vscode" } - ``` + +### Key Configuration Details + +**Mounts Section:** +- The `.venv` directory is stored in a Docker named volume (`venv-${devcontainerId}`) for better performance and isolation +- SSH keys from the host (`${localEnv:HOME}/.ssh`) are bind-mounted to enable git operations with SSH authentication + +**Environment Variables:** +- `UV_PROJECT_ENVIRONMENT` is set to `${containerWorkspaceFolder}/.venv` to ensure uv uses the mounted volume + +**Update Content Command:** +- `updateContentCommand` sets proper ownership of `.venv` and `.ssh` directories to the `vscode` user after container updates + +This configuration eliminates the need for volume definitions in `docker-compose.yml`, as volumes are managed directly through the devcontainer `mounts` section. diff --git a/docs/usecases/jupyter.md b/docs/usecases/jupyter.md index bfc3f58..b569cd3 100644 --- a/docs/usecases/jupyter.md +++ b/docs/usecases/jupyter.md @@ -56,7 +56,7 @@ git switch jupyter "notebook.source.organizeImports": "explicit" }, "notebook.formatOnSave.enabled": true, - "python.defaultInterpreterPath": "/home/vscode/.venv/bin/python", + "python.defaultInterpreterPath": ".venv/bin/python", "[python]": { "editor.codeActionsOnSave": { "source.fixAll": "explicit", From 7554b6c24c4660ae6b000d7174f2a65e72eab50f Mon Sep 17 00:00:00 2001 From: d-eigo-hara Date: Fri, 9 Jan 2026 11:12:54 +0000 Subject: [PATCH 4/5] fix: highlight --- docs/configurations/uv.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/configurations/uv.md b/docs/configurations/uv.md index 544b1da..60ea3c7 100644 --- a/docs/configurations/uv.md +++ b/docs/configurations/uv.md @@ -6,7 +6,7 @@ ## Virtual Environment Set the `UV_PROJECT_ENVIRONMENT` not to create a virtual environment in the project directory. -```json title=".devcontainer/devcontainer.json" hl_lines="48 10-19 50" +```json title=".devcontainer/devcontainer.json" hl_lines="10-19 53 55" { "name": "uv", "dockerComposeFile": "../.devcontainer/docker-compose.yml", From cd0f682a0d87e5f97cde49b80f6fafa1cff08677 Mon Sep 17 00:00:00 2001 From: d-eigo-hara Date: Fri, 9 Jan 2026 11:14:11 +0000 Subject: [PATCH 5/5] fix: highlight --- docs/configurations/uv.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/configurations/uv.md b/docs/configurations/uv.md index 60ea3c7..9d7b3f6 100644 --- a/docs/configurations/uv.md +++ b/docs/configurations/uv.md @@ -6,7 +6,7 @@ ## Virtual Environment Set the `UV_PROJECT_ENVIRONMENT` not to create a virtual environment in the project directory. -```json title=".devcontainer/devcontainer.json" hl_lines="10-19 53 55" +```json title=".devcontainer/devcontainer.json" hl_lines="10-24 53 55" { "name": "uv", "dockerComposeFile": "../.devcontainer/docker-compose.yml",