Skip to content

Commit 731397c

Browse files
committed
feat: log dummy and failing imports for manual cleanup guidance
1 parent c6ef97d commit 731397c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

main.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,15 @@ def exec_module(self, module):
7575
class DummyModuleFinder(importlib.abc.MetaPathFinder):
7676
def find_spec(self, fullname, path, target=None):
7777
if fullname in DUMMY_MODULE_NAMES:
78+
logging.warning(f"[DUMMY IMPORT] '{fullname}' is being replaced with DummyModule. "
79+
f"To clean up: remove or replace imports of '{fullname}' in your codebase.")
80+
return importlib.util.spec_from_loader(fullname, DummyModuleLoader())
81+
# If the import fails for any other reason, log it for manual cleanup
82+
try:
83+
return None # Let the normal import machinery try next
84+
except Exception as e:
85+
logging.error(f"[IMPORT FAILURE] Could not import '{fullname}': {e}")
7886
return importlib.util.spec_from_loader(fullname, DummyModuleLoader())
79-
return None
8087

8188
sys.meta_path.insert(0, DummyModuleFinder())
8289
# --- End Dynamic Dummy Import Hook ---

0 commit comments

Comments
 (0)