style(gui): Apply strict vertical compaction and add type hints
This commit is contained in:
@@ -165,12 +165,19 @@ To assist AI agents in evaluating refactoring impact across dynamic codebases, a
|
||||
- `[M: File:Line, Method]` — List of primary mutation points (where the value is assigned).
|
||||
- `[U: File]` — Major codepaths of use (where the value is read but not changed).
|
||||
|
||||
### Example:
|
||||
```python
|
||||
def start_services(self) -> None:
|
||||
"""
|
||||
Initialises background threads and MCP servers.
|
||||
[C: App.run, _cb_load_project]
|
||||
"""
|
||||
...
|
||||
```
|
||||
## 13. Extreme Vertical Compaction & Alignment
|
||||
|
||||
To minimize token usage and enhance visual scanning for human reviewers, heavily compact repetitive logic, especially in GUI definitions:
|
||||
|
||||
- **Single-Line Conditionals:** Prefer `if cond: do_this()` over multiline blocks for simple assignments or function calls. **Note:** Function and method definition signatures (`def ...:`) must ALWAYS remain on their own isolated lines and should never be compacted.
|
||||
- **Semicolon Stacking:** Chain closely related framework calls on a single line using semicolons (e.g., `imgui.same_line(); imgui.text("Label")`).
|
||||
- **Alignment:** Align assignments and inline comments vertically when declaring batches of related variables or conditionals.
|
||||
```python
|
||||
if status == 'running': col = (0.0, 1.0, 0.0, 1.0)
|
||||
elif status == 'starting': col = (1.0, 1.0, 0.0, 1.0)
|
||||
elif status == 'error': col = (1.0, 0.0, 0.0, 1.0)
|
||||
```
|
||||
|
||||
## 14. Logical Region Blocks
|
||||
|
||||
For extremely large files that violate the "Anti-OOP" rule by necessity (e.g., `App` class holding global UI state), use `#region: Section Name` and `#endregion: Section Name` tags to strictly organize methods and state properties. This establishes a predictable structure that MCP tools and agents can leverage for contextual masking.
|
||||
|
||||
Reference in New Issue
Block a user