-
Notifications
You must be signed in to change notification settings - Fork 252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
headerToModule() is destructive when CustomWidget path is a Python . path #401
Comments
Happy with this change, so long as there's a test for these two cases in https://github.com/mottosso/Qt.py/blob/master/tests.py |
The following test cases are what I believe are appropriate inputs/results based on current code expectation and also addressed the bug:
Should Qt.py attempt to correct malformed input? If the end user entered the malformed data, I'd expect it to fail in PyQt -- so expecting that Qt.py would behave the same? I'm surprised that Qt.py has to do any .h manipulation as well -- but I don't have an example to test so have kept the 'functionality'. |
I can't quite recall how this functionality ended up in Qt.py to begin with (you can use the "Blame" button to find out) but yes, ideally it should act just like PySide2 (not PyQt5). It's important that anything written with Qt.py should be able to search-and-place with |
It appears that there was a Qt.py appears to have 'worked' around the issue 2 years prior to the bug being fixed? In any case the 'headerToModule' function manipulates a path that likely shouldn't be fixed at the Qt.py level. The author should really be responsible for putting in the correctly formatted path into the .ui file. However, its hard to know who is relying on the functionality now. Let me know if there is any additional tests that should be written. Or something else that would alleviate any concerns. |
Simplified the PR somewhat and the test is now an integration test instead of a unit test. The code path first attempt to use the 'header' as authored by the user (new). If it fails to import properly, it will use the original headerToModule(...). So functionality should be what people expect and support python . paths. |
In the following function:
This will break imports if they were written in Python as the structure of the custom widget is "path.to.module"
Since the function always expects a path and a .h extension -- the above is destructive and removes the
.module
in my example above. Custom widgets are not possible if using Python to author the custom widget with Qt.pyPossible Fix?
Patch the Qt.py:
module = os.path.splitext(header)[0] if header.endswith(".h") else header
The issue here is that if its a python module you simply can't use '.h' as a module name. Its a
gotcha
with the above.The text was updated successfully, but these errors were encountered: