|
| 1 | +# Agent Guidelines for litestar-start |
| 2 | + |
| 3 | +This document contains instructions for AI agents operating in this repository. |
| 4 | + |
| 5 | +## 1. Build, Lint, and Test Commands |
| 6 | + |
| 7 | +This project uses `uv` for dependency management and `hatchling` for building. |
| 8 | + |
| 9 | +### Dependency Management |
| 10 | +- **Install dependencies:** `uv sync` |
| 11 | +- **Update lockfile:** `uv lock` (or `uv lock --upgrade` to upgrade) |
| 12 | + |
| 13 | +### Testing |
| 14 | +- **Run all tests:** |
| 15 | + ```bash |
| 16 | + pytest |
| 17 | + ``` |
| 18 | +- **Run a single test file:** |
| 19 | + ```bash |
| 20 | + pytest tests/test_generator.py |
| 21 | + ``` |
| 22 | +- **Run a specific test case:** |
| 23 | + ```bash |
| 24 | + pytest tests/test_generator.py::test_function_name |
| 25 | + ``` |
| 26 | +- **Run with verbose output:** |
| 27 | + ```bash |
| 28 | + pytest -v |
| 29 | + ``` |
| 30 | + |
| 31 | +### Linting and Formatting |
| 32 | +- **Run all linters (Ruff, Type Checking, Pre-commit):** |
| 33 | + ```bash |
| 34 | + make lint |
| 35 | + ``` |
| 36 | + *Note: This runs `ruff check --fix`, `ty check`, and `pre-commit run -a`.* |
| 37 | + |
| 38 | +- **Run Ruff manually:** |
| 39 | + ```bash |
| 40 | + ruff check . |
| 41 | + ``` |
| 42 | + |
| 43 | +- **Run Type Checking manually:** |
| 44 | + ```bash |
| 45 | + ty check |
| 46 | + ``` |
| 47 | + |
| 48 | +## 2. Code Style Guidelines |
| 49 | + |
| 50 | +Adhere strictly to the following conventions to match the existing codebase. |
| 51 | + |
| 52 | +### General |
| 53 | +- **Python Version:** Target Python 3.13+. |
| 54 | +- **Line Length:** 120 characters (configured in `pyproject.toml`). |
| 55 | +- **File Operations:** Always use `pathlib.Path` instead of `os.path` strings. |
| 56 | +- **Data Models:** Use `msgspec.Struct` for defining data structures/configurations, not `dataclasses` or `pydantic`. |
| 57 | +- **Enums:** Use `enum.StrEnum` for string-based enumerations. |
| 58 | + |
| 59 | +### Imports |
| 60 | +- Group imports: |
| 61 | + 1. Standard library (e.g., `pathlib`, `re`) |
| 62 | + 2. Third-party libraries (e.g., `jinja2`, `msgspec`) |
| 63 | + 3. Local application imports (e.g., `src.utils`) |
| 64 | +- Imports are sorted automatically by Ruff; attempt to group them logically. |
| 65 | + |
| 66 | +### Typing |
| 67 | +- **Strict Typing:** All functions and methods must have type annotations for arguments and return values. |
| 68 | +- Use built-in types (`list`, `dict`, `set`) instead of `typing.List`, etc. |
| 69 | +- Use `|` for unions (e.g., `str | None`) instead of `Optional` or `Union`. |
| 70 | + |
| 71 | +### Naming Conventions |
| 72 | +- **Variables/Functions:** `snake_case` |
| 73 | +- **Classes:** `PascalCase` |
| 74 | +- **Constants:** `SCREAMING_SNAKE_CASE` |
| 75 | +- **Private Members:** Prefix with `_` (though `SLF001` is ignored in Ruff, still prefer public interfaces). |
| 76 | + |
| 77 | +### Docstrings |
| 78 | +- Use **Google-style** docstrings for all public modules, functions, classes, and methods. |
| 79 | +- Format: |
| 80 | + ```python |
| 81 | + def function(arg: int) -> str: |
| 82 | + """Short summary of the function. |
| 83 | +
|
| 84 | + Args: |
| 85 | + arg: Description of the argument. |
| 86 | +
|
| 87 | + Returns: |
| 88 | + Description of the return value. |
| 89 | +
|
| 90 | + """ |
| 91 | + ``` |
| 92 | + |
| 93 | +### Error Handling |
| 94 | +- Validate inputs early (fail fast). |
| 95 | +- Use specific exceptions where possible. |
| 96 | +- Avoid bare `except:` blocks. |
| 97 | + |
| 98 | +### Directory Structure |
| 99 | +- `src/`: Source code. |
| 100 | +- `tests/`: Test files (mirrors source structure or flat list). |
| 101 | +- `tools/`: Build and maintenance scripts. |
0 commit comments