testsAndMisc/python_pkg/_optional_credit.py
Krzysztof kuhy Rudnicki aae7dc57f6
Some checks are pending
md-naming / markdown naming convention (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (mypy, mypy) (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (pylint, pylint) (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (rest, ) (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (shellcheck, shellcheck) (push) Waiting to run
Python tests / test (push) Waiting to run
repo-contract / repo contract (push) Waiting to run
Shell tests / shell-tests (push) Waiting to run
Shell tests / lib-tests (push) Waiting to run
Shell tests / arch-tests (push) Waiting to run
phone_lease, android_ui: credit is optional
phone_deploy.sh runs python_pkg.phone_lease with whatever python3 is
first on PATH. e9ba82ed made it import kuhy_credit at module load, so
from a venv without kuhy-credit every phone deploy died with
ModuleNotFoundError. Both phone CLIs now take the epilog from
help_epilog(), which returns None when the package is missing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 15:13:14 +01:00

21 lines
627 B
Python

"""The kuhy credit for CLIs that phone tooling starts under any ``python3``.
phone_deploy.sh and the android_ui driver run with whatever interpreter is
first on PATH, often a project venv without kuhy-credit. The credit is
decoration, so a missing package yields no epilog instead of a crash.
"""
from __future__ import annotations
import importlib
def help_epilog() -> str | None:
"""Return the shared credit line, or None when kuhy_credit is missing."""
try:
credit = importlib.import_module("kuhy_credit")
except ImportError:
return None
line: str = credit.credit_line()
return line