Skip to content

Commit f5e96fa

Browse files
add user class example
1 parent 4c9e55e commit f5e96fa

13 files changed

Lines changed: 343 additions & 434 deletions

.devcontainer/Dockerfile

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1-
ARG UV_VERSION=0.5.4
2-
ARG DEBIAN_VERSION=bookworm
1+
FROM python:3.12-slim-bookworm
32

3+
# Install system dependencies
4+
RUN apt-get update && apt-get install -y \
5+
--no-install-recommends \
6+
curl \
7+
ca-certificates
48

5-
FROM ghcr.io/astral-sh/uv:$UV_VERSION AS uv
9+
# Install uv and add it to PATH
10+
ADD https://astral.sh/uv/install.sh /uv-installer.sh
11+
RUN sh /uv-installer.sh && rm /uv-installer.sh
612

13+
ENV PATH="/root/.local/bin/:$PATH"
714

8-
FROM mcr.microsoft.com/vscode/devcontainers/base:$DEBIAN_VERSION
9-
LABEL maintainer="a5chin <zimmermann@xbrain.com>"
10-
11-
COPY --from=uv --chown=vscode: /uv /uvx /bin/
15+
WORKDIR /workspace

.devcontainer/devcontainer.json

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,28 @@
11
{
2-
"name": "uv",
2+
"name": "Python Dev Container",
33
"build": {
4-
"context": "..",
5-
"dockerfile": "Dockerfile",
6-
"args": {
7-
"UV_VERSION": "0.5.4",
8-
"DEBIAN_VERSION": "bookworm"
9-
}
4+
"dockerfile": "Dockerfile"
105
},
116
"features": {
12-
"ghcr.io/dhoeric/features/hadolint:1": {}
7+
"ghcr.io/devcontainers/features/github-cli:1": {}
138
},
149
"customizations": {
1510
"vscode": {
11+
"settings": {
12+
"python.defaultInterpreterPath": "/workspace/.venv/bin/python",
13+
"python.terminal.activateEnvironment": true,
14+
"python.formatting.provider": "ruff",
15+
"editor.formatOnSave": true
16+
},
1617
"extensions": [
18+
"ms-python.python",
19+
"ms-python.vscode-pylance",
1720
"charliermarsh.ruff",
18-
"exiasr.hadolint",
19-
"kevinrose.vsc-python-indent",
20-
"mosapride.zenkaku",
2121
"ms-azuretools.vscode-docker",
22-
"ms-python.python",
23-
"njpwerner.autodocstring",
24-
"redhat.vscode-yaml",
25-
"shardulm94.trailing-spaces",
26-
"tamasfe.even-better-toml"
22+
"tamasfe.even-better-toml",
23+
"redhat.vscode-yaml"
2724
]
2825
}
2926
},
30-
"containerEnv": {
31-
"DISPLAY": "dummy",
32-
"PYTHONUNBUFFERED": "True",
33-
"UV_LINK_MODE": "copy",
34-
"UV_PROJECT_ENVIRONMENT": "/home/vscode/.venv"
35-
},
36-
"postCreateCommand": "uv sync --frozen",
37-
"postStartCommand": "uv run pre-commit install",
38-
"remoteUser": "vscode"
27+
"postCreateCommand": "uv sync --dev"
3928
}

.dockerignore

Lines changed: 0 additions & 186 deletions
This file was deleted.

.pre-commit-config.yaml

Lines changed: 0 additions & 31 deletions
This file was deleted.

Dockerfile

Lines changed: 0 additions & 21 deletions
This file was deleted.

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# Python Dev Container Repository
1+
# Python Base Repository
2+
3+
Initial python project setup with Devcontainers, CI pipeline and the Serde library.
24

35
## Overview
46
This repository is based on [github.com/a5chin/python-uv](https://github.com/a5chin/python-uv). Check its readme for the main layout of this repository.
@@ -11,7 +13,7 @@ This repository is based on [github.com/a5chin/python-uv](https://github.com/a5c
1113

1214
### Run Tests
1315
```sh
14-
pytest
16+
uv run pytest
1517
```
1618

1719
### Install Libraries
@@ -25,3 +27,10 @@ uv sync --no-dev
2527
# Use the add command to add dependencies to your project
2628
uv add {libraries}
2729
```
30+
31+
## Run Command Line
32+
33+
```sh
34+
uv run python src/main.py 42 Bob bob@example.com
35+
uv run python src/main.py '{"id":42,"name":"Bob","email":"bob@example.com"}'
36+
```

logging_config.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"version": 1,
3+
"disable_existing_loggers": false,
4+
"formatters": {
5+
"standard": {
6+
"format": "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
7+
}
8+
},
9+
"handlers": {
10+
"console": {
11+
"class": "logging.StreamHandler",
12+
"level": "INFO",
13+
"formatter": "standard"
14+
}
15+
},
16+
"loggers": {
17+
"": {
18+
"level": "DEBUG",
19+
"handlers": [
20+
"console"
21+
],
22+
"propagate": true
23+
}
24+
}
25+
}

pyproject.toml

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,14 @@ name = "default"
33
version = "0.1.0"
44
description = "This repository contains configurations to set up a Python development environment using VSCode's Dev Container feature. The environment includes uv and Ruff."
55

6-
authors = [{ name = "a5chin", email = "a5chin.origin+contact@gmail.com" }]
7-
maintainers = [{ name = "a5chin", email = "a5chin.origin+contact@gmail.com" }]
8-
96
requires-python = ">=3.9"
107
readme = "README.md"
118
license = { file = "LICENSE" }
129

13-
dependencies = ["pytz>=2024.2"]
10+
dependencies = ["pydantic>=2.10.6", "pytz>=2024.2"]
1411

1512
[tool.pytest.ini_options]
1613
pythonpath = "src"
1714

1815
[tool.uv]
19-
dev-dependencies = [
20-
"pre-commit>=4.0.1",
21-
"pyright>=1.1.389",
22-
"pytest>=8.3.3",
23-
"ruff>=0.8.0",
24-
]
16+
dev-dependencies = ["pyright>=1.1.389", "pytest>=8.3.3", "ruff>=0.8.0"]

src/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)