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
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#6127
No description provided.