From a4a7c13344c8c34794b6c53e7055ef3ff8d59fff Mon Sep 17 00:00:00 2001 From: Evgenii Alekseev Date: Sat, 18 Jul 2026 14:06:58 +0300 Subject: [PATCH] fix: disable colors for importing parser calls In case if parser is used to generate docs, it remains w\o colors, but help messages are still formatted with it --- .readthedocs.yml | 2 +- ahriman-core/pyproject.toml | 2 +- ahriman-core/src/ahriman/application/ahriman.py | 13 +++++++++---- ahriman-triggers/pyproject.toml | 2 +- ahriman-web/pyproject.toml | 2 +- pyproject.toml | 2 +- 6 files changed, 14 insertions(+), 9 deletions(-) diff --git a/.readthedocs.yml b/.readthedocs.yml index 20f9d342..9c82ad06 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -3,7 +3,7 @@ version: 2 build: os: ubuntu-lts-latest tools: - python: "3.13" + python: "3.14" apt_packages: - graphviz diff --git a/ahriman-core/pyproject.toml b/ahriman-core/pyproject.toml index 27fb8f38..f1884372 100644 --- a/ahriman-core/pyproject.toml +++ b/ahriman-core/pyproject.toml @@ -17,7 +17,7 @@ description = "ArcH linux ReposItory MANager, core package" dynamic = [ "version", ] -requires-python = ">=3.13" +requires-python = ">=3.14" [project.optional-dependencies] journald = [ diff --git a/ahriman-core/src/ahriman/application/ahriman.py b/ahriman-core/src/ahriman/application/ahriman.py index 7c799ffd..11cd1383 100644 --- a/ahriman-core/src/ahriman/application/ahriman.py +++ b/ahriman-core/src/ahriman/application/ahriman.py @@ -19,6 +19,7 @@ # import argparse +from functools import partial from pathlib import Path import ahriman.application.handlers @@ -34,10 +35,13 @@ from ahriman.models.log_handler import LogHandler __all__: list[str] = [] -def _parser() -> argparse.ArgumentParser: +def _parser(*, color: bool = False) -> argparse.ArgumentParser: """ command line parser generator + Args: + color(bool, optional): enable colors in help messages (Default value = False) + Returns: argparse.ArgumentParser: command line parser for the application """ @@ -63,7 +67,7 @@ Start web service (requires additional configuration): >>> ahriman web """, - fromfile_prefix_chars="@", formatter_class=_HelpFormatter) + fromfile_prefix_chars="@", formatter_class=_HelpFormatter, color=color) parser.add_argument("-a", "--architecture", help="filter by target architecture") parser.add_argument("-c", "--configuration", help="configuration path", type=Path, default=Path("/") / "etc" / "ahriman.ini") @@ -92,8 +96,9 @@ Start web service (requires additional configuration): for handler in implementations(ahriman.application.handlers, Handler): for subparser_parser in handler.arguments: subparser = subparser_parser(subparsers) + subparser.color = color subparser.formatter_class = _HelpFormatter - subparser.set_defaults(handler=handler, parser=_parser) + subparser.set_defaults(handler=handler, parser=partial(_parser, color=color)) # sort actions alphabetically in both choices and help message # pylint: disable=protected-access @@ -110,7 +115,7 @@ def run() -> int: Returns: int: application status code """ - parser = _parser() + parser = _parser(color=True) args = parser.parse_args() if args.command is None: # in case of empty command we would like to print help message diff --git a/ahriman-triggers/pyproject.toml b/ahriman-triggers/pyproject.toml index 30d1efdf..42e5f3a9 100644 --- a/ahriman-triggers/pyproject.toml +++ b/ahriman-triggers/pyproject.toml @@ -13,7 +13,7 @@ description = "ArcH linux ReposItory MANager, additional extensions" dynamic = [ "version", ] -requires-python = ">=3.13" +requires-python = ">=3.14" [tool.hatch.build.targets.wheel] packages = [ diff --git a/ahriman-web/pyproject.toml b/ahriman-web/pyproject.toml index 6a251a67..bd64ae2e 100644 --- a/ahriman-web/pyproject.toml +++ b/ahriman-web/pyproject.toml @@ -17,7 +17,7 @@ description = "ArcH linux ReposItory MANager, web server" dynamic = [ "version", ] -requires-python = ">=3.13" +requires-python = ">=3.14" [project.optional-dependencies] auth = [ diff --git a/pyproject.toml b/pyproject.toml index 1b9e2110..68c5c2a3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,7 +20,7 @@ dynamic = [ ] license = { file = "COPYING" } readme = "README.md" -requires-python = ">=3.13" +requires-python = ">=3.14" [project.urls] Changelog = "https://github.com/arcan1s/ahriman/releases"