File: typing.py

package info (click to toggle)
setools 4.6.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,600 kB
  • sloc: python: 24,485; makefile: 14
file content (27 lines) | stat: -rw-r--r-- 859 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# SPDX-License-Identifier: LGPL-2.1-only

import abc

from PyQt6 import QtCore, QtGui

# These are all of the return types for the standard QtCore.Qt.ItemDataRole roles
# for the data method in the models.
AllStdDataTypes = str | QtGui.QColor | QtGui.QIcon | QtGui.QPixmap | QtCore.QSize | \
    QtGui.QFont | QtCore.Qt.AlignmentFlag | QtGui.QBrush | QtCore.Qt.CheckState | \
    QtCore.Qt.SortOrder | None

# This is the return type for the ModelRoles.ContextMenuRole role
ContextMenuType = tuple[QtGui.QAction, ...]


class MetaclassFix(type(QtCore.QObject), abc.ABC):  # type: ignore[misc]

    """
    Fix metaclass issues.

    Use this when doing a Generic[] with a PyQt type. Fixes this error:

    TypeError: metaclass conflict: the metaclass of a derived class must be a
    (non-strict) subclass of the metaclasses of all its bases
    """
    pass