Deprecate QtWidgets accessed through QtGui#1915
Conversation
|
What should be done about Qt5.QtWidgets.QAction vs Qt6.QtGui.QAction? |
Ah, yeah, if so, then that's going to shout deprecation warnings at some users. I used We could whitelist |
225ff2d to
6d3131b
Compare
dc43b68 to
908c4bd
Compare
.pre-commit-config.yaml
Outdated
| - id: mixed-line-ending | ||
| args: [ --fix=lf ] | ||
| - repo: https://github.com/pycqa/isort | ||
| rev: 5.6.4 |
There was a problem hiding this comment.
any reason we don't use the current version (5.9.3?)
There was a problem hiding this comment.
no, I just copied what they had in their documentation.
There was a problem hiding this comment.
pre-commit autoupdate will fix that right up
should we also add the trailing-whitespace hook from the main pre-commit default repo? that will get rid of quite a bit of our style errs.
There was a problem hiding this comment.
I'm good w/ adding that; but I'm not convinced it should happen in this PR given the size of it (also our code quality issues look like they're going to go up by ~70 :( )
.pre-commit-config.yaml
Outdated
| args: [ '--maxkb=100' ] | ||
| - id: check-case-conflict | ||
| - id: end-of-file-fixer | ||
| - id: fix-encoding-pragma |
There was a problem hiding this comment.
Relaying a comment from @pijyoi but this should likely be
- id: fix-encoding-pragma
args: ['--remove']
As we no longer support py2, so we should be nuking those, not adding more of them
|
I'm glad this is being done, it's going to be painful to address the remaining open PRs, but it will be manageable. I think we should take the opportunity to remove the unused imports; at the very least the ones in the |
|
I was playing around on this branch; and ran into an issue. If we run
after # -*- coding: utf-8 -*-
from . import parameterTypes as types
from .Parameter import Parameter, registerParameterItemType, registerParameterType
from .ParameterItem import ParameterItem
from .ParameterSystem import ParameterSystem, SystemSolver
from .ParameterTree import ParameterTreeUnfortunately after the change, running pytest generates the following error: While we could mark the file for skip for isort purposes, we should probably try to resolve that issue whatever it may be. |
|
After More specifically: I suspect it has to do with some confusion between objects and modules judging by the errors. |
|
In from .. import ParameterItem, Parameterto from ..ParameterItem import ParameterItem
from ..Parameter import ParameterThe former relies on While browsing through that directory, I noticed that the following files were doing absolute instead of relative imports:
from pyqtgraph.Qt import QtWidgets
from pyqtgraph.parametertree.parameterTypes import WidgetParameterItem |
Nice catch (on both the non-relative imports and the import of Parameter and ParameterItem)! That indeed fixed the issue w/ ParameterItems; still have the issue with EDIT: dock related error was even simpler to resolve... now that EDIT 2: scratch that, some examples are failing. EDIT 3: Fixed, just needed to update the import for |
|
I got isort and pycln to run over the entire repo, test suite runs and passes, but still getting lots of warnings such as: @outofculture do you know of a good way we can detect these uses in an automated fashion? |
|
Was hoping to make more progress on this today; hopefully i'll make more of a go at it later tonight, the following are items available in PyQt5.QtWidgets but are not available in PyQt6.QtWidgets I found no items in PyQt6.QtWidgets that were not in PyQt5.QtWidgets Will check out QtGui next for a more exhaustive listing. |
10124c9 to
992e447
Compare
992e447 to
6d495bb
Compare
|
Thanks @outofculture ! LGTM! |
This adds the deprecation warning ( thanks @ntjess ) to the first attempted access, then migrates all our code to no longer use QtGui. The migration was semi-automated, using the following process:
python -c 'from PyQt6 import QtWidgets; print("\n".join([m for m in dir(QtWidgets) if m[0] == "Q"]))' > widget-namesfor m in $(cat widget-names); do for f in $(find tests/ examples/ pyqtgraph/ -name '*.py'); do sed -i "s/QtGui\.$m/QtWidgets.$m/g" $f; done; donesed -E -i 's/from pyqtgraph.Qt import .*QtGui/\0, QtWidgets/' $(find pyqtgraph/examples/ tests/ -name '*.py')sed -E -i 's/from \.+Qt import .*QtGui/\0, QtWidgets/' $(find pyqtgraph/ -name '*.py')This can hang out as a draft until the backlog is cleaned up a bit, and we can re-run the migration from scratch to avoid conflicts. We should also run
isorton all our files someday, as this adds a bunch of unused imports, but it's not too important.