← Back to issue list

Module import order matters, but shouldn't.

View original Github issue

Metadata

Project
craft-providers
Number
#262
Type
issue
State
open
Author
lengau
Labels
Type: Bug
Created
Updated
Closed

Current evaluation

Circular import between snap_installer and bases modules has been resolved through code refactoring.

Suggested action: close stale

Reason: The circular import issue is no longer reproducible. Code inspection shows instance_config was moved out of the bases package (now at craft_providers/instance_config.py instead of craft_providers/bases/instance_config.py), and snap_installer imports in centos.py are guarded by TYPE_CHECKING blocks, breaking the runtime circular dependency.

Impact: 65 Quick Win: 35.75 Staleness: 85 Complexity: 45 Confidence: 75 Support Request: 5

Issue body

This code: ```python from craft_providers.actions import snap_installer from craft_providers.bases import get_base_alias, get_base_from_alias ``` fails: ``` $ python3.8 test.py Traceback (most recent call last): File "test.py", line 1, in <module> from craft_providers.actions.snap_installer import Snap File "/home/lengau/Code/craft-application/.tox/test-py38/lib/python3.8/site-packages/craft_providers/actions/snap_installer.py", line 34, in <module> from craft_providers.bases.instance_config import InstanceConfiguration File "/home/lengau/Code/craft-application/.tox/test-py38/lib/python3.8/site-packages/craft_providers/bases/__init__.py", line 28, in <module> from . import centos File "/home/lengau/Code/craft-application/.tox/test-py38/lib/python3.8/site-packages/craft_providers/bases/centos.py", line 35, in <module> from craft_providers.actions.snap_installer import Snap, SnapInstallationError ImportError: cannot import name 'Snap' from partially initialized module 'craft_providers.actions.snap_installer' (most likely due to a circular import) (/home/lengau/Code/craft-application/.tox/test-py38/lib/python3.8/site-packages/craft_providers/actions/snap_installer.py) ``` But swapping the import order: ```python from craft_providers.bases import get_base_alias, get_base_from_alias from craft_providers.actions import snap_installer ``` succeeds.

Evaluation history

Date Model Scores Action Summary
qwen3.6-35b-a3b-mtp-q6
Impact: 65
Quick Win: 35.75
Staleness: 85
Complexity: 45
Confidence: 75
Support Request: 5
close stale Circular import between snap_installer and bases modules has been resolved through code refactoring.
qwen/qwen3.6-35b-a3b
Staleness: 75
Complexity: 45
Confidence: 85
Support Request: 5
needs triage Reports a circular import error in craft_providers that depends on import order. Open for over three years with no maintainer assessment or resolution.
qwen3.6-35b-a3b-mtp-q6
Staleness: 90
Complexity: 25
Confidence: 70
Support Request: 10
close stale Circular import error requires specific module import order. Open for over three years with no maintainer resolution or progress.
qwen3.6-35b-a3b-mtp-q6
Staleness: 85
Complexity: 40
Confidence: 75
Support Request: 10
needs triage Circular import error in craft_providers that depends on module import order. Reported 3 years ago with a reproduction case, but lacks maintainer assessment or resolution.

Update history

No update history recorded yet.

Related issues

No related issues found above the similarity threshold.