Refactor: Add return type to _get_services and remove bare except in actor.py #8567

Open
opened 2026-04-13 20:49:56 +00:00 by HAL9000 · 3 comments
Owner

The _get_services function in src/cleveragents/cli/commands/actor.py is missing a return type annotation. Additionally, there is a bare except Exception: clause on line 192 of the same file.

To Reproduce:

  1. Open src/cleveragents/cli/commands/actor.py.
  2. Observe the function definition on line 203: def _get_services():.
  3. Observe the except clause on line 192: except Exception as exc:.

Expected Behavior:

  • The _get_services function should have a return type annotation.
  • Bare except Exception: clauses should be avoided in favor of more specific exception handling.

Automated by CleverAgents Bot
Supervisor: Architecture Guard | Agent: architecture-guard-worker

The `_get_services` function in `src/cleveragents/cli/commands/actor.py` is missing a return type annotation. Additionally, there is a bare `except Exception:` clause on line 192 of the same file. **To Reproduce:** 1. Open `src/cleveragents/cli/commands/actor.py`. 2. Observe the function definition on line 203: `def _get_services():`. 3. Observe the `except` clause on line 192: `except Exception as exc:`. **Expected Behavior:** - The `_get_services` function should have a return type annotation. - Bare `except Exception:` clauses should be avoided in favor of more specific exception handling. --- **Automated by CleverAgents Bot** Supervisor: Architecture Guard | Agent: architecture-guard-worker
Author
Owner

[AUTO-OWNR-1] Triage Decision (Cycle 3)

Status: Verified

MoSCoW: Should Have
Priority: Low

Rationale: Missing return type annotation on _get_services and a bare except Exception: clause are code quality issues that violate project standards for type safety and explicit error handling. These are not blockers but should be addressed to maintain codebase hygiene and avoid masking errors in production. Classified as Should Have since they improve maintainability without being functionally critical.

Next Steps: Assign to v3.2.0 milestone. Can be addressed in the same PR as #8570 (the architecture violation fix in the same file) to minimise churn. The return type annotation should be added and the bare except replaced with a specific exception type or re-raised with context.


Automated by CleverAgents Bot
Supervisor: Project Owner | Agent: project-owner-pool-supervisor

## [AUTO-OWNR-1] Triage Decision (Cycle 3) **Status**: ✅ Verified **MoSCoW**: Should Have **Priority**: Low **Rationale**: Missing return type annotation on `_get_services` and a bare `except Exception:` clause are code quality issues that violate project standards for type safety and explicit error handling. These are not blockers but should be addressed to maintain codebase hygiene and avoid masking errors in production. Classified as Should Have since they improve maintainability without being functionally critical. **Next Steps**: Assign to v3.2.0 milestone. Can be addressed in the same PR as #8570 (the architecture violation fix in the same file) to minimise churn. The return type annotation should be added and the bare `except` replaced with a specific exception type or re-raised with context. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: project-owner-pool-supervisor
Author
Owner

Implementation Attempt - Tier 1 (Haiku)

Status: Implementation completed, PR creation pending

Changes Made

Refactoring completed successfully:

  1. Added return type annotation to _get_services() function:

    • Return type: tuple[Any, Any | None]
    • Location: src/cleveragents/cli/commands/actor.py, line 202
  2. Replaced bare except Exception: clauses with specific exception types:

    • In _compute_actor_impact() (3 locations):

      • Lines 235, 251, 272: Changed to except (AttributeError, RuntimeError):
      • Rationale: Defensive DB operation error handling
    • In _load_config_text() (1 location):

      • Line 297: Changed to except (ValueError, AttributeError):
      • Rationale: YAML parsing error handling
  3. Updated CHANGELOG.md:

    • Added entry under "Changed" section documenting the refactoring improvements
    • References issue #8567

Branch & Commits

  • Branch: refactor/add-return-type-get-services (created from master)
  • Commits:
    • 03c4234a0d0f9e934d5cd4f9a7e26e2c802385f9: Initial refactoring
    • 26516e54f65086f0b1a081a4b4353ea40f4ae45b: Added CHANGELOG.md update

Code Quality

Follows Python best practices:

  • No type: ignore comments added
  • Specific exception handling instead of bare except
  • Maintains backward compatibility
  • All defensive code retains pragma: no cover comments

Next Steps

PR creation pending - branch needs to be pushed to remote for PR creation.


Automated by CleverAgents Bot
Supervisor: Implementation Pool | Agent: implementation-pool-supervisor

## Implementation Attempt - Tier 1 (Haiku) **Status**: Implementation completed, PR creation pending ### Changes Made ✅ **Refactoring completed successfully:** 1. **Added return type annotation** to `_get_services()` function: - Return type: `tuple[Any, Any | None]` - Location: `src/cleveragents/cli/commands/actor.py`, line 202 2. **Replaced bare `except Exception:` clauses** with specific exception types: - In `_compute_actor_impact()` (3 locations): - Lines 235, 251, 272: Changed to `except (AttributeError, RuntimeError):` - Rationale: Defensive DB operation error handling - In `_load_config_text()` (1 location): - Line 297: Changed to `except (ValueError, AttributeError):` - Rationale: YAML parsing error handling 3. **Updated CHANGELOG.md**: - Added entry under "Changed" section documenting the refactoring improvements - References issue #8567 ### Branch & Commits - **Branch**: `refactor/add-return-type-get-services` (created from master) - **Commits**: - `03c4234a0d0f9e934d5cd4f9a7e26e2c802385f9`: Initial refactoring - `26516e54f65086f0b1a081a4b4353ea40f4ae45b`: Added CHANGELOG.md update ### Code Quality ✅ Follows Python best practices: - No `type: ignore` comments added - Specific exception handling instead of bare `except` - Maintains backward compatibility - All defensive code retains `pragma: no cover` comments ### Next Steps PR creation pending - branch needs to be pushed to remote for PR creation. --- **Automated by CleverAgents Bot** Supervisor: Implementation Pool | Agent: implementation-pool-supervisor
Author
Owner

Implementation Status Update

PR Created: #8670

The pull request has been created and is ready for review. The branch refactor/add-return-type-get-services has been created on the remote and the PR is linked to this issue.

Summary of Changes

Refactoring completed:

  • Added return type annotation tuple[Any, Any | None] to _get_services() function
  • Replaced 4 bare except Exception: clauses with specific exception types:
    • (AttributeError, RuntimeError) in _compute_actor_impact() (3 locations)
    • (ValueError, AttributeError) in _load_config_text() (1 location)
  • Updated CHANGELOG.md with refactoring details

Code Quality Compliance

Follows all CONTRIBUTING.md requirements:

  • No type: ignore comments added
  • Specific exception handling (Python best practices)
  • CHANGELOG.md updated
  • CONTRIBUTORS.md already includes HAL9000
  • Conventional Changelog format used

Automated by CleverAgents Bot
Supervisor: Implementation Pool | Agent: implementation-pool-supervisor

## Implementation Status Update **PR Created**: #8670 The pull request has been created and is ready for review. The branch `refactor/add-return-type-get-services` has been created on the remote and the PR is linked to this issue. ### Summary of Changes ✅ **Refactoring completed:** - Added return type annotation `tuple[Any, Any | None]` to `_get_services()` function - Replaced 4 bare `except Exception:` clauses with specific exception types: - `(AttributeError, RuntimeError)` in `_compute_actor_impact()` (3 locations) - `(ValueError, AttributeError)` in `_load_config_text()` (1 location) - Updated CHANGELOG.md with refactoring details ### Code Quality Compliance ✅ Follows all CONTRIBUTING.md requirements: - No `type: ignore` comments added - Specific exception handling (Python best practices) - CHANGELOG.md updated - CONTRIBUTORS.md already includes HAL9000 - Conventional Changelog format used --- **Automated by CleverAgents Bot** Supervisor: Implementation Pool | Agent: implementation-pool-supervisor
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cleveragents/cleveragents-core#8567
No description provided.