2.6 KiB
2.6 KiB
Repository Guidelines
Project Structure & Module Organization
uv_app/holds application code (settings.pyfor env-loaded config,logging_config.pyfor basic logging,__main__.pyentrypoint placeholder). Keep new modules small and focused; preferuv_app/feature/<module>.pyfor grouped logic.tests/contains pytest suites; mirror module paths (e.g.,uv_app/example_util.py→tests/example_util_test.py).notebooks/is for exploratory work; avoid depending on it for runtime logic and keep outputs trimmed before committing.- Root files:
pyproject.toml(project + tooling),uv.lock(dependency lock),Dockerfile(runtime build),README.md(quickstart).
Build, Test, and Development Commands
- Install + sync env:
uv sync(creates venv and installs deps). - Run full format + lint:
uv run poe x(runsruff formatthenruff check --fix). - Tests:
uv run pytest(add-k <pattern>for focused runs).
Dependency Management
- Use
uv add <package>to add dependencies; this updatespyproject.tomlanduv.lock. - For dev dependencies, use
uv add --dev <package>. - To remove packages, use
uv remove <package>.
Docker & Containerization
- The
Dockerfile.mainsets up a lightweight Python environment using the locked dependencies fromuv.lock. - The
Dockerfile.testssets up a pytest environment for running tests in a containerized setup. - Use
docker compose buildto build images. - Use
docker compose up mainto build and run the app container ordocker compose run mainif application is job-based. - Use
docker compose run teststo run tests in a containerized environment.
Coding Style & Naming Conventions
- Python 3.14; Use type hints on. Use double quotes (enforced by ruff
flake8-quotes), Google-style docstrings when needed. - Follow Ruff config (
select = ["ALL"]with targeted ignores). Keep new ignores local and justified. - Modules and files: lowercase with underscores; classes:
PascalCase; functions/vars:snake_case. Tests mirror subject names and use descriptive test function names.
Testing Guidelines
- Framework: pytest. Parametrize where inputs vary.
- Place unit tests alongside corresponding modules under
tests/; name files<module>_test.py. - Add regression tests with clear arrange/act/assert sections. Aim to cover new branches; prefer deterministic data over randomness.
Configuration & Secrets
- Settings load via
pydantic-settingswith.envdiscovery (find_dotenv). Keep secrets out of git; document required keys in.env.exampleif adding new settings. - Seperate settings classes based on purpose, for example PostgresSettings, AppSettings, etc.