refactor: replace Any types with specific types and update bad_code.md

- Replace Any with object or specific types across codebase
- Add ReviewRequest dataclass for PR review payloads
- Update bad_code.md: mark 5.1 (Any Type Overuse) as resolved
- Fix summary table with accurate counts and unresolved issues list
This commit is contained in:
meeks
2026-07-19 15:35:17 +02:00
parent aa9e8222a3
commit ae4e2d46ac
13 changed files with 326 additions and 169 deletions
+41 -15
View File
@@ -218,9 +218,9 @@ Removed the `_configure_git_credentials()` method entirely. The agent now relies
## 5. Code Quality Issues
### 5.1 `Any` Type Overuse
### 5.1 `Any` Type Overuse [RESOLVED]
Throughout the codebase, `Any` is used where specific types would be better:
Throughout the codebase, `Any` was used where specific types would be better:
```python
# gitea/client.py:34
@@ -231,6 +231,17 @@ def get_authenticated_user(self) -> UserModel | None:
def list_assigned_issues(self) -> list[dict]: # Bare dict, not dict[str, Any]
```
**Resolution:**
Replaced `Any` type annotations with `object` or specific types across the codebase:
- `core/agent.py`: Changed `Any` to `object` for message parameters and model attributes
- `gitea/files_client.py`: Changed `dict[str, Any]` to `dict[str, object]`
- `gitea/issues_client.py`: Changed `dict[str, Any]` to `dict[str, str | list[str]]` for issue data
- `gitea/models.py`: Changed `dict[str, Any]` to `dict[str, object]` for `head` and `base` fields
- `gitea/notifications_client.py`: Changed `list[dict[str, Any]]` to `list[dict[str, object]]`
- `gitea/prs_client.py`: Changed `dict[str, Any]` to specific types (`dict[str, str | None]`, `dict[str, str]`, `dict[str, object]`) and introduced `ReviewRequest` dataclass for review payloads
- `gitea/repos_client.py`: Changed `list[dict[str, Any]]` to `list[dict[str, object]]`
- `gitea/tools/git_tools.py`: Removed unused `from typing import Any` import
### 5.2 `assert` Used for Control Flow [RESOLVED]
**Files:** `core/dispatcher.py:492, 741, 754`, `core/agent.py:74, 94`
@@ -399,18 +410,33 @@ Removed the duplicate methods `add_comment` and `add_label` from `IssueTools`. O
## Summary
| Category | Severity | Count |
| -------------------------- | -------- | ----- |
| Security Vulnerabilities | Critical | 0 |
| Architecture Anti-Patterns | High | 3 |
| Error Handling Problems | High | 0 |
| Dangerous Side Effects | High | 0 |
| Code Quality Issues | Medium | 3 |
| Performance Issues | Medium | 1 |
| Concurrency Issues | Medium | 1 |
| Prompt Engineering Issues | Medium | 1 |
| Testing Issues | Medium | 2 |
| CUPID Violations | High | 4 |
| Category | Severity | Total | Unresolved |
| -------------------------- | -------- | ----- | ---------- |
| Security Vulnerabilities | Critical | 4 | 0 |
| Architecture Anti-Patterns | High | 5 | 0 |
| Error Handling Problems | High | 3 | 0 |
| Dangerous Side Effects | High | 3 | 0 |
| Code Quality Issues | Medium | 5 | 1 |
| Performance Issues | Medium | 2 | 1 |
| Concurrency Issues | Medium | 2 | 1 |
| Prompt Engineering Issues | Medium | 2 | 1 |
| Testing Issues | Medium | 2 | 2 |
| CUPID Violations | High | 5 | 4 |
**Total: 29 issues identified, 8 unresolved.**
**Total: 33 issues identified, 10 unresolved.**
### Unresolved Issues
| # | Issue | Section |
| ---- | -------------------------------------- | ------- |
| 1 | Mutable Default Arguments (Near Miss) | 5.5 |
| 2 | No Caching | 6.2 |
| 3 | No Mutex on Workspace Operations | 7.2 |
| 4 | Massive Embedded System Prompts | 8.1 |
| 5 | Tests Don't Mock HTTP Calls | 9.1 |
| 6 | No Tests for Critical Paths | 9.2 |
| 7 | Not Understandable | 10.2 |
| 8 | Not Performant | 10.3 |
| 9 | Not Inspectable | 10.4 |
| 10 | Not Delightful | 10.5 |