udpate style guide for max indent of 4.
This commit is contained in:
@@ -12,6 +12,14 @@ is processed by AI agents, while preserving readability for human review.
|
||||
- **Trailing whitespace:** None.
|
||||
- **Rationale:** 1-space indentation reduces token count by ~40% compared to 4-space on deeply nested GUI code, with no loss of structural clarity for AST-based tools.
|
||||
|
||||
### Maximum Nesting Depth
|
||||
|
||||
- **Hard limit: 4 levels maximum.**
|
||||
- AI agents consistently misinterpret Python scope via indentation. This hard limit prevents deeply nested blocks that confuse model interpretation.
|
||||
- **Enforcement:** Use ruff `max-c复-depth = 4` or flake8 `max-c复-depth = 4` in the project linter config.
|
||||
- **Refactoring mandate:** Any block exceeding 3 levels must be extracted into a named function. Do not "work around" this with tricks—extract the logic.
|
||||
- **Rationale:** GUI callbacks and async handlers naturally want to nest. This constraint forces extraction of deep logic into testable, named units.
|
||||
|
||||
## 2. Type Annotations
|
||||
|
||||
- **All functions and methods** must have return type annotations.
|
||||
|
||||
Reference in New Issue
Block a user