You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: enhance project structure and update dependencies
- Introduced .editorconfig for consistent coding styles across files.
- Updated pre-commit configuration to use ruff v0.14.8 and adjusted pytest command.
- Enhanced AGENTS.md with additional guidelines on comments and naming conventions.
- Refactored Makefile to streamline commands and updated the main application entry point.
- Upgraded dependencies in pyproject.toml, including pydantic and ty.
- Added initial application logic in src/templates_python and utility functions for settings management.
- Created tests for logging configuration and main application execution.
All changes aim to improve code quality, maintainability, and project usability.
- Keep public API names stable and unsurprising; avoid cleverness
35
+
24
36
## Architecture Principles
25
37
26
38
**Classes for state and lifecycle**, pure functions for transformations. Use classes when managing resources, coordinating operations, or defining interfaces.
@@ -32,6 +44,7 @@ This document provides coding guidelines for AI agents working on this Python pr
32
44
**Factory functions**: Standalone functions (`get_backend()`, `resolve_config()`) that map configurations to implementations.
33
45
34
46
**Resource management**:
47
+
35
48
- Reference counting for expensive resources (connections, clients) with acquire/release semantics
36
49
- Context managers (`__enter__`/`__exit__`) for automatic cleanup
37
50
- Track ownership with boolean flags to avoid closing borrowed resources
@@ -44,7 +57,7 @@ This document provides coding guidelines for AI agents working on this Python pr
44
57
45
58
**Performance**: Use `@dataclass(slots=True)` for frequently-instantiated objects and `TypeVar` for type-safe generic protocols.
46
59
47
-
**Resilience**: Exponential backoff for network operations, graceful empty returns over exceptions, debug logging for key metrics.
60
+
**Resilience**: Exponential backoff for network operations, graceful empty returns over exceptions, debug logging for key metrics. Keep error handling targeted (catch specific exceptions, add context, re-raise/convert).
48
61
49
62
## Best Practices
50
63
@@ -55,20 +68,22 @@ This document provides coding guidelines for AI agents working on this Python pr
55
68
- Pipeline pattern: chain transformations with clear inputs/outputs
56
69
- No excessive error handling or low-value comments
57
70
71
+
## Code Quality Bar (What to Avoid)
72
+
73
+
When generating code, optimize for reviewability and long-term maintainability.
74
+
75
+
-**Unnecessary comments**: If a comment just restates the code, remove it and improve naming/structure instead
76
+
-**Long docstrings**: Keep most docstrings to a single line; only expand when a public API truly needs usage notes
77
+
-**Overly defensive code**: Don’t add “just in case” checks everywhere; validate at boundaries and trust validated data internally
78
+
-**Broad `try/except`**: Avoid wrapping whole functions; don’t swallow exceptions; catch specific errors only to recover or add context
79
+
-**Deep nesting**: Prefer guard clauses and extraction to keep indentation shallow (avoid multi-level `if/for/try`)
80
+
-**Bad abstractions**: Don’t create classes/protocols/layers without clear value; avoid one-method wrappers and “framework-building”
81
+
-**Vague naming**: Avoid generic verbs (`do`, `process`, `handle`) and generic buckets (`utils`, `helpers`) for core logic
82
+
-**Weak typing / schemas**: Avoid `Any` and unstructured `dict[str, Any]` in core code; prefer Pydantic models (or narrow typed objects) with explicit fields and validation
83
+
-**Noisy error handling**: Prefer a small number of well-placed domain exceptions over many `RuntimeError`/`ValueError` catch-alls
84
+
58
85
## Pydantic Commitment
59
86
60
87
- All interface models use Pydantic `BaseModel` (not dataclasses)
└── .github/workflows/ # CI (lint + typecheck + test)
95
100
```
96
101
97
102
---
@@ -124,6 +129,27 @@ Configuration is in `pyproject.toml` under `[tool.ty]`.
124
129
125
130
---
126
131
132
+
## Code Style
133
+
134
+
This project uses **2-space indentation** and **single quotes** (configured in Ruff). While Python conventionally uses 4-space indentation, 2-space is a deliberate choice for more compact code. The formatter enforces this automatically.
135
+
136
+
Key style settings:
137
+
- Indent: 2 spaces
138
+
- Quotes: Single (`'`)
139
+
- Line length: 88 characters
140
+
141
+
---
142
+
143
+
## First Things To Edit
144
+
145
+
When copying this template into a new project, update:
146
+
147
+
-`[project] name`, `description`, `authors`, and `version` in `pyproject.toml`
148
+
- The import package name under `src/` (rename `templates_python/` to your project slug)
0 commit comments