Add version info. Add linter
All checks were successful
CI / test (push) Successful in 2m22s
Lint / test (push) Successful in 13s
Trivy / test (push) Successful in 21s

This commit is contained in:
Miguel Jacq 2025-11-13 16:26:35 +11:00
parent c191d9f35c
commit d338033333
Signed by: mig5
GPG key ID: 59B3F0C24135C6A9
7 changed files with 67 additions and 0 deletions

View file

@ -0,0 +1,25 @@
name: Lint
on:
push:
jobs:
test:
runs-on: docker
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install system dependencies
run: |
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
black pyflakes3
- name: Run linters
run: |
black bouquin/*
black tests/*
pyflakes3 bouquin/*
pyflakes3 tests/*

View file

@ -2,6 +2,7 @@
* Fix a few small matters identified with tests * Fix a few small matters identified with tests
* Make locales dynamically detected from the locales dir rather than hardcoded * Make locales dynamically detected from the locales dir rather than hardcoded
* Add version information in the navigation
# 0.2.1.8 # 0.2.1.8

View file

@ -59,6 +59,7 @@
"documentation": "Documentation", "documentation": "Documentation",
"couldnt_open": "Couldn't open", "couldnt_open": "Couldn't open",
"report_a_bug": "Report a bug", "report_a_bug": "Report a bug",
"version": "Version",
"navigate": "Navigate", "navigate": "Navigate",
"current": "current", "current": "current",
"selected": "selected", "selected": "selected",

View file

@ -59,6 +59,7 @@
"documentation": "Documentation", "documentation": "Documentation",
"couldnt_open": "Impossible douvrir", "couldnt_open": "Impossible douvrir",
"report_a_bug": "Signaler un bug", "report_a_bug": "Signaler un bug",
"version": "Version",
"navigate": "Naviguer", "navigate": "Naviguer",
"current": "actuel", "current": "actuel",
"selected": "sélectionné", "selected": "sélectionné",

View file

@ -1,6 +1,7 @@
from __future__ import annotations from __future__ import annotations
import datetime import datetime
import importlib.metadata
import os import os
import sys import sys
import re import re
@ -263,6 +264,12 @@ class MainWindow(QMainWindow):
act_bugs.triggered.connect(self._open_bugs) act_bugs.triggered.connect(self._open_bugs)
help_menu.addAction(act_bugs) help_menu.addAction(act_bugs)
self.addAction(act_bugs) self.addAction(act_bugs)
act_version = QAction(strings._("version"), self)
act_version.setShortcut("Ctrl+V")
act_version.setShortcutContext(Qt.ApplicationShortcut)
act_version.triggered.connect(self._open_version)
help_menu.addAction(act_version)
self.addAction(act_version)
# Autosave # Autosave
self._dirty = False self._dirty = False
@ -1177,6 +1184,11 @@ class MainWindow(QMainWindow):
strings._("couldnt_open") + url.toDisplayString(), strings._("couldnt_open") + url.toDisplayString(),
) )
def _open_version(self):
version = importlib.metadata.version("bouquin")
version_formatted = f"{APP_NAME} {version}"
QMessageBox.information(self, strings._("version"), version_formatted)
# ----------------- Idle handlers ----------------- # # ----------------- Idle handlers ----------------- #
def _apply_idle_minutes(self, minutes: int): def _apply_idle_minutes(self, minutes: int):
minutes = max(0, int(minutes)) minutes = max(0, int(minutes))

View file

@ -14,6 +14,7 @@ _DEFAULT = "en"
strings = {} strings = {}
translations = {} translations = {}
def load_strings(current_locale: str) -> None: def load_strings(current_locale: str) -> None:
global strings, translations global strings, translations
translations = {} translations = {}

View file

@ -1,4 +1,6 @@
import pytest import pytest
import importlib.metadata
from pathlib import Path from pathlib import Path
import bouquin.main_window as mwmod import bouquin.main_window as mwmod
@ -906,9 +908,33 @@ def test_open_docs_and_bugs_show_warning_on_failure(
) )
w._open_docs() w._open_docs()
w._open_bugs() w._open_bugs()
assert seen["docs"] and seen["bugs"] assert seen["docs"] and seen["bugs"]
def test_open_version(qtbot, tmp_db_cfg, app, monkeypatch):
w = _make_main_window(tmp_db_cfg, app, monkeypatch)
qtbot.addWidget(w)
called = {"title": None, "text": None}
def fake_information(parent, title, text, *a, **k):
called["title"] = title
called["text"] = text
# Return value of QMessageBox.information is an int; 0 is fine.
return 0
# Patch whichever one you actually use in _open_version
monkeypatch.setattr(QMessageBox, "information", fake_information)
w._open_version()
assert called["title"] is not None
assert "version" in called["title"].lower()
version = importlib.metadata.version("bouquin")
assert version in called["text"]
# ---- Idle/lock/event filter helpers (1176, 1181-1187, 1193-1202, 1231-1233) ---- # ---- Idle/lock/event filter helpers (1176, 1181-1187, 1193-1202, 1231-1233) ----