cli-usereq 0.76.0__tar.gz → 0.76.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. {cli_usereq-0.76.0 → cli_usereq-0.76.1}/PKG-INFO +2 -2
  2. {cli_usereq-0.76.0 → cli_usereq-0.76.1}/README.md +1 -1
  3. {cli_usereq-0.76.0 → cli_usereq-0.76.1}/pyproject.toml +1 -1
  4. {cli_usereq-0.76.0 → cli_usereq-0.76.1}/src/usereq/__init__.py +19 -10
  5. {cli_usereq-0.76.0 → cli_usereq-0.76.1}/src/usereq/cli.py +50 -35
  6. {cli_usereq-0.76.0 → cli_usereq-0.76.1}/src/usereq/compress.py +23 -19
  7. {cli_usereq-0.76.0 → cli_usereq-0.76.1}/src/usereq/compress_files.py +1 -1
  8. {cli_usereq-0.76.0 → cli_usereq-0.76.1}/src/usereq/config_cli.py +12 -9
  9. {cli_usereq-0.76.0 → cli_usereq-0.76.1}/src/usereq/config_schema.py +9 -9
  10. {cli_usereq-0.76.0 → cli_usereq-0.76.1}/src/usereq/doxygen_parser.py +3 -5
  11. {cli_usereq-0.76.0 → cli_usereq-0.76.1}/src/usereq/find_constructs.py +3 -5
  12. {cli_usereq-0.76.0 → cli_usereq-0.76.1}/src/usereq/generate_markdown.py +1 -1
  13. {cli_usereq-0.76.0 → cli_usereq-0.76.1}/src/usereq/source_analyzer.py +33 -33
  14. {cli_usereq-0.76.0 → cli_usereq-0.76.1}/src/usereq/static_check.py +48 -40
  15. {cli_usereq-0.76.0 → cli_usereq-0.76.1}/src/usereq/table_style.py +1 -1
  16. {cli_usereq-0.76.0 → cli_usereq-0.76.1}/src/usereq/token_counter.py +2 -2
  17. {cli_usereq-0.76.0 → cli_usereq-0.76.1}/uv.lock +1 -1
  18. {cli_usereq-0.76.0 → cli_usereq-0.76.1}/LICENSE +0 -0
  19. {cli_usereq-0.76.0 → cli_usereq-0.76.1}/MANIFEST.in +0 -0
  20. {cli_usereq-0.76.0 → cli_usereq-0.76.1}/setup.cfg +0 -0
  21. {cli_usereq-0.76.0 → cli_usereq-0.76.1}/setup.py +0 -0
  22. {cli_usereq-0.76.0 → cli_usereq-0.76.1}/src/usereq/__main__.py +1 -1
  23. {cli_usereq-0.76.0 → cli_usereq-0.76.1}/src/usereq/resources/guidelines/Google_C++_Style_Guide.md +0 -0
  24. {cli_usereq-0.76.0 → cli_usereq-0.76.1}/src/usereq/resources/guidelines/Google_Python_Style_Guide.md +0 -0
  25. {cli_usereq-0.76.0 → cli_usereq-0.76.1}/src/usereq/resources/guidelines/Google_TypeScript_Style_Guide.md +0 -0
  26. {cli_usereq-0.76.0 → cli_usereq-0.76.1}/src/usereq/resources/guidelines/RFC2119.md +0 -0
  27. {cli_usereq-0.76.0 → cli_usereq-0.76.1}/src/usereq/resources/prompts/analyze.md +0 -0
  28. {cli_usereq-0.76.0 → cli_usereq-0.76.1}/src/usereq/resources/prompts/change.md +0 -0
  29. {cli_usereq-0.76.0 → cli_usereq-0.76.1}/src/usereq/resources/prompts/check.md +0 -0
  30. {cli_usereq-0.76.0 → cli_usereq-0.76.1}/src/usereq/resources/prompts/cover.md +0 -0
  31. {cli_usereq-0.76.0 → cli_usereq-0.76.1}/src/usereq/resources/prompts/create.md +0 -0
  32. {cli_usereq-0.76.0 → cli_usereq-0.76.1}/src/usereq/resources/prompts/fix.md +0 -0
  33. {cli_usereq-0.76.0 → cli_usereq-0.76.1}/src/usereq/resources/prompts/flowchart.md +0 -0
  34. {cli_usereq-0.76.0 → cli_usereq-0.76.1}/src/usereq/resources/prompts/implement.md +0 -0
  35. {cli_usereq-0.76.0 → cli_usereq-0.76.1}/src/usereq/resources/prompts/new.md +0 -0
  36. {cli_usereq-0.76.0 → cli_usereq-0.76.1}/src/usereq/resources/prompts/orchestrate.md +0 -0
  37. {cli_usereq-0.76.0 → cli_usereq-0.76.1}/src/usereq/resources/prompts/readme.md +0 -0
  38. {cli_usereq-0.76.0 → cli_usereq-0.76.1}/src/usereq/resources/prompts/recreate.md +0 -0
  39. {cli_usereq-0.76.0 → cli_usereq-0.76.1}/src/usereq/resources/prompts/refactor.md +0 -0
  40. {cli_usereq-0.76.0 → cli_usereq-0.76.1}/src/usereq/resources/prompts/references.md +0 -0
  41. {cli_usereq-0.76.0 → cli_usereq-0.76.1}/src/usereq/resources/prompts/renumber.md +0 -0
  42. {cli_usereq-0.76.0 → cli_usereq-0.76.1}/src/usereq/resources/prompts/workflow.md +0 -0
  43. {cli_usereq-0.76.0 → cli_usereq-0.76.1}/src/usereq/resources/prompts/write.md +0 -0
  44. {cli_usereq-0.76.0 → cli_usereq-0.76.1}/src/usereq/resources/prompts-version.txt +0 -0
  45. {cli_usereq-0.76.0 → cli_usereq-0.76.1}/src/usereq/resources/templates/Agentic_Text_Authoring_Guidance.md +0 -0
  46. {cli_usereq-0.76.0 → cli_usereq-0.76.1}/src/usereq/resources/templates/Document_Source_Code_in_Doxygen_Style.md +0 -0
  47. {cli_usereq-0.76.0 → cli_usereq-0.76.1}/src/usereq/resources/templates/HDT_Test_Authoring_Guide.md +0 -0
  48. {cli_usereq-0.76.0 → cli_usereq-0.76.1}/src/usereq/resources/templates/Requirements_Template.md +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cli-usereq
3
- Version: 0.76.0
3
+ Version: 0.76.1
4
4
  Summary: Initialize a project with prompts, agents, and templates from the useReq repository.
5
5
  Author: Ogekuri
6
6
  License-Expression: GPL-3.0-only
@@ -35,7 +35,7 @@ Dynamic: license-file
35
35
  > * **No Support or Feature Requests:** Please **do not** open issues, bug reports, or feature requests. They will not be addressed or accepted at this stage of development.
36
36
  > * **No Warranty:** This software is provided **"AS IS"**, without warranty of any kind, express or implied. You may use it strictly for **testing and evaluation purposes** at your own sole risk.
37
37
 
38
- # useReq / req (0.76.0)
38
+ # useReq / req (0.76.1)
39
39
 
40
40
  <p align="center">
41
41
  <img src="https://img.shields.io/badge/python-3.11%2B-3776AB?style=flat-square&logo=python&logoColor=white" alt="Python 3.11+">
@@ -10,7 +10,7 @@
10
10
  > * **No Support or Feature Requests:** Please **do not** open issues, bug reports, or feature requests. They will not be addressed or accepted at this stage of development.
11
11
  > * **No Warranty:** This software is provided **"AS IS"**, without warranty of any kind, express or implied. You may use it strictly for **testing and evaluation purposes** at your own sole risk.
12
12
 
13
- # useReq / req (0.76.0)
13
+ # useReq / req (0.76.1)
14
14
 
15
15
  <p align="center">
16
16
  <img src="https://img.shields.io/badge/python-3.11%2B-3776AB?style=flat-square&logo=python&logoColor=white" alt="Python 3.11+">
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "cli-usereq"
7
- version = "0.76.0"
7
+ version = "0.76.1"
8
8
  description = "Initialize a project with prompts, agents, and templates from the useReq repository."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
@@ -10,15 +10,18 @@ import of `usereq.cli` during package initialization.
10
10
  from __future__ import annotations
11
11
 
12
12
  import importlib
13
- from . import compress # usereq.compress submodule
14
- from . import compress_files # usereq.compress_files submodule
15
- from . import find_constructs # usereq.find_constructs submodule
16
- from . import generate_markdown # usereq.generate_markdown submodule
17
- from . import source_analyzer # usereq.source_analyzer submodule
18
- from . import token_counter # usereq.token_counter submodule
19
13
  from typing import Any
20
14
 
21
- __version__ = "0.76.0"
15
+ from . import (
16
+ compress, # usereq.compress submodule
17
+ compress_files, # usereq.compress_files submodule
18
+ find_constructs, # usereq.find_constructs submodule
19
+ generate_markdown, # usereq.generate_markdown submodule
20
+ source_analyzer, # usereq.source_analyzer submodule
21
+ token_counter, # usereq.token_counter submodule
22
+ )
23
+
24
+ __version__ = "0.76.1"
22
25
  """! @brief Semantic version string of the package."""
23
26
 
24
27
 
@@ -55,8 +58,14 @@ def __getattr__(name: str) -> Any:
55
58
 
56
59
 
57
60
  __all__ = [
58
- "__version__", "main", "cli",
59
- "source_analyzer", "token_counter", "generate_markdown",
60
- "compress", "compress_files", "find_constructs",
61
+ "__version__",
62
+ "cli",
63
+ "compress",
64
+ "compress_files",
65
+ "find_constructs",
66
+ "generate_markdown",
67
+ "main",
68
+ "source_analyzer",
69
+ "token_counter",
61
70
  ]
62
71
  """! @brief List of public symbols exported by the package."""
@@ -9,25 +9,27 @@
9
9
  from __future__ import annotations
10
10
 
11
11
  import argparse
12
- from datetime import datetime, timezone
13
- from email.utils import parsedate_to_datetime
12
+ import copy
14
13
  import json
15
14
  import os
16
15
  import platform
17
16
  import re
18
17
  import shutil
19
- import sys
20
18
  import subprocess
19
+ import sys
21
20
  import textwrap
22
21
  import time
23
22
  import tomllib
24
23
  import urllib.error
25
24
  import urllib.request
26
- import copy
27
- import yaml
28
25
  from argparse import Namespace
26
+ from collections.abc import Mapping
27
+ from datetime import UTC, datetime
28
+ from email.utils import parsedate_to_datetime
29
29
  from pathlib import Path
30
- from typing import Any, Mapping, Optional
30
+ from typing import Any
31
+
32
+ import yaml
31
33
 
32
34
  from . import config_cli
33
35
  from .config_schema import (
@@ -932,7 +934,7 @@ def build_parser() -> argparse.ArgumentParser:
932
934
  return parser
933
935
 
934
936
 
935
- def parse_args(argv: Optional[list[str]] = None) -> Namespace:
937
+ def parse_args(argv: list[str] | None = None) -> Namespace:
936
938
  """!
937
939
  @brief Parses command-line arguments into a namespace.
938
940
  @param argv List of arguments (defaults to sys.argv).
@@ -951,13 +953,13 @@ def load_package_version() -> str:
951
953
  """
952
954
  init_path = Path(__file__).resolve().parent / "__init__.py"
953
955
  text = init_path.read_text(encoding="utf-8")
954
- match = re.search(r'^__version__\s*=\s*"([^"]+)"\s*$', text, re.M)
956
+ match = re.search(r'^__version__\s*=\s*"([^"]+)"\s*$', text, re.MULTILINE)
955
957
  if not match:
956
958
  raise ReqError("Error: unable to determine package version", 6)
957
959
  return match.group(1)
958
960
 
959
961
 
960
- def maybe_print_version(argv: list[str], pypi_latest: Optional[str] = None) -> bool:
962
+ def maybe_print_version(argv: list[str], pypi_latest: str | None = None) -> bool:
961
963
  """!
962
964
  @brief Handles --ver/--version by printing installed, PyPI latest, and GitHub latest versions in aligned columns.
963
965
  @param argv Command line arguments to check.
@@ -986,7 +988,7 @@ def maybe_print_version(argv: list[str], pypi_latest: Optional[str] = None) -> b
986
988
  ):
987
989
  pypi_latest = None
988
990
  try:
989
- github_latest: Optional[str] = fetch_github_latest_version(
991
+ github_latest: str | None = fetch_github_latest_version(
990
992
  RELEASE_CHECK_TIMEOUT_SECONDS
991
993
  )
992
994
  except (
@@ -1374,7 +1376,7 @@ def resolve_pypi_latest_version_url() -> str:
1374
1376
 
1375
1377
  def fetch_pypi_latest_version(
1376
1378
  timeout_seconds: float = RELEASE_CHECK_TIMEOUT_SECONDS,
1377
- ) -> Optional[str]:
1379
+ ) -> str | None:
1378
1380
  """!
1379
1381
  @brief Fetch the latest published version of `cli-usereq` from the PyPI JSON API.
1380
1382
  @param timeout_seconds {float} Timeout for the HTTP GET request.
@@ -1413,7 +1415,7 @@ def fetch_github_latest_version(
1413
1415
  timeout_seconds: float = RELEASE_CHECK_TIMEOUT_SECONDS,
1414
1416
  *,
1415
1417
  raw_tag: bool = False,
1416
- ) -> Optional[str]:
1418
+ ) -> str | None:
1417
1419
  """!
1418
1420
  @brief Fetch the latest GitHub release version from the GitHub latest-release API.
1419
1421
  @param timeout_seconds {float} Timeout for the HTTP GET request.
@@ -1460,7 +1462,7 @@ def format_unix_timestamp_utc(timestamp_seconds: int) -> str:
1460
1462
  """
1461
1463
  return datetime.fromtimestamp(
1462
1464
  timestamp_seconds,
1463
- tz=timezone.utc,
1465
+ tz=UTC,
1464
1466
  ).strftime("%Y-%m-%dT%H:%M:%SZ")
1465
1467
 
1466
1468
 
@@ -1521,7 +1523,7 @@ def read_release_check_idle_state(file_path: Path) -> dict[str, int | str] | Non
1521
1523
 
1522
1524
  payload = json.loads(file_path.read_text(encoding="utf-8"))
1523
1525
  if not isinstance(payload, dict):
1524
- raise ValueError("idle-state JSON root must be an object")
1526
+ raise ValueError("idle-state JSON root must be an object") # noqa: TRY004
1525
1527
 
1526
1528
  required_keys = (
1527
1529
  "last_success_timestamp",
@@ -1541,9 +1543,9 @@ def read_release_check_idle_state(file_path: Path) -> dict[str, int | str] | Non
1541
1543
  idle_until_human_readable_timestamp = payload["idle_until_human_readable_timestamp"]
1542
1544
 
1543
1545
  if not isinstance(last_success_timestamp, (int, float)):
1544
- raise ValueError("idle-state key 'last_success_timestamp' must be numeric")
1546
+ raise ValueError("idle-state key 'last_success_timestamp' must be numeric") # noqa: TRY004
1545
1547
  if not isinstance(idle_until_timestamp, (int, float)):
1546
- raise ValueError("idle-state key 'idle_until_timestamp' must be numeric")
1548
+ raise ValueError("idle-state key 'idle_until_timestamp' must be numeric") # noqa: TRY004
1547
1549
  if (
1548
1550
  not isinstance(last_success_human_readable_timestamp, str)
1549
1551
  or not last_success_human_readable_timestamp.strip()
@@ -1620,7 +1622,7 @@ def parse_retry_after_seconds(
1620
1622
  if parsed_datetime is None:
1621
1623
  return None
1622
1624
  if parsed_datetime.tzinfo is None:
1623
- parsed_datetime = parsed_datetime.replace(tzinfo=timezone.utc)
1625
+ parsed_datetime = parsed_datetime.replace(tzinfo=UTC)
1624
1626
  return max(0, int(parsed_datetime.timestamp()) - now_timestamp)
1625
1627
 
1626
1628
 
@@ -1740,7 +1742,7 @@ def persist_failed_release_check_idle_state(
1740
1742
 
1741
1743
  def maybe_notify_newer_version(
1742
1744
  timeout_seconds: float = RELEASE_CHECK_TIMEOUT_SECONDS,
1743
- ) -> Optional[str]:
1745
+ ) -> str | None:
1744
1746
  """!
1745
1747
  @brief Executes idle-gated online PyPI version check and prints bright colored status messages.
1746
1748
  @param timeout_seconds Time to wait for the version check response.
@@ -2000,7 +2002,7 @@ def make_relative_if_contains_project(path_value: str, project_base: Path) -> st
2000
2002
  return path_value
2001
2003
 
2002
2004
 
2003
- def resolve_absolute(normalized: str, project_base: Path) -> Optional[Path]:
2005
+ def resolve_absolute(normalized: str, project_base: Path) -> Path | None:
2004
2006
  """!
2005
2007
  @brief Resolves the absolute path starting from a normalized value.
2006
2008
  @param normalized The normalized relative path string.
@@ -2027,6 +2029,7 @@ def resolve_git_root(target_path: Path) -> Path:
2027
2029
  try:
2028
2030
  result = subprocess.run(
2029
2031
  ["git", "rev-parse", "--show-toplevel"],
2032
+ check=False,
2030
2033
  capture_output=True,
2031
2034
  text=True,
2032
2035
  cwd=str(target_path),
@@ -2091,8 +2094,8 @@ def save_config(
2091
2094
  doc_dir_value: str,
2092
2095
  test_dir_value: str,
2093
2096
  src_dir_values: list[str],
2094
- static_check_config: Optional[dict] = None,
2095
- providers: Optional[list[str]] = None,
2097
+ static_check_config: dict | None = None,
2098
+ providers: list[str] | None = None,
2096
2099
  ) -> None:
2097
2100
  """!
2098
2101
  @brief Saves normalized directory parameters to the user-global configuration file.
@@ -2123,9 +2126,9 @@ def save_config(
2123
2126
 
2124
2127
 
2125
2128
  def update_directory_config(
2126
- docs_dir_value: Optional[str] = None,
2127
- tests_dir_value: Optional[str] = None,
2128
- src_dir_values: Optional[list[str]] = None,
2129
+ docs_dir_value: str | None = None,
2130
+ tests_dir_value: str | None = None,
2131
+ src_dir_values: list[str] | None = None,
2129
2132
  ) -> None:
2130
2133
  """!
2131
2134
  @brief Persist one or more directory configuration keys while preserving unrelated keys.
@@ -2255,7 +2258,7 @@ def load_static_check_from_config() -> dict:
2255
2258
 
2256
2259
  def _static_check_entry_identity(
2257
2260
  canonical_lang: str, entry: Mapping[str, Any]
2258
- ) -> tuple[str, str, Optional[str], tuple[str, ...]]:
2261
+ ) -> tuple[str, str, str | None, tuple[str, ...]]:
2259
2262
  """!
2260
2263
  @brief Build the canonical identity tuple for one static-check entry.
2261
2264
  @param canonical_lang Canonical language key that owns the entry.
@@ -2495,6 +2498,8 @@ def apply_disable_static_check_specs(specs: list[str]) -> None:
2495
2498
  """
2496
2499
  from .static_check import (
2497
2500
  STATIC_CHECK_LANG_CANONICAL,
2501
+ )
2502
+ from .static_check import (
2498
2503
  parse_enable_static_check as _parse_sc,
2499
2504
  )
2500
2505
 
@@ -2746,7 +2751,7 @@ def extract_frontmatter(content: str) -> tuple[str, str]:
2746
2751
  @param content Input parameter `content`.
2747
2752
  @return {tuple[str, str]} Function return value.
2748
2753
  """
2749
- match = re.match(r"^\s*---\s*\n(.*?)\n---\s*\n(.*)$", content, re.S)
2754
+ match = re.match(r"^\s*---\s*\n(.*?)\n---\s*\n(.*)$", content, re.DOTALL)
2750
2755
  if not match:
2751
2756
  raise ReqError("No leading '---' block found at start of Markdown file.", 4)
2752
2757
  # Explicitly return two strings to satisfy type annotation.
@@ -3223,7 +3228,7 @@ def run_set_directories(args: Namespace) -> None:
3223
3228
  tests_value = getattr(args, "set_tests_dir", None)
3224
3229
  src_values = getattr(args, "set_src_dir", None)
3225
3230
 
3226
- normalized_docs: Optional[str] = None
3231
+ normalized_docs: str | None = None
3227
3232
  if docs_value is not None:
3228
3233
  normalized_docs = make_relative_if_contains_project(
3229
3234
  docs_value, project_base
@@ -3233,7 +3238,7 @@ def run_set_directories(args: Namespace) -> None:
3233
3238
  if abs_docs and not abs_docs.resolve().is_relative_to(project_base):
3234
3239
  raise ReqError("Error: docs-dir must be under the project base", 4)
3235
3240
 
3236
- normalized_tests: Optional[str] = None
3241
+ normalized_tests: str | None = None
3237
3242
  if tests_value is not None:
3238
3243
  normalized_tests = make_relative_if_contains_project(
3239
3244
  tests_value, project_base
@@ -3243,7 +3248,7 @@ def run_set_directories(args: Namespace) -> None:
3243
3248
  if abs_tests and not abs_tests.resolve().is_relative_to(project_base):
3244
3249
  raise ReqError("Error: tests-dir must be under the project base", 4)
3245
3250
 
3246
- normalized_srcs: Optional[list[str]] = None
3251
+ normalized_srcs: list[str] | None = None
3247
3252
  if src_values:
3248
3253
  normalized_srcs = []
3249
3254
  for src_value in src_values:
@@ -3653,8 +3658,7 @@ def _collect_source_files(src_dirs: list[str], project_base: Path) -> list[str]:
3653
3658
  collected: set[str] = set()
3654
3659
  for rel_path in output.splitlines():
3655
3660
  rel_posix = Path(rel_path.strip()).as_posix()
3656
- if rel_posix.startswith("./"):
3657
- rel_posix = rel_posix[2:]
3661
+ rel_posix = rel_posix.removeprefix("./")
3658
3662
  if not rel_posix:
3659
3663
  continue
3660
3664
  if not any(
@@ -3855,6 +3859,7 @@ def run_git_check(args: Namespace) -> None:
3855
3859
  try:
3856
3860
  result = subprocess.run(
3857
3861
  ["bash", "-c", cmd],
3862
+ check=False,
3858
3863
  capture_output=True,
3859
3864
  text=True,
3860
3865
  cwd=str(git_path),
@@ -3910,6 +3915,7 @@ def run_git_wt_name(args: Namespace) -> None:
3910
3915
  try:
3911
3916
  branch_result = subprocess.run(
3912
3917
  ["git", "branch", "--show-current"],
3918
+ check=False,
3913
3919
  capture_output=True,
3914
3920
  text=True,
3915
3921
  cwd=str(git_path),
@@ -3935,6 +3941,7 @@ def _worktree_path_exists_exact(git_path: Path, target_path: Path) -> bool:
3935
3941
  try:
3936
3942
  wt_list = subprocess.run(
3937
3943
  ["git", "worktree", "list", "--porcelain"],
3944
+ check=False,
3938
3945
  capture_output=True,
3939
3946
  text=True,
3940
3947
  cwd=str(git_path),
@@ -3966,6 +3973,7 @@ def _rollback_worktree_create(git_path: Path, wt_path: Path, wt_name: str) -> No
3966
3973
  try:
3967
3974
  remove_result = subprocess.run(
3968
3975
  ["git", "worktree", "remove", str(wt_path), "--force"],
3976
+ check=False,
3969
3977
  capture_output=True,
3970
3978
  text=True,
3971
3979
  cwd=str(git_path),
@@ -3973,6 +3981,7 @@ def _rollback_worktree_create(git_path: Path, wt_path: Path, wt_name: str) -> No
3973
3981
  )
3974
3982
  branch_result = subprocess.run(
3975
3983
  ["git", "branch", "-D", wt_name],
3984
+ check=False,
3976
3985
  capture_output=True,
3977
3986
  text=True,
3978
3987
  cwd=str(git_path),
@@ -4013,6 +4022,7 @@ def run_git_wt_create(args: Namespace) -> None:
4013
4022
  try:
4014
4023
  result = subprocess.run(
4015
4024
  ["git", "worktree", "add", str(wt_dest), "-b", wt_name],
4025
+ check=False,
4016
4026
  capture_output=True,
4017
4027
  text=True,
4018
4028
  cwd=str(git_path),
@@ -4066,6 +4076,7 @@ def run_git_wt_delete(args: Namespace) -> None:
4066
4076
  try:
4067
4077
  br = subprocess.run(
4068
4078
  ["git", "show-ref", "--verify", f"refs/heads/{wt_name}"],
4079
+ check=False,
4069
4080
  capture_output=True,
4070
4081
  text=True,
4071
4082
  cwd=str(git_path),
@@ -4090,6 +4101,7 @@ def run_git_wt_delete(args: Namespace) -> None:
4090
4101
  try:
4091
4102
  r1 = subprocess.run(
4092
4103
  ["git", "worktree", "remove", str(wt_path), "--force"],
4104
+ check=False,
4093
4105
  capture_output=True,
4094
4106
  text=True,
4095
4107
  cwd=str(base_path),
@@ -4103,6 +4115,7 @@ def run_git_wt_delete(args: Namespace) -> None:
4103
4115
  try:
4104
4116
  r2 = subprocess.run(
4105
4117
  ["git", "branch", "-D", wt_name],
4118
+ check=False,
4106
4119
  capture_output=True,
4107
4120
  text=True,
4108
4121
  cwd=str(base_path),
@@ -4461,7 +4474,7 @@ def run_project_static_check_cmd(args: Namespace) -> int:
4461
4474
  project_base, src_dirs = _resolve_project_src_dirs(args)
4462
4475
  sc_config = load_static_check_from_config()
4463
4476
  selection_dirs = list(src_dirs)
4464
- tests_dir_rel: Optional[str] = None
4477
+ tests_dir_rel: str | None = None
4465
4478
 
4466
4479
  # SRS-336: append tests-dir to file selection; skip silently if missing/invalid
4467
4480
  try:
@@ -4785,7 +4798,7 @@ def run_config_schema_command(args: Namespace) -> int:
4785
4798
  return exc.code
4786
4799
 
4787
4800
 
4788
- def main(argv: Optional[list[str]] = None) -> int:
4801
+ def main(argv: list[str] | None = None) -> int:
4789
4802
  """!
4790
4803
  @brief CLI entry point for console_scripts and `-m` execution.
4791
4804
  @details Returns an exit code (0 success, non-zero on error).
@@ -4800,7 +4813,7 @@ def main(argv: Optional[list[str]] = None) -> int:
4800
4813
  global FORCE_ONLINE_RELEASE_CHECK
4801
4814
  previous_force_online_release_check = FORCE_ONLINE_RELEASE_CHECK
4802
4815
  FORCE_ONLINE_RELEASE_CHECK = force_online_release_check
4803
- pypi_latest_from_check: Optional[str] = None
4816
+ pypi_latest_from_check: str | None = None
4804
4817
  try:
4805
4818
  pypi_latest_from_check = maybe_notify_newer_version(
4806
4819
  timeout_seconds=RELEASE_CHECK_TIMEOUT_SECONDS
@@ -4905,7 +4918,9 @@ def main(argv: Optional[list[str]] = None) -> int:
4905
4918
  except ReqError as e:
4906
4919
  print(e.message, file=sys.stderr)
4907
4920
  return e.code
4908
- except Exception as e: # Unexpected error
4921
+ # Intentional top-level guard: any unexpected error must degrade to an English
4922
+ # one-line diagnostic and exit code 1 without leaking a stack trace in normal mode.
4923
+ except Exception as e: # noqa: BLE001
4909
4924
  print(f"Unexpected error: {e}", file=sys.stderr)
4910
4925
  if DEBUG:
4911
4926
  import traceback
@@ -236,26 +236,30 @@ def compress_source(source: str, language: str) -> str:
236
236
  # after optional whitespace).
237
237
  if is_python:
238
238
  for q in ('"""', "'''"):
239
- if stripped.startswith(q):
239
+ if (
240
+ stripped.startswith(q)
241
+ and stripped.count(q) >= 2
242
+ and stripped.endswith(q)
243
+ and len(stripped) > 3
244
+ ):
240
245
  # Single-line docstring: """..."""
241
- if stripped.count(q) >= 2 and stripped.endswith(q) and len(stripped) > 3:
242
- # Check it's not a variable assignment like x = """..."""
243
- leading = line[:len(line) - len(line.lstrip())]
244
- code_before = line[:line.index(q)].strip()
245
- if not code_before or code_before.endswith('='):
246
- # Standalone docstring or assigned — skip if standalone
247
- if not code_before:
248
- line = None
249
- break
250
- # If code before and not assignment, keep line
251
- elif stripped.startswith(q) and stripped.count(q) == 1:
252
- # Multi-line docstring start
253
- code_before = line[:line.index(q)].strip()
254
- if not code_before:
255
- in_python_docstring = True
256
- python_docstring_delim = q
257
- line = None
258
- break
246
+ # Check it's not a variable assignment like x = """..."""
247
+ leading = line[:len(line) - len(line.lstrip())]
248
+ code_before = line[:line.index(q)].strip()
249
+ # Skip standalone docstrings; docstrings assigned to a
250
+ # variable keep the line (outer filter is behavior-neutral).
251
+ if not code_before:
252
+ line = None
253
+ break
254
+ # If code before and not assignment, keep line
255
+ elif stripped.startswith(q) and stripped.count(q) == 1:
256
+ # Multi-line docstring start
257
+ code_before = line[:line.index(q)].strip()
258
+ if not code_before:
259
+ in_python_docstring = True
260
+ python_docstring_delim = q
261
+ line = None
262
+ break
259
263
  if line is None:
260
264
  i += 1
261
265
  continue
@@ -85,7 +85,7 @@ def compress_files(filepaths: list[str],
85
85
  ok_count += 1
86
86
  if verbose:
87
87
  print(f" OK {fpath}", file=sys.stderr)
88
- except Exception as e:
88
+ except Exception as e: # noqa: BLE001 -- per-file resilience guard
89
89
  if verbose:
90
90
  print(f" FAIL {fpath} ({e})", file=sys.stderr)
91
91
  fail_count += 1
@@ -19,9 +19,10 @@ import shlex
19
19
  import stat
20
20
  import tempfile
21
21
  import unicodedata
22
+ from collections.abc import Sequence
22
23
  from dataclasses import dataclass, field
23
24
  from pathlib import Path
24
- from typing import Any, Optional, Sequence
25
+ from typing import Any
25
26
 
26
27
  from .config_schema import (
27
28
  CONFIG_KEYS,
@@ -87,7 +88,7 @@ class RenderNode:
87
88
  kind: str
88
89
  heading: str
89
90
  details: list[list[str]] = field(default_factory=list)
90
- children: list["RenderNode"] = field(default_factory=list)
91
+ children: list[RenderNode] = field(default_factory=list)
91
92
 
92
93
 
93
94
  @dataclass
@@ -322,7 +323,7 @@ def write_config(config_path: Path, config: dict[str, Any]) -> None:
322
323
  raise ConfigError(
323
324
  f"Error: cannot create configuration directory '{config_path.parent}': {exc}"
324
325
  ) from exc
325
- tmp_name: Optional[str] = None
326
+ tmp_name: str | None = None
326
327
  try:
327
328
  fd, tmp_name = tempfile.mkstemp(
328
329
  dir=str(config_path.parent), prefix=config_path.name + ".", suffix=".tmp"
@@ -508,7 +509,7 @@ def resolve_target(config: dict[str, Any], path: str) -> Target:
508
509
  return Target(
509
510
  "map_key",
510
511
  spec.item,
511
- value[token] if token in value else MISSING,
512
+ value.get(token, MISSING),
512
513
  value,
513
514
  token,
514
515
  )
@@ -530,7 +531,7 @@ def resolve_target(config: dict[str, Any], path: str) -> Target:
530
531
  return Target(
531
532
  "dict_field",
532
533
  child,
533
- value[token] if token in value else MISSING,
534
+ value.get(token, MISSING),
534
535
  value,
535
536
  token,
536
537
  )
@@ -732,7 +733,7 @@ def _sanitize_cell(text: str) -> str:
732
733
  elif char == "\t":
733
734
  out.append("\\t")
734
735
  elif ord(char) < 0x20 or ord(char) == 0x7F:
735
- out.append("\\x{:02x}".format(ord(char)))
736
+ out.append(f"\\x{ord(char):02x}")
736
737
  else:
737
738
  out.append(char)
738
739
  return "".join(out)
@@ -1093,8 +1094,10 @@ def _info_parameter_details(spec: SchemaNode, path: str) -> list[list[str]]:
1093
1094
  if spec.has_default:
1094
1095
  details.append(
1095
1096
  [
1096
- f"Default : {_json_value(spec.default)} "
1097
- f"(restored via: --unset {path})"
1097
+ (
1098
+ f"Default : {_json_value(spec.default)} "
1099
+ f"(restored via: --unset {path})"
1100
+ )
1098
1101
  ]
1099
1102
  )
1100
1103
  if spec.kind in (KIND_STRING, KIND_BOOLEAN):
@@ -1377,7 +1380,7 @@ def handle_print_raw(config_path: Path) -> bytes:
1377
1380
  ) from exc
1378
1381
 
1379
1382
 
1380
- def handle_display(config_path: Path, path: Optional[str], info: bool) -> str:
1383
+ def handle_display(config_path: Path, path: str | None, info: bool) -> str:
1381
1384
  """!
1382
1385
  @brief Execute one `--print` or `--info` display request.
1383
1386
  @param config_path {Path} Absolute global configuration file path.
@@ -13,7 +13,7 @@ parameter lists (SRS-521, SRS-542).
13
13
  from __future__ import annotations
14
14
 
15
15
  from dataclasses import dataclass
16
- from typing import Any, Optional
16
+ from typing import Any
17
17
 
18
18
  KIND_SECTION = "section"
19
19
  """! @brief Schema node kind for a named configuration section (SRS-523)."""
@@ -227,13 +227,13 @@ class SchemaNode:
227
227
  default: Any = NO_DEFAULT
228
228
  non_empty: bool = False
229
229
  optional: bool = False
230
- enum: Optional[tuple[str, ...]] = None
231
- enum_meanings: Optional[dict[str, str]] = None
232
- example: Optional[str] = None
233
- key_enum: Optional[tuple[str, ...]] = None
234
- item: Optional["SchemaNode"] = None
235
- fields: tuple["SchemaNode", ...] = ()
236
- children: tuple["SchemaNode", ...] = ()
230
+ enum: tuple[str, ...] | None = None
231
+ enum_meanings: dict[str, str] | None = None
232
+ example: str | None = None
233
+ key_enum: tuple[str, ...] | None = None
234
+ item: SchemaNode | None = None
235
+ fields: tuple[SchemaNode, ...] = ()
236
+ children: tuple[SchemaNode, ...] = ()
237
237
 
238
238
  @property
239
239
  def has_default(self) -> bool:
@@ -395,7 +395,7 @@ CONFIG_KEYS: tuple[str, ...] = tuple(child.token for child in CONFIG_SECTION.chi
395
395
  """! @brief Canonical persisted configuration keys in schema order (SRS-288, SRS-521)."""
396
396
 
397
397
 
398
- def find_field(node: SchemaNode, token: str) -> Optional[SchemaNode]:
398
+ def find_field(node: SchemaNode, token: str) -> SchemaNode | None:
399
399
  """!
400
400
  @brief Look up one ordered child field of a section or dictionary node.
401
401
  @param node {SchemaNode} Section or dictionary node providing the candidate fields.
@@ -8,8 +8,6 @@
8
8
  """
9
9
 
10
10
  import re
11
- from typing import Dict, List
12
-
13
11
 
14
12
  # Supported Doxygen tags in extraction order
15
13
  DOXYGEN_TAGS = [
@@ -48,7 +46,7 @@ DOXYGEN_TAG_PATTERN = re.compile(
48
46
  """! @brief Compiled regex that matches supported @tag / \\tag tokens."""
49
47
 
50
48
 
51
- def parse_doxygen_comment(comment_text: str) -> Dict[str, List[str]]:
49
+ def parse_doxygen_comment(comment_text: str) -> dict[str, list[str]]:
52
50
  """!
53
51
  @brief Extract Doxygen fields from a documentation comment block.
54
52
  @details Parses both @tag and \\tag syntax. Each tag's content extends until the next tag or end of comment. Multiple occurrences of the same tag accumulate in the returned list. Whitespace is normalized.
@@ -60,7 +58,7 @@ def parse_doxygen_comment(comment_text: str) -> Dict[str, List[str]]:
60
58
  if not comment_text or not comment_text.strip():
61
59
  return {}
62
60
 
63
- result: Dict[str, List[str]] = {}
61
+ result: dict[str, list[str]] = {}
64
62
 
65
63
  # Normalize line endings and strip comment delimiters
66
64
  text = comment_text.replace('\r\n', '\n').replace('\r', '\n')
@@ -152,7 +150,7 @@ def _normalize_whitespace(text: str) -> str:
152
150
  return '\n'.join(normalized_lines).strip()
153
151
 
154
152
 
155
- def format_doxygen_fields_as_markdown(doxygen_fields: Dict[str, List[str]]) -> List[str]:
153
+ def format_doxygen_fields_as_markdown(doxygen_fields: dict[str, list[str]]) -> list[str]:
156
154
  """!
157
155
  @brief Format extracted Doxygen fields as Markdown bulleted list.
158
156
  @details Emits fields in fixed order (DOXYGEN_TAGS) preserving original Doxygen tag tokens with `@` prefix and no `:` suffix. Skips tags not present in input. Each extracted field occurrence is emitted as an independent markdown bullet.
@@ -11,10 +11,9 @@ import os
11
11
  import re
12
12
  import sys
13
13
 
14
+ from .compress import detect_language
14
15
  from .doxygen_parser import format_doxygen_fields_as_markdown, parse_doxygen_comment
15
16
  from .source_analyzer import SourceAnalyzer
16
- from .compress import detect_language
17
-
18
17
 
19
18
  # ── Language-specific TAG support map ────────────────────────────────────────
20
19
  LANGUAGE_TAGS = {
@@ -185,8 +184,7 @@ def format_construct(
185
184
  code_lines = source_lines[element.line_start - 1:element.line_end]
186
185
  numbered_lines = []
187
186
  for offset, line in enumerate(code_lines):
188
- if line.endswith("\n"):
189
- line = line[:-1]
187
+ line = line.removesuffix("\n")
190
188
  numbered_lines.append(f"{element.line_start + offset}: {line}")
191
189
  formatted = "\n".join(numbered_lines)
192
190
 
@@ -281,7 +279,7 @@ def find_constructs_in_files(
281
279
  print(f" SKIP {fpath} (no matches)", file=sys.stderr)
282
280
  skip_count += 1
283
281
 
284
- except Exception as e:
282
+ except Exception as e: # noqa: BLE001 -- per-file resilience guard
285
283
  if verbose:
286
284
  print(f" FAIL {fpath} ({e})", file=sys.stderr)
287
285
  fail_count += 1