Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,23 @@
"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": {}
},
Expand Down Expand Up @@ -33,8 +50,9 @@
},
"containerEnv": {
"DISPLAY": "dummy",
"UV_PROJECT_ENVIRONMENT": "/home/vscode/.venv"
"UV_PROJECT_ENVIRONMENT": "${containerWorkspaceFolder}/.venv"
},
"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"
Expand Down
6 changes: 3 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
"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,
"python.testing.pytestArgs": [
"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",
Expand Down
20 changes: 15 additions & 5 deletions docs/configurations/ruff.md
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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 = [
Expand Down Expand Up @@ -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.
Expand All @@ -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",
Expand All @@ -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",
Expand Down
59 changes: 46 additions & 13 deletions docs/configurations/uv.md
Original file line number Diff line number Diff line change
Expand Up @@ -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="10-24 53 55"
{
"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.
2 changes: 1 addition & 1 deletion docs/usecases/jupyter.md
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading