Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…GmbH#104)

* Addressing TUV-SUD-Product-Service-GmbH#103
* Updated framework to python 3.12
* refactored resource file building
* Added python 3.12 runner to tests
  • Loading branch information
p5k369 authored Oct 14, 2024
1 parent dcbd2ef commit e543775
Show file tree
Hide file tree
Showing 15 changed files with 428 additions and 388 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
python-version:
- "3.10"
- "3.11"
- "3.12"

steps:

Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ repos:
args: [ "--profile", "black", "-l 79" ]

- repo: https://github.com/psf/black
rev: 24.4.2
rev: 24.10.0
hooks:
- id: black
exclude: ".*venv/.*|.*qute_style/gen/.*|resources_rc.py"
args: [ --safe, --quiet, -l 79 ]
language_version: python3

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
Expand All @@ -37,7 +37,7 @@ repos:
- id: requirements-txt-fixer

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.5
rev: v0.6.9
hooks:
- id: ruff
name: ruff
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ It is mainly suited for applications that rely on a center widget for user inter

**Project status**

[![Python Versions](https://img.shields.io/badge/Python-3.10%20|%203.11-blue.svg?&logo=Python&logoWidth=18&logoColor=white)](https://www.python.org/downloads/)
[![Python Versions](https://img.shields.io/badge/Python-3.10%20|%203.11%20|%203.12-blue.svg?&logo=Python&logoWidth=18&logoColor=white)](https://www.python.org/downloads/)
[![Qt Versions](https://img.shields.io/badge/Qt-6-blue.svg?&logo=Qt&logoWidth=18&logoColor=white)](https://www.qt.io/qt-for-python)
[![License](https://img.shields.io/github/license/TUV-SUD-Product-Service-GmbH/QuteStyle.svg)](https://github.com/TUV-SUD-Product-Service-GmbH/QuteStyle/blob/master/LICENSE)
[![Code style: black](https://img.shields.io/badge/code%20style-black-black.svg)](https://github.com/python/black)
Expand Down
736 changes: 380 additions & 356 deletions poetry.lock

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "qute_style"
version = "1.0.7"
version = "1.0.8"
description = "QuteStyle is an expandable application framework for PySide6"
authors = ["Marina Baumgartner, Dairen Gonschior, Tilman Krummeck, Dennis Spitzhorn, Gerhard Trapp, Patrick Zwerschke <[email protected]>"]
readme = "README.md"
Expand All @@ -12,22 +12,22 @@ packages = [
]

[tool.poetry.dependencies]
python = ">=3.9,<3.12"
PySide6 = "6.5.1.1"
python = ">=3.9,<3.13"
PySide6 = "6.8.0"

[tool.poetry.dev-dependencies]
pytest = "8.2.1"
pytest-qt = "4.4.0"
requests = "2.32.2"
black = "24.4.2"
coverage = "7.5.2"
requests = "2.32.3"
black = "24.10.0"
coverage = "7.6.2"
isort = "5.13.2"
mypy = "1.10.0"
pre-commit = "3.7.1"
mypy = "1.11.2"
pre-commit = "4.0.1"
pytest-cov = "^5.0.0"
pytest-github-actions-annotate-failures = "^0.2.0"
ruff = "^0.4.5"
types-requests = "2.32.0.20240523"
ruff = "^0.6.9"
types-requests = "2.32.0.20240914"


[tool.poetry.scripts]
Expand Down
9 changes: 6 additions & 3 deletions qute_style/dev/dev_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from __future__ import annotations

import json
import os
import pickle
import re
import subprocess
Expand Down Expand Up @@ -171,16 +172,18 @@ def _create_resource_file( # pylint: disable=too-many-locals
added_images.update(list(images))

for image in added_images:
image_path = Path(change_log_path).joinpath(image)
image_path = Path(change_log_path) / Path(image.replace("\\", os.sep))
ElTree.SubElement(qrc, "file", {"alias": image}).text = str(
image_path.relative_to(resource_file_path)
)
tree = ElTree.ElementTree(rcc)
tree.write(resource_file)

print("Generating resource_rc.py with new resources.qrc")
assert (
subprocess.call(f"pyside6-rcc -o {resource_py} {resource_file}") == 0
subprocess.run(
f"pyside6-rcc -o {resource_py} {resource_file}",
shell=True,
check=False,
)

print("Deleting resources.qrc")
Expand Down
4 changes: 2 additions & 2 deletions qute_style/qs_main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class QuteStyleMainWindow(

LANG_CODE: str | None = None

def __init__( # noqa: PLR0913
def __init__(
self,
app_data: AppData,
force_whats_new: bool = False,
Expand Down Expand Up @@ -233,7 +233,7 @@ def _load_settings(self) -> None:

def get_main_widget(self, widget: type[MainWidgetT]) -> MainWidgetT | None:
"""Get main widget from content."""
return self._content.findChild(widget) # type: ignore[return-value]
return self._content.findChild(widget)

@Slot(QRect, name="window_geometry_changed")
def window_geometry_changed(self, geometry: QRect) -> None:
Expand Down
4 changes: 2 additions & 2 deletions qute_style/widgets/base_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class MainWidget(BaseWidget):

shutdown_completed = Signal(QWidget, name="shutdown_completed")

def __repr__(self) -> str:
def __repr__(self) -> str: # type: ignore[override]
"""Return a str representation for the MainWidget."""
return f"<{self.__class__} {self.NAME} {id(self)}>"

Expand Down Expand Up @@ -96,4 +96,4 @@ def add_widget(self, widget: QWidget) -> None:
def clear_widget(self) -> None:
"""Remove a widget from the settings if present."""
if item := self._layout.itemAtPosition(1, 0):
item.widget().setParent(None) # type: ignore[call-overload]
item.widget().setParent(None)
2 changes: 1 addition & 1 deletion qute_style/widgets/icon_button.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class IconButton(QPushButton):
FIXED_HEIGHT: int = 36
FIXED_WIDTH: int | None = 36

def __init__( # noqa: PLR0913
def __init__(
self,
parent: QWidget | None = None,
icon_path: str = ":/svg_icons/no_icon.svg",
Expand Down
6 changes: 4 additions & 2 deletions qute_style/widgets/icon_tooltip_button.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def __init__( # noqa: PLR0913
)
self._tooltip.hide()

def __repr__(self) -> str:
def __repr__(self) -> str: # type: ignore[override]
"""Return a str representation of the object."""
class_name = (
self._widget_class.__name__ if self._widget_class else "None"
Expand Down Expand Up @@ -91,7 +91,9 @@ def move_tooltip(self) -> None:
pos = self._app_parent.mapFromGlobal(global_pos)
# FORMAT POSITION
# Adjust _tooltip position with offset
pos_x, pos_y = self._get_tooltip_coords(pos)
# is valid overload, see:
# https://doc.qt.io/qtforpython-6/PySide6/QtWidgets/QWidget.html
pos_x, pos_y = self._get_tooltip_coords(pos) # type: ignore
# SET POSITION TO WIDGET
# Move _tooltip position
self._tooltip.move(pos_x, pos_y)
Expand Down
7 changes: 5 additions & 2 deletions qute_style/widgets/left_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,12 @@ def _button(
self, widget_class: type[BaseWidgetType]
) -> LeftMenuButton[BaseWidgetType]:
"""Return the button for the given widget class."""
for btn in self.findChildren(LeftMenuButton):
for btn in cast(
Iterable[LeftMenuButton[BaseWidgetType]],
self.findChildren(LeftMenuButton),
):
if btn.widget_class == widget_class:
return cast(LeftMenuButton[BaseWidgetType], btn)
return btn
raise ValueError( # pragma: no cover
f"Could not find button for widget: {widget_class}"
)
Expand Down
2 changes: 1 addition & 1 deletion qute_style/widgets/left_menu_button.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def __init__( # noqa: PLR0913
self._is_active_tab = False
self._is_toggle_active = False

def __repr__(self) -> str:
def __repr__(self) -> str: # type: ignore[override]
"""Return a representation for the LeftMenuButton."""
name = self.widget_class.__name__ if self.widget_class else None
return f"<LeftMenuButton '{self.text()} {name}'>"
Expand Down
5 changes: 3 additions & 2 deletions qute_style/widgets/title_bar.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Top bar with system buttons and extra menu."""

import logging
from collections.abc import Iterable
from typing import cast

from PySide6.QtCore import QEvent, QObject, QPoint, Qt, Signal, Slot
Expand Down Expand Up @@ -179,9 +180,9 @@ def set_button_active(

def _button(self, widget_class: type[BaseWidget]) -> TitleButton:
"""Return the button for the given widget class."""
for btn in self.findChildren(TitleButton):
for btn in cast(Iterable[TitleButton], self.findChildren(TitleButton)):
if btn.widget_class == widget_class:
return cast(TitleButton, btn)
return btn
raise ValueError( # pragma: no cover
f"Could not find button for widget: {widget_class}"
)
2 changes: 1 addition & 1 deletion qute_style_examples/sample_main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class StyledMainWindow(QuteStyleMainWindow):

MIN_SIZE = QSize(800, 600)

def __init__( # noqa: PLR0913
def __init__(
self,
app_data: AppData,
registry_reset: bool = False,
Expand Down
10 changes: 8 additions & 2 deletions tests/test_qs_main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# pylint: disable=protected-access
import logging
from collections.abc import Iterable
from typing import cast

import pytest
Expand Down Expand Up @@ -288,12 +289,17 @@ def test_no_widget_on_column(
window = create_new_main_window(qtbot, window_type)

if not window.RIGHT_WIDGET_CLASSES:
for title_button in window._title_bar.findChildren(TitleButton):
for title_button in cast(
Iterable[TitleButton], window._title_bar.findChildren(TitleButton)
):
assert title_button.widget_class is None

if not window.LEFT_WIDGET_CLASSES:
assert window._left_menu._bottom_layout.count() == 0
for left_button in window._left_menu.findChildren(LeftMenuButton):
for left_button in cast(
Iterable[LeftMenuButton], # type: ignore[type-arg]
window._left_menu.findChildren(LeftMenuButton),
):
assert (
left_button.widget_class is None
or left_button.widget_class in window.MAIN_WIDGET_CLASSES
Expand Down

0 comments on commit e543775

Please sign in to comment.