Skip to content

Commit 6623e19

Browse files
authored
Expose INVALID_HANDLE_VALUE as mobase.INVALID_HANDLE_VALUE. (#131)
* Expose INVALID_HANDLE_VALUE as mobase.INVALID_HANDLE_VALUE. * Add tests for startApplication() returning INVALID_HANDLE_VALUE. * Clean tests and generate stub files for them.
1 parent 7cfc761 commit 6623e19

30 files changed

+662
-80
lines changed

.github/workflows/linting.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- uses: actions/checkout@v3
13-
- name: Run clang-format
14-
uses: jidicula/clang-format-action@v4.11.0
13+
- name: Check format
14+
uses: ModOrganizer2/check-formatting-action@master
1515
with:
16-
clang-format-version: "15"
1716
check-path: "."
1817
- uses: actions/setup-python@v4
1918
with:
20-
python-version: '3.10'
21-
- uses: isort/isort-action@master
22-
- uses: psf/black@stable
19+
python-version: "3.12"
20+
- uses: abatilo/actions-poetry@v2
21+
- name: Check format Python tests
22+
run: |
23+
poetry install --no-root
24+
poetry run poe lint

poetry.lock

Lines changed: 254 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
[tool.poetry]
2+
name = "modorganizer-plugin_python"
3+
version = "3.0.0"
4+
description = ""
5+
authors = ["Mikaël Capelle <[email protected]>"]
6+
7+
[tool.poetry.dependencies]
8+
python = "^3.12"
9+
10+
[tool.poetry.group.dev.dependencies]
11+
pyright = "^1.1.369"
12+
ruff = "^0.2.1"
13+
poethepoet = "^0.23.0"
14+
mobase-stubs = { version = "^2.5.1a0", allow-prereleases = true }
15+
pyqt6 = "^6.7.0"
16+
pytest = "^8.2.2"
17+
pybind11-stubgen = "^2.5.1"
18+
19+
[tool.poe.tasks]
20+
format-imports = "ruff check --select I tests typings --fix"
21+
format-ruff = "ruff format tests typings"
22+
format.sequence = ["format-imports", "format-ruff"]
23+
lint-ruff = "ruff check tests typings"
24+
lint-ruff-format = "ruff format --check tests typings"
25+
lint.sequence = ["lint-ruff", "lint-ruff-format"]
26+
lint.ignore_fail = "return_non_zero"
27+
28+
[tool.ruff]
29+
target-version = "py312"
30+
31+
[tool.ruff.lint]
32+
extend-select = ["B", "Q", "I"]
33+
34+
[tool.ruff.lint.isort.sections]
35+
mobase = ["mobase"]
36+
mobase_tests = ["mobase_tests"]
37+
38+
[tool.ruff.lint.isort]
39+
section-order = [
40+
"future",
41+
"standard-library",
42+
"third-party",
43+
"first-party",
44+
"mobase",
45+
"mobase_tests",
46+
"local-folder",
47+
]
48+
49+
[tool.pyright]
50+
typeCheckingMode = "strict"
51+
reportMissingTypeStubs = true
52+
reportMissingModuleSource = false
53+
pythonPlatform = "Windows"

setup.cfg

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/mobase/wrappers/basic_classes.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,9 @@ namespace mo2::python {
429429

430430
void add_iorganizer_classes(py::module_ m)
431431
{
432+
// define INVALID_HANDLE_VALUE for startApplication, etc.
433+
m.attr("INVALID_HANDLE_VALUE") = py::int_((std::uintptr_t)INVALID_HANDLE_VALUE);
434+
432435
py::class_<IOrganizer::FileInfo>(m, "FileInfo")
433436
.def(py::init<>())
434437
.def_readwrite("filePath", &IOrganizer::FileInfo::filePath)

tests/python/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ add_test(NAME pytest
1818
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/pylibs/bin/pytest.exe ${CMAKE_CURRENT_SOURCE_DIR} -s
1919
)
2020

21-
set(extra_paths "${UIBASE_PATH}\\;${MO2_INSTALL_PATH}/bin/dlls")
2221
set_tests_properties(pytest
2322
PROPERTIES
2423
DEPENDS python-tests

tests/python/conftest.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
# -*- encoding: utf-8 -*-
2-
31
import os
42
import sys
53
from pathlib import Path
4+
from typing import cast
65

76

87
def pytest_configure():
98
global app
109

11-
os.add_dll_directory(Path(os.getenv("QT_ROOT")).joinpath("bin"))
12-
os.add_dll_directory(Path(os.getenv("UIBASE_PATH")))
10+
os.add_dll_directory(str(Path(cast(str, os.getenv("QT_ROOT"))).joinpath("bin")))
11+
os.add_dll_directory(str(os.getenv("UIBASE_PATH")))
1312

1413
from PyQt6.QtWidgets import QApplication
1514

0 commit comments

Comments
 (0)