fix: QScreen ImportError + GUI import smoke tests #2
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/qscreen-import"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fix: QScreen ImportError when clicking tray icon
The bug
QScreenwas imported fromPySide6.QtWidgetsinside the_show_panel()method body, butQScreenlives inPySide6.QtGui. This caused anImportErrorevery time the tray icon was clicked.Root cause
Inline imports in method bodies hide import errors from the test suite — they only trigger at runtime on specific code paths. The existing 36 tests all passed because none of them exercised the GUI import paths.
The fix
QScreenandQCursorto module-level imports from the correct module (PySide6.QtGui)QSvgRendererfromPySide6.QtSvg(was inline in_load_svg_icon)from PySide6... import ...statements from method bodiesNew tests:
test_gui_imports.py(7 tests)These tests exist specifically to prevent this class of bug:
test_qtcore_imports_resolvetest_qtgui_imports_resolvetest_qtwidgets_imports_resolvetest_qtsvg_imports_resolvetest_qscreen_not_in_qtwidgetstest_main_module_imports_without_errortest_no_inline_imports_in_methodsfrom PySide6... importinside method bodies43 tests total, all passing.
You're right that this should have been caught — the GUI code had zero import coverage. These tests now guard every PySide6 symbol and enforce that imports are at module level where static analysis can see them.
Pull request closed