name: import-fixer description: Fix import statements across the codebase to align with clean architecture layer boundaries. Use when: fixing imports, layer boundary violations, circular import issues, deprecated core imports, import order rules.
Import Fixer
Fix imports to follow clean architecture principles.
Common Issues
Deprecated Core Imports
# WRONG (deprecated):
from casare_rpa.core.types import DataType
# CORRECT:
from casare_rpa.domain.value_objects.types import DataType
Layer Violations
# WRONG: Presentation importing Infrastructure
from casare_rpa.infrastructure.resources import BrowserResourceManager
# CORRECT: Presentation imports from Application
from casare_rpa.application.use_cases import ExecuteWorkflowUseCase
Circular Dependencies
# Use TYPE_CHECKING for type hints only
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from module_b import ClassB
class ClassA:
def use_b(self) -> 'ClassB':
from module_b import ClassB # Import at runtime
return ClassB()
Import Order
- Standard library
- Third-party
- Local application
# 1. Standard library
import os
from typing import Any
# 2. Third-party
from loguru import logger
from PySide6.QtCore import Qt
# 3. Local
from casare_rpa.domain.value_objects import ExecutionResult
Layer Rules
Presentation → Application → Domain ← Infrastructure
Forbidden:
- Domain → Infrastructure
- Domain → Application
- Domain → Presentation
- Infrastructure → Presentation
Verification
# Check for deprecated imports
grep -r "from casare_rpa.core" src/ tests/
# Check domain violations
grep -r "from casare_rpa.infrastructure" src/casare_rpa/domain/
# Check for circular dependencies
pydeps src/casare_rpa --show-cycles