From 76508d7e71e2ba22379d1650e9d7c2aac9084eea Mon Sep 17 00:00:00 2001 From: Ed_ Date: Mon, 11 May 2026 23:03:53 -0400 Subject: [PATCH] udpate style guide for max indent of 4. --- conductor/code_styleguides/python.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/conductor/code_styleguides/python.md b/conductor/code_styleguides/python.md index bf86b15..2f92679 100644 --- a/conductor/code_styleguides/python.md +++ b/conductor/code_styleguides/python.md @@ -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.