- Use
uvas the Python package manager and runtime.- Run scripts/tools via
uv run <tool>(e.g.uv run pytest,uv run ruff check). - Add dependencies with
uv add; sync the environment withuv sync. - Never use
pipdirectly.
- Run scripts/tools via
- Follow ruff standards. Before committing, always run:
uv run ruff check --fix . uv run ruff format . - Line length: 120 characters.
- Enabled ruff rule-sets:
B,D,C4,S,F,E,W,UP,I,RUF. - Ignored rules:
D203,D212,D100,D104,D107,D401— use D211 / D213 docstring style. - Test files (
tests/**) may omit docstrings and useassertfreely (S101ignored there).
- Prefer modern Python 3.13+ features and idioms.
- Avoid unnecessary imports, variables, or functions.
- Suggest more efficient algorithms or data structures when applicable.
- Find common patterns and abstract them into reusable functions or classes (adhering the DRY principle).
- Add type hints to all function signatures and variables where inferable.
- Verify with
uv run mypy; the project enforcesdisallow_untyped_defs = true.
- Add Google-style docstrings to all public functions, methods, and classes.
- Module-level and
__init__docstrings are optional (D100, D104, D107 are ignored).
- Target Python 3.13; prefer modern syntax and stdlib features:
match/casefor structural pattern matching.X | Yunion types instead ofOptional[X]orUnion[X, Y].tomllib,pathlib,typing.Self, etc.
- Source code lives under
src/<package_name>/(src layout). - Tests live under
tests/; the package is importable afteruv sync. - Do not place importable source files at the project root.
- Follow Django template best practices.
- Use
{% block %}and{% extends %}for template inheritance. - Avoid logic in templates; use template tags and filters instead.
- Always add the block name at the end of the block comment for clarity, e.g.
{% endblock content %}. - Prefer the new django 6 partials syntax for reusable template components.
- Design mobile-first and ensure templates are responsive, using Tailwind CSS / DaisyUI for styling.
- Use class-based views (CBVs) for better organization and reusability.
- For forms, prefer Django's built-in form classes and validation mechanisms.
- Use htmx for dynamic interactions where appropriate, following best practices for progressive enhancement and accessibility.
- Use
pytestfor all tests; run viauv run pytest. - Maintain or improve coverage (reported to
term-missingandxml). - When adding features, add corresponding tests in
tests/.
- Follow Conventional Commits format (enforced by commitlint):
Common types:
<type>(<scope>): <short summary>feat,fix,docs,chore,refactor,test,ci,build. - Commits of type
chore,ci,refactor,style,testare excluded from the changelog.