Skip to content

Commit e114c84

Browse files
committed
Convert exec_ calls to exec and remove compat checks
Note: This change breaks support for Qt4 and older versions of Qt5. exec_ was a reserved keyword in python 2, its not in python 3. PyQt6 has dropped support for exec_ and its deprecated in PySide6. Modern Qt5 supports both. This requires disabling py2-3 compatibility checking as modernize doesn't like using `exec` as a object property. I'm also removing the compileall check as it's assumed that the linting flake8/black checks will cover checking for syntax errors.
1 parent 947682b commit e114c84

File tree

7 files changed

+8
-23
lines changed

7 files changed

+8
-23
lines changed

.github/workflows/static-analysis-and-test.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,6 @@ jobs:
3535
- name: Format with black
3636
run: tox -e black
3737

38-
- name: Py 2 and 3 compatibility
39-
run: tox -e modernize
40-
41-
4238
test:
4339
# We want to run on external PRs, but not on our own internal PRs as they'll
4440
# be run by the push to the branch. Without this if check, checks are

preditor/debug.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def send_logger_error(self, exc_info):
190190
ConsolePrEdit._errorPrompted = True
191191
errorDialog = ErrorDialog(root_window())
192192
errorDialog.setText(exc_info)
193-
errorDialog.exec_()
193+
errorDialog.exec()
194194

195195
# interruptted until dialog closed
196196
finally:

preditor/gui/dialog.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def closeEvent(self, event):
140140
except TypeError:
141141
pass
142142

143-
def exec_(self):
143+
def exec(self):
144144
# do not use the DeleteOnClose attribute when executing a dialog as often times
145145
# a user will be accessing information from the dialog instance after it closes.
146146
# This function properly transfers ownership of the dialog instance back to
@@ -149,7 +149,7 @@ def exec_(self):
149149
self.setAttribute(Qt.WidgetAttribute.WA_DeleteOnClose, False)
150150

151151
# execute the dialog
152-
return QDialog.exec_(self)
152+
return super().exec()
153153

154154
def setGeometry(self, *args):
155155
"""

preditor/gui/drag_tab_bar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def mouseMoveEvent(self, event): # noqa: N802
5454
drag.setHotSpot(event_pos - pos_in_tab)
5555
cursor = QCursor(Qt.CursorShape.OpenHandCursor)
5656
drag.setDragCursor(cursor.pixmap(), Qt.DropAction.MoveAction)
57-
action = drag.exec_(Qt.DropAction.MoveAction)
57+
action = drag.exec(Qt.DropAction.MoveAction)
5858
# If the user didn't successfully add this to a new tab widget, restore
5959
# the tab to the original location.
6060
if action == Qt.DropAction.IgnoreAction:

preditor/gui/errordialog.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def submitRequest(self):
8484
# If that failed, we will use a dialog to prompt for credentials.
8585
except ImpersonateError:
8686
dialog = RedmineLoginDialog(parent=self)
87-
result = dialog.exec_()
87+
result = dialog.exec()
8888
if result == QDialog.DialogCode.Accepted:
8989
kwargs.update(
9090
{

preditor/gui/loggerwindow.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ def setup_run_workbox(self):
486486

487487
def openSetPreferredTextEditorDialog(self):
488488
dlg = SetTextEditorPathDialog(parent=self)
489-
dlg.exec_()
489+
dlg.exec()
490490

491491
def focusToConsole(self):
492492
"""Move focus to the console"""
@@ -867,7 +867,7 @@ def maybeDisplayDialog(self, dialog):
867867
if dialog.objectName() in self.dont_ask_again:
868868
return
869869

870-
dialog.exec_()
870+
dialog.exec()
871871

872872
def restartLogger(self):
873873
"""Closes this PrEditor instance and starts a new process with the same

tox.ini

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = modernize,begin,py{27,36,37,38,39,310,311},end,black,flake8
2+
envlist = begin,py{27,36,37,38,39,310,311},end,black,flake8
33
skip_missing_interpreters = True
44
skipsdist = True
55

@@ -25,17 +25,6 @@ commands =
2525

2626
coverage run -m pytest {tty:--color=yes} {posargs:tests/}
2727

28-
[testenv:modernize]
29-
# Test compatibility with python 2 and 3
30-
deps =
31-
modernize
32-
commands =
33-
# Check for python 3 compliance
34-
python -m compileall -f -q -x \.tox|shared-venv .
35-
# Note: `-f numliterals -f except -f dict_six` always report failure so we can't include them
36-
# in this test.
37-
python -m modernize -f print -f import -f basestring -f unicode_type --enforce ./preditor
38-
3928
[testenv:begin]
4029
basepython = python3
4130
deps =

0 commit comments

Comments
 (0)