Skip to content

PR: Use raise from None when raising QtBindingsNotFoundError in __init__#391

Merged
dalthviz merged 1 commit intospyder-ide:masterfrom
CAM-Gerlach:fix-bindingsnotfound-handling
Dec 18, 2022
Merged

PR: Use raise from None when raising QtBindingsNotFoundError in __init__#391
dalthviz merged 1 commit intospyder-ide:masterfrom
CAM-Gerlach:fix-bindingsnotfound-handling

Conversation

@CAM-Gerlach
Copy link
Copy Markdown
Member

As described in #390 , this fixes the raise QtBindingsNotFoundError in __init__,py to correctly use raise ... from None, to ensure it behaves appropriately and has a clear, understandable and non-confusing message.

Here's how the error output looked previously:

>>> 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 looks now:

>>> 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

Fixes #390

Copy link
Copy Markdown
Member

@dalthviz dalthviz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @CAM-Gerlach !

@dalthviz dalthviz merged commit 371ec52 into spyder-ide:master Dec 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

QtBindingsNotFoundError is not raised correctly (from None) in __init__

2 participants