From 2e0111724b989d22c2adc49f45bd7d5503731afc Mon Sep 17 00:00:00 2001 From: Krzysztof kuhy Rudnicki Date: Sat, 21 Nov 2026 10:45:59 +0100 Subject: [PATCH] Put my logo everywhere Todo: 7808ee0a --- .pre-commit-config.yaml | 3 ++ phone_app/lib/screens/settings_screen.dart | 3 ++ phone_app/pubspec.lock | 9 +++++ phone_app/pubspec.yaml | 5 +++ phone_app/test/settings_screen_test.dart | 14 +++++++- pyproject.toml | 1 + requirements.txt | 3 +- wake_alarm/_audit.py | 6 +++- wake_alarm/_cli_modes.py | 7 +++- wake_alarm/_ring_wav.py | 7 +++- wake_alarm/_session.py | 4 ++- wake_alarm/_sync.py | 5 ++- wake_alarm/_trigger.py | 4 ++- wake_alarm/tests/test_credit.py | 42 ++++++++++++++++++++++ 14 files changed, 105 insertions(+), 8 deletions(-) create mode 100644 wake_alarm/tests/test_credit.py diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6fd9988..79a05a5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -96,6 +96,8 @@ repos: rev: v3.3.2 hooks: - id: pylint + # dill (pylint --jobs) crashes on 3.15 (co_lnotab gone); 3.14 until it catches up. + language_version: python3.14 args: - --rcfile=pyproject.toml - --fail-under=10 @@ -108,6 +110,7 @@ repos: # than merely an old one. - gatelock @ git+https://github.com/kuhyx/utils@gatelock-v0.12.0#subdirectory=gatelock - crdt-sync @ git+https://github.com/kuhyx/utils@crdt-sync-v0.11.1#subdirectory=crdt-sync + - kuhy-credit @ git+https://github.com/kuhyx/utils@kuhy-credit-v0.3.1#subdirectory=kuhy_credit - freedays @ git+https://github.com/kuhyx/utils@freedays-v0.4.3#subdirectory=freedays - sickdays @ git+https://github.com/kuhyx/utils@sickdays-v0.5.4#subdirectory=sickdays # Test suites intentionally use patterns (protected-access, magic-value diff --git a/phone_app/lib/screens/settings_screen.dart b/phone_app/lib/screens/settings_screen.dart index 76d303b..8322073 100644 --- a/phone_app/lib/screens/settings_screen.dart +++ b/phone_app/lib/screens/settings_screen.dart @@ -2,6 +2,7 @@ import 'dart:developer' as developer; import 'package:crdt_sync_flutter/crdt_sync_flutter.dart' show E2ePassphraseButton; +import 'package:kuhy_credit/kuhy_credit.dart'; import 'package:material_ui/material_ui.dart'; import 'package:sync_settings_ui/sync_settings_ui.dart'; @@ -192,6 +193,8 @@ class SettingsScreen extends StatelessWidget { appRoute(context, (_) => const GitHubMirrorScreen()), ), ), + const SizedBox(height: 24), + const Center(child: KuhyCredit()), ], ), ); diff --git a/phone_app/pubspec.lock b/phone_app/pubspec.lock index e92b099..194c8b0 100644 --- a/phone_app/pubspec.lock +++ b/phone_app/pubspec.lock @@ -474,6 +474,15 @@ packages: url: "https://pub.dev" source: hosted version: "4.12.0" + kuhy_credit: + dependency: "direct main" + description: + path: "kuhy_credit/flutter" + ref: "kuhy-credit-v0.3.1" + resolved-ref: "2352c177232a4b4594573a3b1126697ef32851f7" + url: "https://github.com/kuhyx/utils" + source: git + version: "0.3.1" leak_tracker: dependency: transitive description: diff --git a/phone_app/pubspec.yaml b/phone_app/pubspec.yaml index 6506fa7..91e652a 100644 --- a/phone_app/pubspec.yaml +++ b/phone_app/pubspec.yaml @@ -45,6 +45,11 @@ dependencies: ref: google_account_token-v0.1.0 path: google_account_token http: 1.6.0 + kuhy_credit: + git: + url: https://github.com/kuhyx/utils + ref: kuhy-credit-v0.3.1 + path: kuhy_credit/flutter material_ui: 1.11.1 path: 1.9.1 path_provider: 2.1.6 diff --git a/phone_app/test/settings_screen_test.dart b/phone_app/test/settings_screen_test.dart index 6ce519d..14faacf 100644 --- a/phone_app/test/settings_screen_test.dart +++ b/phone_app/test/settings_screen_test.dart @@ -1,7 +1,9 @@ import 'package:flutter_test/flutter_test.dart'; +import 'package:kuhy_credit/kuhy_credit.dart'; import 'package:material_ui/material_ui.dart'; import 'package:wake_alarm_sync/screens/github_mirror_screen.dart'; -import 'package:wake_alarm_sync/screens/settings_screen.dart'; +import 'package:wake_alarm_sync/screens/settings_screen.dart' + show SettingsScreen; import 'package:wake_alarm_sync/ui/theme.dart'; void main() { @@ -104,4 +106,14 @@ void main() { expect(find.byIcon(Icons.error_outline), findsOneWidget); expect(find.byIcon(Icons.check_circle), findsNothing); }); + + testWidgets('shows exactly one KuhyCredit at the bottom', (tester) async { + await tester.pumpWidget( + MaterialApp(theme: buildAppTheme(), home: const SettingsScreen()), + ); + + final creditFinder = find.byType(KuhyCredit); + await tester.scrollUntilVisible(creditFinder, 500); + expect(creditFinder, findsOneWidget); + }); } diff --git a/pyproject.toml b/pyproject.toml index 58004f8..52aebe0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,6 +17,7 @@ dependencies = [ # Sick days stand the PC's enforcement down (_sick.py). Imported behind # a guard: missing means "not sick", never a crashed tick. "sickdays @ git+https://github.com/kuhyx/utils@sickdays-v0.5.6#subdirectory=sickdays", + "kuhy-credit @ git+https://github.com/kuhyx/utils@kuhy-credit-v0.3.1#subdirectory=kuhy_credit", ] # Package discovery must be explicit: phone_app/ is a Flutter app, not a Python diff --git a/requirements.txt b/requirements.txt index be178dd..97e8a6e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,10 +4,11 @@ # it is missing — but it is required here for mypy/pylint/tests. bandit==1.9.4 codespell==2.4.3 -coverage==7.17.3 +coverage==7.17.4 crdt-sync @ git+https://github.com/kuhyx/utils@crdt-sync-v0.11.1#subdirectory=crdt-sync freedays @ git+https://github.com/kuhyx/utils@freedays-v0.4.3#subdirectory=freedays gatelock @ git+https://github.com/kuhyx/utils@gatelock-v0.16.0#subdirectory=gatelock +kuhy-credit @ git+https://github.com/kuhyx/utils@kuhy-credit-v0.3.1#subdirectory=kuhy_credit mypy==2.4.1 pre-commit==4.7.0 pylint==4.1.4 diff --git a/wake_alarm/_audit.py b/wake_alarm/_audit.py index 3f6aac1..25e037b 100644 --- a/wake_alarm/_audit.py +++ b/wake_alarm/_audit.py @@ -22,6 +22,7 @@ import sys from typing import TYPE_CHECKING import freedays +from kuhy_credit import credit_line from wake_alarm._audit_checks import alarm_from_events, flags, run_checks from wake_alarm._audit_evidence import Check, Evidence, PcSide, PhoneSide @@ -169,7 +170,10 @@ def write_report(day: date, text: str) -> str: def main(argv: list[str] | None = None) -> int: """Entry point; exit 1 if unwritable, 2 if a report exists and no flag.""" - parser = argparse.ArgumentParser(description="Audit one wake-up") + parser = argparse.ArgumentParser( + description="Audit one wake-up", + epilog=credit_line(), + ) parser.add_argument("day", nargs="?", type=date.fromisoformat, default=None) parser.add_argument( "--stdout", diff --git a/wake_alarm/_cli_modes.py b/wake_alarm/_cli_modes.py index bb87925..3c5d005 100644 --- a/wake_alarm/_cli_modes.py +++ b/wake_alarm/_cli_modes.py @@ -13,13 +13,18 @@ from datetime import datetime import sys from typing import TYPE_CHECKING +from kuhy_credit import credit_line + if TYPE_CHECKING: from collections.abc import Callable def mode_parser(description: str, act: str, act_help: str) -> argparse.ArgumentParser: """A parser with exactly one of ``--``, ``--dry-run``, ``--show``.""" - parser = argparse.ArgumentParser(description=description) + parser = argparse.ArgumentParser( + description=description, + epilog=credit_line(), + ) mode = parser.add_mutually_exclusive_group(required=True) mode.add_argument(f"--{act}", action="store_true", help=act_help) mode.add_argument("--dry-run", action="store_true", help="decide, change nothing") diff --git a/wake_alarm/_ring_wav.py b/wake_alarm/_ring_wav.py index 715a982..3cba9bd 100644 --- a/wake_alarm/_ring_wav.py +++ b/wake_alarm/_ring_wav.py @@ -24,6 +24,8 @@ import struct import sys import wave +from kuhy_credit import credit_line + SAMPLE_RATE = 16_000 RISE_SECONDS = 60.0 LOOP_SECONDS = 20.0 @@ -108,7 +110,10 @@ def ensure_pair(preferred: Path, fallback: Path) -> tuple[Path, Path]: def main(argv: list[str] | None = None) -> int: """Write the pair into ``--write DIR``.""" - parser = argparse.ArgumentParser(description="Generate the fallback ring WAVs") + parser = argparse.ArgumentParser( + description="Generate the fallback ring WAVs", + epilog=credit_line(), + ) parser.add_argument("--write", type=Path, required=True, metavar="DIR") args = parser.parse_args(sys.argv[1:] if argv is None else argv) for path in write_pair(args.write): diff --git a/wake_alarm/_session.py b/wake_alarm/_session.py index 8d7941c..a7747e2 100644 --- a/wake_alarm/_session.py +++ b/wake_alarm/_session.py @@ -35,6 +35,7 @@ import time from typing import TYPE_CHECKING from gatelock.log_integrity import compute_entry_hmac, verify_entry_hmac +from kuhy_credit import credit_line from wake_alarm._constants import ( FALLBACK_ALARM_HOUR, @@ -173,7 +174,8 @@ def describe(entry: dict[str, object], now: datetime) -> str: def _parse_args(argv: list[str]) -> argparse.Namespace: parser = argparse.ArgumentParser( - description="PC copy of the phone's morning session" + description="PC copy of the phone's morning session", + epilog=credit_line(), ) mode = parser.add_mutually_exclusive_group(required=True) mode.add_argument( diff --git a/wake_alarm/_sync.py b/wake_alarm/_sync.py index ba773cb..b59558f 100644 --- a/wake_alarm/_sync.py +++ b/wake_alarm/_sync.py @@ -29,6 +29,8 @@ import logging import sys import time +from kuhy_credit import credit_line + from wake_alarm._alarm_payload import in_range from wake_alarm._constants import ( ALARM_CACHE_FILE, @@ -212,7 +214,8 @@ def get_alarm(*, max_cache_age_seconds: float = ALARM_CACHE_MAX_AGE_SECONDS) -> def _parse_args(argv: list[str]) -> argparse.Namespace: """Parse CLI arguments for the sync reader.""" parser = argparse.ArgumentParser( - description="Show the alarm time the phone last synced." + description="Show the alarm time the phone last synced.", + epilog=credit_line(), ) parser.add_argument( "--show", diff --git a/wake_alarm/_trigger.py b/wake_alarm/_trigger.py index ddb0711..d5e7d6a 100644 --- a/wake_alarm/_trigger.py +++ b/wake_alarm/_trigger.py @@ -27,6 +27,7 @@ import subprocess import sys import freedays +from kuhy_credit import credit_line from wake_alarm._constants import ( ALARM_DAYS, @@ -164,7 +165,8 @@ def _decide(now: datetime, alarm: Alarm) -> tuple[bool, str]: def _parse_args(argv: list[str]) -> argparse.Namespace: """Parse CLI arguments for the trigger.""" parser = argparse.ArgumentParser( - description="Fire the morning routine at the phone's alarm time." + description="Fire the morning routine at the phone's alarm time.", + epilog=credit_line(), ) parser.add_argument( "--dry-run", diff --git a/wake_alarm/tests/test_credit.py b/wake_alarm/tests/test_credit.py new file mode 100644 index 0000000..9aa1f3f --- /dev/null +++ b/wake_alarm/tests/test_credit.py @@ -0,0 +1,42 @@ +"""Tests that every CLI parser's --help output ends with credit_line().""" + +import subprocess +import sys + +import pytest + +from kuhy_credit import credit_line + +MODULES_WITH_CLI = [ + "wake_alarm._audit", + "wake_alarm._ring_wav", + "wake_alarm._session", + "wake_alarm._trigger", + "wake_alarm._sync", +] + + +def _run_help(module: str) -> str: + """Run `python -m --help` and return stdout.""" + result = subprocess.run( + [sys.executable, "-m", module, "--help"], + capture_output=True, + text=True, + ) + if result.returncode != 0: + # Some modules need a subcommand; mode_parser is one. Try without --help. + result = subprocess.run( + [sys.executable, "-m", module], + capture_output=True, + text=True, + ) + return result.stdout + + +@pytest.mark.parametrize("module", MODULES_WITH_CLI) +def test_help_ends_with_credit_line(module: str): + """The --help output must end with credit_line().""" + help_text = _run_help(module) + assert help_text.endswith(credit_line() + "\n"), ( + f"Module {module} help does not end with credit_line()" + ) \ No newline at end of file