pyapp-kit / superqt

Missing widgets and components for Qt-python
https://pyapp-kit.github.io/superqt/
BSD 3-Clause "New" or "Revised" License
207 stars 36 forks source link

fix: don't use AbstractContextManager for exceptions_as_dialog #234

Closed tlambert03 closed 8 months ago

tlambert03 commented 8 months ago

The use of contextlib.AbstractContextManager seems to be more trouble than useful. I occasionally see this error:

/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/superqt/utils/_errormsg_context.py:17: in <module>
    class exceptions_as_dialog(AbstractContextManager):
E   SystemError: <built-in method __prepare__ of type object at 0x7fc513f209a0> returned a result with an exception set
Error: The process '/Users/runner/hostedtoolcache/Python/3.11.8/x64/bin/python' failed with exit code 4

it's not necessary though, it implements the full protocol anyway

codecov[bot] commented 8 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 87.30%. Comparing base (56f65ff) to head (71588e9). Report is 1 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #234 +/- ## ========================================== + Coverage 87.29% 87.30% +0.01% ========================================== Files 46 46 Lines 3336 3332 -4 ========================================== - Hits 2912 2909 -3 + Misses 424 423 -1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

tlambert03 commented 8 months ago

unfortunately, this didn't fix it. here's the whole traceback:

ImportError while loading conftest '/Users/runner/work/pymmcore-plus/pymmcore-plus/pymmcore-plus/napari-micromanager/tests/conftest.py'.
tests/conftest.py:6: in <module>
    from napari_micromanager._util import NMM_METADATA_KEY
/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/napari_micromanager/__init__.py:10: in <module>
    from .main_window import MainWindow
/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/napari_micromanager/main_window.py:14: in <module>
    from ._core_link import CoreViewerLink
/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/napari_micromanager/_core_link.py:10: in <module>
    from superqt.utils import ensure_main_thread
/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/superqt/__init__.py:12: in <module>
    from .combobox import QColorComboBox, QEnumComboBox, QSearchableComboBox
/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/superqt/combobox/__init__.py:3: in <module>
    from ._color_combobox import QColorComboBox
/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/superqt/combobox/_color_combobox.py:20: in <module>
    from superqt.utils import signals_blocked
/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/superqt/utils/__init__.py:29: in <module>
    from ._errormsg_context import exceptions_as_dialog
/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/superqt/utils/_errormsg_context.py:16: in <module>
    class exceptions_as_dialog:
E   SystemError: <built-in method __prepare__ of type object at 0x10d7b62f0> returned a result with an exception set