From e204c003aeeae4b4ee8d4fea5a3ea114d2c543bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Capelle?= Date: Fri, 6 May 2022 23:34:48 +0200 Subject: [PATCH] Add GameFeatureType. --- src/mobase/mobase.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/mobase/mobase.cpp b/src/mobase/mobase.cpp index 9eebfe0..c24a00d 100644 --- a/src/mobase/mobase.cpp +++ b/src/mobase/mobase.cpp @@ -69,17 +69,15 @@ PYBIND11_MODULE(mobase, m) // type their code if they want { m.add_object("Path", py::module_::import("pathlib").attr("Path")); + m.add_object("TypeVar", py::module_::import("typing").attr("TypeVar")); auto s = m.attr("__dict__"); - // expose MoVariant - MoVariant is a fake object whose only purpose is to be - // used as a type-hint on the python side (e.g., def foo(x: - // mobase.MoVariant)) + // expose MoVariant // - // the real MoVariant is defined in the generated stubs, since it's only - // relevant when doing type-checking, but this needs to be defined, - // otherwise MoVariant is not found when actually running plugins through - // MO2, making them crash + // this needs to be defined, otherwise MoVariant is not found when actually + // running plugins through MO2, making them crash (if plugins use MoVariant in + // their own code) // m.add_object( "MoVariant", @@ -89,6 +87,10 @@ PYBIND11_MODULE(mobase, m) // m.add_object("FileWrapper", py::eval("str | PyQt6.QtCore.QFileInfo | Path", s)); m.add_object("DirectoryWrapper", py::eval("str | PyQt6.QtCore.QDir | Path", s)); + + // same thing for GameFeatureType + // + m.add_object("GameFeatureType", py::eval("TypeVar('GameFeatureType')", s)); } // private stuff for debugging/test