From 0914910df5cdcd2a7f64ee80dc9405e8b8957557 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Thu, 5 Nov 2026 17:04:48 +0000 Subject: [PATCH] fix(cli): make the architecture legend's split strings explicit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit py/implicit-string-concatenation-in-list on PR #625 (architecture.py:147, :151): one table row and one paragraph were split over lines without parentheses; both are now parenthesized, likewise the f-string row ruff ISC004 flags. The new test pins four two-cell rows and one paragraph and fails with a comma inserted. 🎯 Fix: 97 % 💥 Break: 1 % 💸 Cost: – ⏱️ Time: – 🛡️ Security: ~100 % 🏆 Score: 96 🚦 Gate: ✅ 90/5, cost and time <= 100, security 100 % Co-Authored-By: Claude Opus 5.5 --- cli/build/docs/readme/architecture.py | 30 +++++++++++-------- .../build/docs/readme/test_architecture.py | 22 ++++++++++++++ 2 files changed, 39 insertions(+), 13 deletions(-) create mode 100644 tests/unit/python/cli/build/docs/readme/test_architecture.py diff --git a/cli/build/docs/readme/architecture.py b/cli/build/docs/readme/architecture.py index edc87dc579..a46f56fd84 100644 --- a/cli/build/docs/readme/architecture.py +++ b/cli/build/docs/readme/architecture.py @@ -144,16 +144,20 @@ def _volumes_legend() -> list[str]: return [ "| Condition | Effect |", "| --- | --- |", - "| swarm, `storage.backend: nfs`, no `nfs: false`, role not pinned " - "| shared over NFS |", + ( + "| swarm, `storage.backend: nfs`, no `nfs: false`, role not pinned " + "| shared over NFS |" + ), "| any one of those missing | node-local |", "", - "All four conditions must hold, so pinning a role takes every one of " - "its volumes node-local. Only the role's primary entry counts as " - "pinned here: a `placement` on any other service pins that service " - "alone and leaves the backing of every volume unchanged. The chain is " - "drawn rather than its result, because that coupling is what makes a " - "placement change move data without saying so.", + ( + "All four conditions must hold, so pinning a role takes every one of " + "its volumes node-local. Only the role's primary entry counts as " + "pinned here: a `placement` on any other service pins that service " + "alone and leaves the backing of every volume unchanged. The chain is " + "drawn rather than its result, because that coupling is what makes a " + "placement change move data without saying so." + ), ] @@ -168,8 +172,10 @@ def _dependencies_legend() -> list[str]: f"| {to_emoji('compose')} | deploys under compose |", f"| {to_emoji('swarm')} | deploys under swarm |", f"| {to_emoji('disabled')} | service explicitly turned off |", - f"| {to_emoji('role_dependency')} | Ansible role dependency from " - "`meta/main.yml` |", + ( + f"| {to_emoji('role_dependency')} | Ansible role dependency from " + "`meta/main.yml` |" + ), "", "Every dependency and dependent is listed; the graph is not truncated.", ] @@ -185,9 +191,7 @@ def derive_architecture_page(role_dir, role_name: str, app_name: str = "") -> st after it so both documents name the application the same way. """ role_dir = Path(role_dir) - role_placement = ( - get_role_placement(role_dir, role_name=role_name) or "" - ).strip() + role_placement = (get_role_placement(role_dir, role_name=role_name) or "").strip() sections = [ f"# {app_name or role_name} Architecture", "", diff --git a/tests/unit/python/cli/build/docs/readme/test_architecture.py b/tests/unit/python/cli/build/docs/readme/test_architecture.py new file mode 100644 index 0000000000..f6432f6c66 --- /dev/null +++ b/tests/unit/python/cli/build/docs/readme/test_architecture.py @@ -0,0 +1,22 @@ +from __future__ import annotations + +import unittest + +from cli.build.docs.readme.architecture import _volumes_legend + + +class TestVolumesLegend(unittest.TestCase): + def test_each_table_row_is_one_item_with_the_columns_of_the_header(self): + rows = [line for line in _volumes_legend() if line.startswith("|")] + self.assertEqual([3, 3, 3, 3], [row.count("|") for row in rows]) + self.assertIn("role not pinned | shared over NFS |", rows[2]) + + def test_the_explanation_below_the_table_is_one_paragraph(self): + prose = [line for line in _volumes_legend() if line and line[0] != "|"] + self.assertEqual(1, len(prose)) + self.assertTrue(prose[0].startswith("All four conditions must hold")) + self.assertTrue(prose[0].endswith("move data without saying so.")) + + +if __name__ == "__main__": + unittest.main()