Skip to content

Commit a1e83f0

Browse files
committed
mypy: Use class-based API for enum.IntEnum
See python/mypy#4865
1 parent 563e1e8 commit a1e83f0

5 files changed

Lines changed: 35 additions & 13 deletions

File tree

‎qutebrowser/browser/downloads.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@
4040
from qutebrowser.qt import sip
4141

4242

43-
ModelRole = enum.IntEnum('ModelRole', ['item'], start=Qt.UserRole)
43+
class ModelRole(enum.IntEnum):
44+
45+
"""Custom download model roles."""
46+
47+
item = Qt.UserRole
4448

4549

4650
# Remember the last used directory

‎qutebrowser/mainwindow/tabwidget.py‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,11 @@
3737
from qutebrowser.browser import browsertab
3838

3939

40-
PixelMetrics = enum.IntEnum('PixelMetrics', ['icon_padding'],
41-
start=QStyle.PM_CustomBase)
40+
class PixelMetrics(enum.IntEnum):
41+
42+
"""Custom PixelMetrics attributes."""
43+
44+
icon_padding = QStyle.PM_CustomBase
4245

4346

4447
class TabWidget(QTabWidget):

‎qutebrowser/misc/backendproblem.py‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,14 @@
3838
from qutebrowser.misc import objects, msgbox
3939

4040

41-
_Result = enum.IntEnum(
42-
'_Result',
43-
['quit', 'restart', 'restart_webkit', 'restart_webengine'],
44-
start=QDialog.Accepted + 1)
41+
class _Result(enum.IntEnum):
42+
43+
"""The result code returned by the backend problem dialog."""
44+
45+
quit = QDialog.Accepted + 1
46+
restart = QDialog.Accepted + 2
47+
restart_webkit = QDialog.Accepted + 3
48+
restart_webengine = QDialog.Accepted + 4
4549

4650

4751
@attr.s

‎qutebrowser/misc/crashdialog.py‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,12 @@
4242
from qutebrowser.config import config, configfiles
4343

4444

45-
Result = enum.IntEnum('Result', ['restore', 'no_restore'],
46-
start=QDialog.Accepted + 1)
45+
class Result(enum.IntEnum):
46+
47+
"""The result code returned by the crash dialog."""
48+
49+
restore = QDialog.Accepted + 1
50+
no_restore = QDialog.Accepted + 2
4751

4852

4953
def parse_fatal_stacktrace(text):

‎qutebrowser/utils/usertypes.py‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,17 @@ def reset(self):
221221
'jump_mark', 'record_macro', 'run_macro'])
222222

223223

224-
# Exit statuses for errors. Needs to be an int for sys.exit.
225-
Exit = enum.IntEnum('Exit', ['ok', 'reserved', 'exception', 'err_ipc',
226-
'err_init', 'err_config', 'err_key_config'],
227-
start=0)
224+
class Exit(enum.IntEnum):
225+
226+
"""Exit statuses for errors. Needs to be an int for sys.exit."""
227+
228+
ok = 0
229+
reserved = 1
230+
exception = 2
231+
err_ipc = 3
232+
err_init = 4
233+
err_config = 5
234+
err_key_config = 6
228235

229236

230237
# Load status of a tab

0 commit comments

Comments
 (0)