-
Notifications
You must be signed in to change notification settings - Fork 256
Add site customization of _common_members #207
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
Conversation
| def test_add_site_members(): | ||
| import Qt | ||
| try: | ||
| from Qt import QtGui |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'Qt.QtGui' imported but unused
| return _common_members | ||
|
|
||
| def test_add_site_members(): | ||
| import Qt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'Qt' imported but unused
| ] | ||
| return _common_members | ||
|
|
||
| def test_add_site_members(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expected 2 blank lines, found 1
| customize available modules for Qt.py without modifying the Qt.py package. | ||
| """ | ||
|
|
||
| def update_common_members(_common_members): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expected 2 blank lines, found 1
Qt.py
Outdated
| try: | ||
| import Qt_site_config | ||
| except ImportError: | ||
| # If no Qt_site_config module found, no modifications to _common_members |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (80 > 79 characters)
Qt.py
Outdated
| ] | ||
| } | ||
|
|
||
| def _add_site_members(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expected 2 blank lines, found 1
| def test_add_site_members(): | ||
| import Qt | ||
| try: | ||
| from Qt import QtGui |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'Qt.QtGui' imported but unused
| return _common_members | ||
|
|
||
| def test_add_site_members(): | ||
| import Qt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'Qt' imported but unused
| ] | ||
| return _common_members | ||
|
|
||
| def test_add_site_members(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expected 2 blank lines, found 1
| customize available modules for Qt.py without modifying the Qt.py package. | ||
| """ | ||
|
|
||
| def update_common_members(_common_members): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expected 2 blank lines, found 1
Qt.py
Outdated
| try: | ||
| import Qt_site_config | ||
| except ImportError: | ||
| # If no Qt_site_config module found, no modifications to _common_members |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (80 > 79 characters)
Qt.py
Outdated
| ] | ||
| } | ||
|
|
||
| def _add_site_members(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expected 2 blank lines, found 1
|
|
||
| def test_add_site_members(): | ||
| try: | ||
| from Qt import QtGui |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'Qt.QtGui' imported but unused
|
Thanks @MHendricks for this! I'm not too fond of underscores in the module name (
However, since we are conforming to CamelCase to make Qt.py blend into Qt land. Could you please expand on any reasoning behind this or if you would mind changing it into e.g. A bit on documentation:
But other than these minor things, thanks for this nice contribution! @mottosso what do you think? |
|
Hi @MHendricks, There was a change made recently, March this year, to enable optional submodules to become part of Qt.py, without causing trouble for those that did not have the implementation available locally. I think this would be the preferable method of adding these members and you are welcome to do so. In practice, anything present in |
|
@mottosso so what you're saying is we should just add e.g. Previously, I think we've only discussed members which we know are included in the more regular type of compilation of Qt. In this case I believe that e.g. This means these members are most likely not available for the "common user"... and I wonder if these should really be added to the |
That's right, this will still work. There's reasoning behind how and why in the PR and original issue, but in a nutshell, Qt.py should encompass all of PySide2 which should encompass all of Qt in some shape or form. Currently the various distributions of PySide2 vary greatly, with even basic submodules missing, like That said, I'm not expecting us to add any submodules that aren't related to PySide2. |
|
I also don't like underscores, so I'm happy to rename the module to QtSiteConfig. I can also make the other changes requested.
Heh, along those lines I need to make use of QVariant from PyQt so we have access to the type enums Do you want to proceed with the direction of this pull request, or should I make a new one that just adds the Qsci and QJsonDocument to the existing _common_members? |
|
Have you considered using those members via from PyQt4 import QtCore
assert QtCore.QVariant.Date == QtCore.QMetaType.QDate
I'm not sure yet, on one hand there isn't any harm to existing functionality by introducing this functionality but on the other it may open the floodgates to code not usable by anyone other than the original author if code written with this "extension" in place gets into the wild. For example, if the developers at your studio are first introduced to Qt.py when extended in this manner are later expecting to write software on their own or to help others write software, then if there is suddenly this "hidden addition" that only the original author knows about it may create more issues than it solves. I think the ideal scenario was if you could find away to migrate your use of
|
|
I talked with our Qt developer and it looks like we should be able to migrate to QMetaType and away from QVariant. I went ahead and addressed @fredrikaverpil comments in case we end up merging this pull request. |
Thanks @MHendricks :) @mottosso you decide which route to take here. Either way is fine by me, really. I just reacted to the fact that these particular modules are most often not part of PySide2 and probably never will be in the most popular DCC apps. On the other hand, if you need to use them you might already be aware of this fact. On a slightly different note, I like the idea of being able to customize Qt.py without actually having to maintain code changes to the Qt.py file itself. The question here is: would it really be useful to be able to customize e.g. the Perhaps the best way forward would be to just add these members to Qt.py but make inline comments about modules which are not compiled by default? |
|
Hi @MHendricks, I had a look at the documentation you've made and gave the implementation a try, I think it's solid. I made a few tweaks to the API, namely:
I've also gone ahead and added Let me know what you think. |
|
Was going to add some motivation for the changes but ran out of time; I found some so here goes! I renamed I removed the return statement, as it didn't seem needed and removing it simplified the method in which the functions needed to be written. As the function no longer needed to return, it was no longer necessary to assign it in the Finally, I renamed the private function |
|
I wondered if you could just modify the passed in dict. One of the reasons I left it in there is that it made it clear to understand that the function was modifying _common_members by looking at the code. However, I dislike using global if I can avoid it, so I'm happy with the changes. I went ahead and fixed a few broken links from the rename. Everything looks good to me. |
|
@MHendricks @mottosso Headsup, guys. It seems |
We make use of optional Qt libraries at Blur Studio, Qsci and QtCore.QJsonDocument. It would be nice to be able to opt-into being able to use those modules. Ideally in a way where we don't have to maintain our own fork of Qt.py. It also means that we don't need to define imports of these modules outside of the Qt object.
To make this happen I made Qt.py attempt to import the python module Qt_site_config. If it can import the module it calls Qt_site_config.update_common_members(_common_members) and updates _common_members with the returned value.