Skip to content

QtBindingsNotFoundError is not raised correctly (from None) in __init__ #390

@CAM-Gerlach

Description

@CAM-Gerlach

As a followup to issue #367 and PR #379 , I wasn't available to review the latter at the time, but the corrected fix discussed in the former (using raise QtBindingsNotFoundError from None) didn't end up getting implemented, as opposed to the original naive version with several issues. we discussed on the issue that solves the two problems I pointed out with the initial naive implementation was not implemented, making the error/traceback message and behavior more appropriate and less confusing,

Currently, it is treated and printed as an unexpected error during error handling rather than a intentional wrapper error (with raise from), and furthermore prints the error message and traceback from importing pyside6, making users think it was incorrectly trying to use that binding instead of the one they selected.

Here's how the error output looks now:

>>> import qtpy.QtCore
Traceback (most recent call last):
  File "C:\Users\C. A. M. Gerlach\Documents\dev\SpyderDev\qtpy\qtpy\__init__.py", line 252, in <module>
    from PySide6 import __version__ as PYSIDE_VERSION  # analysis:ignore
ModuleNotFoundError: No module named 'PySide6'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\C. A. M. Gerlach\Documents\dev\SpyderDev\qtpy\qtpy\__init__.py", line 259, in <module>
    raise QtBindingsNotFoundError()
qtpy.QtBindingsNotFoundError: No Qt bindings could be found

and here's how it should look with the correct raise QtBindingsNotFoundError from None:

>>> import qtpy.QtCore
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\C. A. M. Gerlach\Documents\dev\SpyderDev\qtpy\qtpy\__init__.py", line 259, in <module>
    raise QtBindingsNotFoundError from None
qtpy.QtBindingsNotFoundError: No Qt bindings could be found

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions