Compare commits

..
Author SHA1 Message Date
Mikaël Capelle 33b7222b13 Fix enabledByDefault(). 2022-04-22 12:19:47 +02:00
Mikaël Capelle e083e0832e Linting. 2022-04-21 22:03:21 +02:00
Mikaël Capelle 478af17c58 Fix PyQt5 -> PyQt6. 2022-04-21 21:40:18 +02:00
9 changed files with 85 additions and 57 deletions
+2 -1
View File
@@ -17,7 +17,7 @@ ignores:
mobase:
# Version of the stubs.
__version__: 2.5.0.dev0
__version__: 2.5.0.dev2
getFileVersion:
__doc__: Retrieve the file version of the given executable.
@@ -1814,6 +1814,7 @@ mobase:
returns: True if the plugin was initialized correctly, False otherwise.
enabledByDefault:
abstract: false
__doc__: Check whether this plugin should be enabled by default.
returns: True if this plugin should be enabled by default, False otherwise.
+2 -1
View File
@@ -15,6 +15,7 @@ def load_module(name: str, path: Path):
# Extract the spec:
spec = importlib.util.spec_from_loader(name, loader)
assert spec is not None
# Create the module and execute it?
module = importlib.util.module_from_spec(spec)
@@ -53,7 +54,7 @@ def load_mobase(path: Path, moprivate: bool = False):
os.add_dll_directory(str(path)) # type: ignore[attr-defined]
os.add_dll_directory(str(path.joinpath("dlls"))) # type: ignore[attr-defined]
# We need to add plugins/data to sys.path, mainly for PyQt5
# We need to add plugins/data to sys.path, mainly for PyQt6
sys.path.insert(1, path.joinpath("plugins", "data").as_posix())
mobase = load_module("mobase", path.joinpath("plugins", "data", "pythonrunner.dll"))
+3 -3
View File
@@ -119,9 +119,9 @@ class CType(Type):
REPLACEMENTS = {
"QString": "str",
"QStringList": "List[str]",
"QWidget *": "PyQt5.QtWidgets.QWidget",
"QMainWindow *": "PyQt5.QtWidgets.QMainWindow",
"QObject *": "PyQt5.QtCore.QObject",
"QWidget *": "PyQt6.QtWidgets.QWidget",
"QMainWindow *": "PyQt6.QtWidgets.QMainWindow",
"QObject *": "PyQt6.QtCore.QObject",
"void *": "object",
"api::object": "object",
}
+17 -6
View File
@@ -6,8 +6,19 @@ from collections import OrderedDict, defaultdict
from typing import Dict, List, Optional, Tuple, Union
from . import logger
from .mtypes import (Arg, Class, Constant, CType, Enum, Function, Method,
Property, PyClass, Ret, Type)
from .mtypes import (
Arg,
Class,
Constant,
CType,
Enum,
Function,
Method,
Property,
PyClass,
Ret,
Type,
)
from .register import MobaseRegister
@@ -193,9 +204,9 @@ def parse_psig(s: str, name: str) -> Tuple[Type, List[Arg]]:
n: str = pa.strip()
d: Optional[str] = None
if pa.find("=") != -1:
n, d = pa.split("=")
n, ds = pa.split("=")
n = n.strip()
d = d.strip()
d = ds.strip()
elif i > len(args) - c - 1:
d = Arg.DEFAULT_NONE
pargs.append(Arg(n, Type(t), d))
@@ -572,10 +583,10 @@ def make_class(fullname: str, e: type, register: MobaseRegister) -> Class:
if e.__name__.endswith("Widget"):
logger.info(
"Forcing base {} for class {}.".format(
"PyQt5.QtWidgets.QWidget", e.__name__
"PyQt6.QtWidgets.QWidget", e.__name__
)
)
direct_bases.append(PyClass("PyQt5.QtWidgets.QWidget"))
direct_bases.append(PyClass("PyQt6.QtWidgets.QWidget"))
return Class(
e.__name__,
+12 -2
View File
@@ -1,8 +1,18 @@
# -*- encoding: utf-8 -*-
from collections import OrderedDict, defaultdict
from typing import (TYPE_CHECKING, Any, Dict, List, NamedTuple, Optional, Set,
TextIO, Tuple, Union)
from typing import (
TYPE_CHECKING,
Any,
Dict,
List,
NamedTuple,
Optional,
Set,
TextIO,
Tuple,
Union,
)
import yaml
+3 -3
View File
@@ -134,9 +134,9 @@ with open(args.output, "w") as output:
"Type",
],
),
"PyQt5.QtCore",
"PyQt5.QtGui",
"PyQt5.QtWidgets",
"PyQt6.QtCore",
"PyQt6.QtGui",
"PyQt6.QtWidgets",
]
)
+10 -3
View File
@@ -15,19 +15,26 @@ warn_return_any = True
warn_unused_configs = True
namespace_packages = True
[isort]
profile = black
multi_line_output = 3
[tox:tox]
skipsdist = true
envlist = py38-lint
envlist = py310-lint
[testenv:py38-lint]
[testenv:py310-lint]
skip_install = true
deps =
black
mypy
flake8
flake8-black
PyQt5-stubs
git+https://github.com/TilmanK/PyQt6-stubs.git
types-PyYAML
isort
commands =
black generator main.py --check --diff
flake8 generator main.py
mypy generator main.py
isort -c generator main.py
+18 -19
View File
@@ -1,4 +1,4 @@
__version__ = "2.5.0.dev0"
__version__ = "2.5.0.dev2"
import abc
from enum import Enum
@@ -15,9 +15,9 @@ from typing import (
TypeVar,
Type,
)
import PyQt5.QtCore
import PyQt5.QtGui
import PyQt5.QtWidgets
import PyQt6.QtCore
import PyQt6.QtGui
import PyQt6.QtWidgets
MoVariant = Union[None, bool, int, str, List[Any], Dict[str, Any]]
GameFeatureType = TypeVar("GameFeatureType")
@@ -1663,7 +1663,7 @@ class IModRepositoryBridge(PyQt5.QtCore.QObject):
trackingToggled: PyQt6.QtCore.pyqtSignal = ...
requestFailed: PyQt6.QtCore.pyqtSignal = ...
def _object(self) -> PyQt5.QtCore.QObject:
def _object(self) -> PyQt6.QtCore.QObject:
"""
Returns:
The underlying `QObject` for the bridge.
@@ -2082,7 +2082,7 @@ class IOrganizer:
"""
...
def onUserInterfaceInitialized(
self, callback: Callable[[PyQt5.QtWidgets.QMainWindow], None]
self, callback: Callable[[PyQt6.QtWidgets.QMainWindow], None]
) -> bool:
"""
Install a new handler to be called when the UI has been fully initialized.
@@ -2294,7 +2294,6 @@ class IPlugin(abc.ABC):
The description for this plugin.
"""
...
@abc.abstractmethod
def enabledByDefault(self) -> bool:
"""
Check whether this plugin should be enabled by default.
@@ -2919,7 +2918,7 @@ class IPluginInstaller(IPlugin):
manager: The installation manager.
"""
...
def setParentWidget(self, parent: PyQt5.QtWidgets.QWidget):
def setParentWidget(self, parent: PyQt6.QtWidgets.QWidget):
"""
Set the parent widget for this installer.
@@ -2946,7 +2945,7 @@ class IPluginInstallerCustom(IPluginInstaller):
The installation manager.
"""
...
def _parentWidget(self) -> PyQt5.QtWidgets.QWidget:
def _parentWidget(self) -> PyQt6.QtWidgets.QWidget:
"""
Returns:
The parent widget.
@@ -3014,7 +3013,7 @@ class IPluginInstallerSimple(IPluginInstaller):
The installation manager.
"""
...
def _parentWidget(self) -> PyQt5.QtWidgets.QWidget:
def _parentWidget(self) -> PyQt6.QtWidgets.QWidget:
"""
Returns:
The parent widget.
@@ -3250,7 +3249,7 @@ class IPluginList:
class IPluginModPage(IPlugin):
def __init__(self): ...
def _parentWidget(self) -> PyQt5.QtWidgets.QWidget:
def _parentWidget(self) -> PyQt6.QtWidgets.QWidget:
"""
Returns:
The parent widget.
@@ -3296,7 +3295,7 @@ class IPluginModPage(IPlugin):
The URL to open when the user wants to visit this mod page.
"""
...
def setParentWidget(self, parent: PyQt5.QtWidgets.QWidget):
def setParentWidget(self, parent: PyQt6.QtWidgets.QWidget):
"""
Set the parent widget for this mod page.
@@ -3330,7 +3329,7 @@ class IPluginPreview(IPlugin):
@abc.abstractmethod
def genFilePreview(
self, filename: str, max_size: PyQt6.QtCore.QSize
) -> PyQt5.QtWidgets.QWidget:
) -> PyQt6.QtWidgets.QWidget:
"""
Generate a preview for the specified file.
@@ -3403,7 +3402,7 @@ class IPluginTool(IPlugin):
"""
def __init__(self): ...
def _parentWidget(self) -> PyQt5.QtWidgets.QWidget:
def _parentWidget(self) -> PyQt6.QtWidgets.QWidget:
"""
Returns:
The parent widget.
@@ -3429,7 +3428,7 @@ class IPluginTool(IPlugin):
The icon for this tool, or a default-constructed QICon().
"""
...
def setParentWidget(self, parent: PyQt5.QtWidgets.QWidget):
def setParentWidget(self, parent: PyQt6.QtWidgets.QWidget):
"""
Set the parent widget for this tool.
@@ -3548,18 +3547,18 @@ class ISaveGame:
"""
...
class ISaveGameInfoWidget(PyQt5.QtWidgets.QWidget):
class ISaveGameInfoWidget(PyQt6.QtWidgets.QWidget):
"""
Base class for a save game info widget.
"""
def __init__(self, parent: PyQt5.QtWidgets.QWidget = None):
def __init__(self, parent: PyQt6.QtWidgets.QWidget = None):
"""
Args:
parent: Parent widget.
"""
...
def _widget(self) -> PyQt5.QtWidgets.QWidget:
def _widget(self) -> PyQt6.QtWidgets.QWidget:
"""
Returns:
The underlying `QWidget`.
@@ -3994,7 +3993,7 @@ class SaveGameInfo(abc.ABC):
...
@abc.abstractmethod
def getSaveGameWidget(
self, parent: PyQt5.QtWidgets.QWidget
self, parent: PyQt6.QtWidgets.QWidget
) -> Optional["ISaveGameInfoWidget"]:
"""
Retrieve a widget to display over the save game list.
+18 -19
View File
@@ -1,4 +1,4 @@
__version__ = "2.5.0.dev0"
__version__ = "2.5.0.dev2"
import abc
from enum import Enum
@@ -15,9 +15,9 @@ from typing import (
TypeVar,
Type,
)
import PyQt5.QtCore
import PyQt5.QtGui
import PyQt5.QtWidgets
import PyQt6.QtCore
import PyQt6.QtGui
import PyQt6.QtWidgets
MoVariant = Union[None, bool, int, str, List[Any], Dict[str, Any]]
GameFeatureType = TypeVar("GameFeatureType")
@@ -1663,7 +1663,7 @@ class IModRepositoryBridge(PyQt5.QtCore.QObject):
trackingToggled: PyQt6.QtCore.pyqtSignal = ...
requestFailed: PyQt6.QtCore.pyqtSignal = ...
def _object(self) -> PyQt5.QtCore.QObject:
def _object(self) -> PyQt6.QtCore.QObject:
"""
Returns:
The underlying `QObject` for the bridge.
@@ -2082,7 +2082,7 @@ class IOrganizer:
"""
...
def onUserInterfaceInitialized(
self, callback: Callable[[PyQt5.QtWidgets.QMainWindow], None]
self, callback: Callable[[PyQt6.QtWidgets.QMainWindow], None]
) -> bool:
"""
Install a new handler to be called when the UI has been fully initialized.
@@ -2294,7 +2294,6 @@ class IPlugin(abc.ABC):
The description for this plugin.
"""
...
@abc.abstractmethod
def enabledByDefault(self) -> bool:
"""
Check whether this plugin should be enabled by default.
@@ -2919,7 +2918,7 @@ class IPluginInstaller(IPlugin):
manager: The installation manager.
"""
...
def setParentWidget(self, parent: PyQt5.QtWidgets.QWidget):
def setParentWidget(self, parent: PyQt6.QtWidgets.QWidget):
"""
Set the parent widget for this installer.
@@ -2946,7 +2945,7 @@ class IPluginInstallerCustom(IPluginInstaller):
The installation manager.
"""
...
def _parentWidget(self) -> PyQt5.QtWidgets.QWidget:
def _parentWidget(self) -> PyQt6.QtWidgets.QWidget:
"""
Returns:
The parent widget.
@@ -3014,7 +3013,7 @@ class IPluginInstallerSimple(IPluginInstaller):
The installation manager.
"""
...
def _parentWidget(self) -> PyQt5.QtWidgets.QWidget:
def _parentWidget(self) -> PyQt6.QtWidgets.QWidget:
"""
Returns:
The parent widget.
@@ -3250,7 +3249,7 @@ class IPluginList:
class IPluginModPage(IPlugin):
def __init__(self): ...
def _parentWidget(self) -> PyQt5.QtWidgets.QWidget:
def _parentWidget(self) -> PyQt6.QtWidgets.QWidget:
"""
Returns:
The parent widget.
@@ -3296,7 +3295,7 @@ class IPluginModPage(IPlugin):
The URL to open when the user wants to visit this mod page.
"""
...
def setParentWidget(self, parent: PyQt5.QtWidgets.QWidget):
def setParentWidget(self, parent: PyQt6.QtWidgets.QWidget):
"""
Set the parent widget for this mod page.
@@ -3330,7 +3329,7 @@ class IPluginPreview(IPlugin):
@abc.abstractmethod
def genFilePreview(
self, filename: str, max_size: PyQt6.QtCore.QSize
) -> PyQt5.QtWidgets.QWidget:
) -> PyQt6.QtWidgets.QWidget:
"""
Generate a preview for the specified file.
@@ -3403,7 +3402,7 @@ class IPluginTool(IPlugin):
"""
def __init__(self): ...
def _parentWidget(self) -> PyQt5.QtWidgets.QWidget:
def _parentWidget(self) -> PyQt6.QtWidgets.QWidget:
"""
Returns:
The parent widget.
@@ -3429,7 +3428,7 @@ class IPluginTool(IPlugin):
The icon for this tool, or a default-constructed QICon().
"""
...
def setParentWidget(self, parent: PyQt5.QtWidgets.QWidget):
def setParentWidget(self, parent: PyQt6.QtWidgets.QWidget):
"""
Set the parent widget for this tool.
@@ -3548,18 +3547,18 @@ class ISaveGame:
"""
...
class ISaveGameInfoWidget(PyQt5.QtWidgets.QWidget):
class ISaveGameInfoWidget(PyQt6.QtWidgets.QWidget):
"""
Base class for a save game info widget.
"""
def __init__(self, parent: PyQt5.QtWidgets.QWidget = None):
def __init__(self, parent: PyQt6.QtWidgets.QWidget = None):
"""
Args:
parent: Parent widget.
"""
...
def _widget(self) -> PyQt5.QtWidgets.QWidget:
def _widget(self) -> PyQt6.QtWidgets.QWidget:
"""
Returns:
The underlying `QWidget`.
@@ -3994,7 +3993,7 @@ class SaveGameInfo(abc.ABC):
...
@abc.abstractmethod
def getSaveGameWidget(
self, parent: PyQt5.QtWidgets.QWidget
self, parent: PyQt6.QtWidgets.QWidget
) -> Optional["ISaveGameInfoWidget"]:
"""
Retrieve a widget to display over the save game list.