Refactor relative imports in domain models to reduce coupling #6127

Open
opened 2026-04-09 15:17:20 +00:00 by HAL9000 · 0 comments
Owner

Summary

The domain models in src/cleveragents/domain/models/ use relative imports (from ..) to import from other modules at the same level. This creates tight coupling between the modules and makes the code harder to understand and maintain.

Problem

  • Tight Coupling: Relative imports create implicit dependencies between modules, making it harder to refactor or move them around.
  • Reduced Readability: It's not immediately clear where the imported modules are located without looking at the directory structure.
  • Potential for Circular Dependencies: Relative imports can sometimes lead to circular dependencies, which can cause runtime errors.

Proposed Solution

  • Use absolute imports: All imports in the domain models should be converted to absolute imports, starting from the root of the project (e.g., from cleveragents.domain.models.core.enums import ModelPublisher). This will make the dependencies explicit and easier to track.

Files to Update

A full review of the src/cleveragents/domain/models/ directory is recommended. Some of the files that need to be updated include:

  • src/cleveragents/domain/models/aimodels_custom/__init__.py
  • src/cleveragents/domain/models/aimodelscredentials/ai_models_credentials.py
  • src/cleveragents/domain/models/aimodelsdatamodels/__init__.py
  • src/cleveragents/domain/models/aimodelserrors/ai_models_errors.py
  • src/cleveragents/domain/models/aimodelsproviders/ai_models_providers.py
  • and many others.

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

## Summary The domain models in `src/cleveragents/domain/models/` use relative imports (`from ..`) to import from other modules at the same level. This creates tight coupling between the modules and makes the code harder to understand and maintain. ## Problem - **Tight Coupling:** Relative imports create implicit dependencies between modules, making it harder to refactor or move them around. - **Reduced Readability:** It's not immediately clear where the imported modules are located without looking at the directory structure. - **Potential for Circular Dependencies:** Relative imports can sometimes lead to circular dependencies, which can cause runtime errors. ## Proposed Solution - **Use absolute imports:** All imports in the domain models should be converted to absolute imports, starting from the root of the project (e.g., `from cleveragents.domain.models.core.enums import ModelPublisher`). This will make the dependencies explicit and easier to track. ## Files to Update A full review of the `src/cleveragents/domain/models/` directory is recommended. Some of the files that need to be updated include: - `src/cleveragents/domain/models/aimodels_custom/__init__.py` - `src/cleveragents/domain/models/aimodelscredentials/ai_models_credentials.py` - `src/cleveragents/domain/models/aimodelsdatamodels/__init__.py` - `src/cleveragents/domain/models/aimodelserrors/ai_models_errors.py` - `src/cleveragents/domain/models/aimodelsproviders/ai_models_providers.py` - and many others. --- **Automated by CleverAgents Bot** Supervisor: Architecture Guard | Agent: architecture-guard
freemo added the
Priority
Medium
label 2026-04-09 16:24:59 +00:00
freemo added the
State
In Progress
Type
Automation
labels 2026-04-09 16:27:28 +00:00
HAL9000 added the Automation Tracking label 2026-04-09 21:02:55 +00:00
freemo removed the Automation Tracking label 2026-04-13 16:22:43 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: cleveragents/cleveragents-core#6127