1
0
This commit is contained in:
2026-03-30 09:54:38 +00:00
commit 84fc5e4b14
10 changed files with 278 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/python
{
"name": "Python 3",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/python:3-3.14-trixie"
// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "pip3 install --user -r requirements.txt",
// Configure tool-specific properties.
// "customizations": {},
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}

48
.dockerignore Normal file
View File

@@ -0,0 +1,48 @@
# VCS
.git/
.gitignore
# Python cache / bytecode
__pycache__/
*.py[cod]
*$py.class
# Build / packaging artifacts
build/
dist/
*.egg-info/
.eggs/
pip-wheel-metadata/
# Test and coverage artifacts
.pytest_cache/
.tox/
.nox/
.coverage
.coverage.*
htmlcov/
# Type checker / linter caches
.mypy_cache/
.pytype/
.pyre/
.ruff_cache/
# Virtual environments
.venv/
venv/
env/
ENV/
# Local env/config files
.env
.env.*
# IDE and notebook artifacts
.vscode/
.idea/
.ipynb_checkpoints/
# Logs and temp files
*.log
*.tmp

66
.gitignore vendored Normal file
View File

@@ -0,0 +1,66 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
dist/
downloads/
.eggs/
*.egg-info/
*.egg
pip-wheel-metadata/
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
.pytest_cache/
coverage.xml
*.cover
# Type checkers / linters
.mypy_cache/
.pytype/
.pyre/
.ruff_cache/
# Virtual environments
.venv/
venv/
env/
ENV/
# IDEs and editors
.vscode/
.idea/
*.swp
# Jupyter
.ipynb_checkpoints/
# Environment variables
.env
.env.*
# OS generated files
.DS_Store
Thumbs.db
# Logs
*.log
# Local application data
instance/

50
.pre-commit-config.yaml Normal file
View File

@@ -0,0 +1,50 @@
minimum_pre_commit_version: 4.0.0
fail_fast: false
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-merge-conflict
- repo: local
hooks:
- id: black
name: black
entry: uv run black --check --diff
language: system
types_or: [python]
- id: isort
name: isort
entry: uv run isort --check-only --diff
language: system
types_or: [python]
- id: ruff
name: ruff
entry: uv run ruff check
language: system
types_or: [python]
- id: bandit
name: bandit
entry: uv run bandit -q -r src
language: system
pass_filenames: false
- id: ty
name: ty
entry: uv run ty check
language: system
pass_filenames: false
- id: pytest
name: pytest-with-coverage
entry: uv run pytest -q
language: system
pass_filenames: false
stages: [pre-push]

18
Dockerfile Normal file
View File

@@ -0,0 +1,18 @@
FROM python:3.12-slim
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
UV_LINK_MODE=copy
WORKDIR /app
RUN pip install --no-cache-dir uv
COPY pyproject.toml ./
RUN uv sync --no-install-project
COPY src ./src
EXPOSE 8000
CMD ["uv", "run", "uvicorn", "comment_automation.main:app", "--app-dir", "src", "--host", "0.0.0.0", "--port", "8000"]

18
README.md Normal file
View File

@@ -0,0 +1,18 @@
# CommentAutomation
Python project initialized with uv.
## Quick start
1. Install uv.
2. Sync dependencies:
uv sync --group dev
3. Run the app:
uv run uvicorn comment_automation.main:app --app-dir src --host 0.0.0.0 --port 8000
4. Run tests:
uv run pytest

28
pyproject.toml Normal file
View File

@@ -0,0 +1,28 @@
[project]
name = "comment-automation"
version = "0.1.0"
description = "Comment automation service"
readme = "README.md"
requires-python = ">=3.11"
dependencies = [
"fastapi[standard]>=0.116.0",
"pydantic>=2.11.0",
"uplink>=0.9.7",
]
[dependency-groups]
dev = [
"pytest>=8.3.0",
"pre-commit>=4.2.0",
]
[build-system]
requires = ["hatchling>=1.24.2"]
build-backend = "hatchling.build"
[tool.hatch.build.targets.wheel]
packages = ["src/comment_automation"]
[tool.pytest.ini_options]
testpaths = ["tests"]
addopts = "-q"

View File

@@ -0,0 +1 @@
"""CommentAutomation package."""

View File

@@ -0,0 +1,14 @@
from fastapi import FastAPI
from pydantic import BaseModel
app = FastAPI(title="CommentAutomation")
class HealthResponse(BaseModel):
status: str
@app.get("/health", response_model=HealthResponse)
def health() -> HealthResponse:
return HealthResponse(status="ok")

13
tests/test_health.py Normal file
View File

@@ -0,0 +1,13 @@
from fastapi.testclient import TestClient
from comment_automation.main import app
client = TestClient(app)
def test_health() -> None:
response = client.get("/health")
assert response.status_code == 200
assert response.json() == {"status": "ok"}