Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions packages/PyQt6-Qlementine/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ def fix_rpath_macos(so: Path, new_rpaths: list[str]) -> None:
["install_name_tool", "-delete_rpath", rpath, str(so)], check=True
)
for rpath in new_rpaths:
subprocess.run(
["install_name_tool", "-add_rpath", rpath, str(so)], check=True
)
subprocess.run(["install_name_tool", "-add_rpath", rpath, str(so)], check=True)
print(f"Updated RPATH for {so} to {new_rpaths}")


Expand Down
5 changes: 4 additions & 1 deletion packages/PySide6-Qlementine/PySide6Qlementine/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@

del PySide6, shiboken6, os, _mod, _dir, _qt_bin


def _init():
import types

from . import PySide6Qlementine as _ql

ns = globals()
Expand All @@ -40,7 +42,8 @@ def _init():
# appStyle lives on UtilsBridge (free functions are rejected by shiboken)
ns["appStyle"] = _ql.UtilsBridge.appStyle


_init()
del _init

from . import utils as utils
from . import utils as utils # noqa: E402
19 changes: 12 additions & 7 deletions packages/PySide6-Qlementine/scripts/generate_stubs.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,7 @@ def _split_stubs(content: str) -> tuple[str, str]:
dedented = stripped
method_block = [dedented]
i += 1
while i < len(lines) and lines[i].startswith(
(" ", "\t")
):
while i < len(lines) and lines[i].startswith((" ", "\t")):
# Dedent method body (8 spaces -> 4 spaces)
body = lines[i]
if body.startswith(" "):
Expand Down Expand Up @@ -207,13 +205,11 @@ def _split_stubs(content: str) -> tuple[str, str]:
def _generate_utils_stubs_from_bridge(header: str) -> str:
"""Generate utils.pyi by introspecting UtilsBridge static method signatures."""
import inspect
import typing

from shibokensupport.signature import get_signature # type: ignore

bridge = PySide6Qlementine.PySide6Qlementine.UtilsBridge
lines = [header.rstrip(), ""]
seen: dict[str, list[str]] = {}

for name in sorted(dir(bridge)):
if name.startswith("_") or name == "appStyle":
Expand Down Expand Up @@ -308,8 +304,17 @@ def _run_ruff(path: Path) -> None:
ruff_args = ["--target-version", "py310"]
subprocess.run(
[
ruff, "check", *ruff_args, "--fix", "--unsafe-fixes",
str(path), "--select", "E,F,W,I,UP,RUF", "--ignore", "E501", "--quiet",
ruff,
"check",
*ruff_args,
"--fix",
"--unsafe-fixes",
str(path),
"--select",
"E,F,W,I,UP,RUF",
"--ignore",
"E501",
"--quiet",
],
check=False,
)
Expand Down
38 changes: 22 additions & 16 deletions packages/PySide6-Qlementine/scripts/generate_utils_bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"WidgetUtils.sip",
}


def _find_functions(text: str) -> list[tuple[str, str, str]]:
"""Extract function declarations, handling nested parens in defaults."""
results: list[tuple[str, str, str]] = []
Expand Down Expand Up @@ -66,6 +67,7 @@ def _find_functions(text: str) -> list[tuple[str, str, str]]:
results.append((m.group(1).strip(), m.group(2).strip(), params))
return results


# Matches #include lines inside %TypeHeaderCode blocks
INCLUDE_RE = re.compile(r"^#include\s+[<\"](.+?)[>\"]", re.MULTILINE)

Expand Down Expand Up @@ -170,16 +172,18 @@ def generate_bridge(
if "oclero/qlementine/style/QlementineStyle.hpp" not in seen:
lines.append("#include <oclero/qlementine/style/QlementineStyle.hpp>")

lines.extend([
"",
"namespace oclero::qlementine {",
"",
"class UtilsBridge {",
"public:",
" static QlementineStyle* appStyle() {",
" return oclero::qlementine::appStyle();",
" }",
])
lines.extend(
[
"",
"namespace oclero::qlementine {",
"",
"class UtilsBridge {",
"public:",
" static QlementineStyle* appStyle() {",
" return oclero::qlementine::appStyle();",
" }",
]
)

for ret_type, name, params in all_functions:
call_args = format_call_args(params)
Expand All @@ -193,12 +197,14 @@ def generate_bridge(
lines.append(f" {body}")
lines.append(" }")

lines.extend([
"};",
"",
"} // namespace oclero::qlementine",
"",
])
lines.extend(
[
"};",
"",
"} // namespace oclero::qlementine",
"",
]
)

return "\n".join(lines)

Expand Down
1 change: 0 additions & 1 deletion tests/test_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

from typing import TYPE_CHECKING

import pytest
from _qt_compat import (
QAction,
QApplication,
Expand Down
1 change: 0 additions & 1 deletion tests/utils/test_badge_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
Theme = Qlementine.Theme



def test_draw_status_badge(qapp):
pixmap = QtGui.QPixmap(64, 64)
pixmap.fill(QtGui.QColor(255, 255, 255))
Expand Down
1 change: 0 additions & 1 deletion tests/utils/test_color_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from _qt_compat import QColor, Qlementine



def test_get_contrast_ratio():
# NOTE: upstream getContrastRatio is a stub returning 4.5
ratio = Qlementine.utils.getContrastRatio(QColor(0, 0, 0), QColor(255, 255, 255))
Expand Down
1 change: 0 additions & 1 deletion tests/utils/test_font_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from _qt_compat import Qlementine, QtGui



def test_point_size_to_pixel_size(qapp):
result = Qlementine.utils.pointSizeToPixelSize(12.0, 96.0)
assert isinstance(result, float)
Expand Down
1 change: 0 additions & 1 deletion tests/utils/test_geometry_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from _qt_compat import Qlementine, QtCore



def test_point_inside_rounded_rect():
rect = QtCore.QRectF(0, 0, 100, 100)
center = QtCore.QPointF(50, 50)
Expand Down
1 change: 0 additions & 1 deletion tests/utils/test_image_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
RadiusesF = Qlementine.RadiusesF



def test_colorize_image(qapp):
pixmap = QtGui.QPixmap(32, 32)
pixmap.fill(QColor(128, 128, 128))
Expand Down
1 change: 0 additions & 1 deletion tests/utils/test_layout_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from _qt_compat import Qlementine, QtWidgets, QWidget



def test_get_layout_margins(qapp):
w = QWidget()
w.setLayout(QtWidgets.QVBoxLayout())
Expand Down
1 change: 0 additions & 1 deletion tests/utils/test_menu_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from _qt_compat import Qlementine, QtWidgets



def test_get_top_level_menu_returns_self(qapp):
menu = QtWidgets.QMenu()
result = Qlementine.utils.getTopLevelMenu(menu)
Expand Down
1 change: 0 additions & 1 deletion tests/utils/test_primitive_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
Theme = Qlementine.Theme



def _make_painter():
"""Create a pixmap and painter for drawing tests."""
pixmap = QtGui.QPixmap(100, 100)
Expand Down
1 change: 0 additions & 1 deletion tests/utils/test_state_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
QStyle = QtWidgets.QStyle



def test_get_mouse_state_from_flags(qapp):
state = QStyle.StateFlag.State_Enabled | QStyle.StateFlag.State_MouseOver
result = Qlementine.utils.getMouseState(state)
Expand Down
1 change: 0 additions & 1 deletion tests/utils/test_style_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from _qt_compat import Qlementine, QWidget



def test_should_have_hover_events(qapp):
w = QWidget()
result = Qlementine.utils.shouldHaveHoverEvents(w)
Expand Down
1 change: 0 additions & 1 deletion tests/utils/test_widget_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from _qt_compat import Qlementine, QWidget



def test_make_vertical_line(qapp):
parent = QWidget()
line = Qlementine.utils.makeVerticalLine(parent)
Expand Down
Loading