style: settle the formatter and linter rewrites of this change set

ruff format reflows long calls and normalises quotes, isort reorders the
imports of the documentation lint package, SIM117 folds nested `with`
statements into one parenthesised block, TC003 moves typing-only imports
under `if TYPE_CHECKING`, the JavaScript linter replaces a `var`, and the
YAML formatter rewraps five role files. None of it changes behaviour.

One entry does more than that: the formatter had reflowed two calls in
test_builder.py so their `# nocheck: cache-read` markers landed on the
closing parenthesis, where they suppress nothing and the cache-read lint
would have reported two real violations. Both calls are hoisted into a
variable so the marker sits on the reading line again.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
kevinveenbirkenbachandClaude Opus 5 committed 2026-09-26 04:53:30 +02:00
1 parent c39f3ec9ee
commit 2ba37b55b2
27 files changed
+67 -71

No files matched your search

+1 -2
View File
@@ -44,8 +44,7 @@ TOR_DNSMASQ_DROPIN: "/etc/systemd/system/dnsmasq.service.d/infinito-restart.conf
# nocheck: host-local-fact meta/services.yml pins this role to the manager, so the fact describes the node the hidden service forwards on
TOR_CONTAINER_DNS_HOST: "{{ ansible_facts['docker0']['ipv4']['address'] | default('', true) }}"
# nocheck: host-local-fact meta/services.yml pins this role to the manager, so the fact describes the node the hidden service forwards on
TOR_HS_BACKEND_HOST: "{{ ansible_facts['default_ipv4']['address'] if IS_SWARM_MODE else (TOR_CONTAINER_DNS_HOST | ternary(TOR_CONTAINER_DNS_HOST, '127.0.0.1'))
}}"
TOR_HS_BACKEND_HOST: "{{ ansible_facts['default_ipv4']['address'] if IS_SWARM_MODE else (TOR_CONTAINER_DNS_HOST | ternary(TOR_CONTAINER_DNS_HOST, '127.0.0.1')) }}"
TOR_DATA_DIR: "{{ [ DIR_VAR_LIB, application_id, 'data' ] | path_join }}"
TOR_CONFIG_DIR: "{{ [ DIR_VAR_LIB, application_id, 'config' ] | path_join }}"
@@ -13,8 +13,8 @@
# Param: resolve_cid_filters - extra `container ps` filters for the cid lookup (default '')
- name: "🔧 resolve_host_cid | resolve swarm service name for '{{ resolve_service_key }}'"
ansible.builtin.set_fact:
_resolve_service_name: "{{ (resolve_service_name | default('')) or (lookup('container_service', application_id, resolve_service_key) if IS_SWARM_MODE
else '') }}"
_resolve_service_name: "{{ (resolve_service_name | default('')) or (lookup('container_service', application_id, resolve_service_key) if IS_SWARM_MODE else '')
}}"
- name: "⏳ resolve_host_cid | wait for '{{ resolve_service_key }}' to converge"
ansible.builtin.include_tasks: "{{ lookup('path_absolute', 'roles/sys-svc-compose/tasks/utils/swarm/wait_converged.yml') }}"
+2 -2
View File
@@ -19,6 +19,6 @@
- networks.internet.dns | length > 0
environment:
BUSYBOX_IMAGE: "{{ lookup('config', 'sys-svc-container', 'services.busybox.image') }}:{{ lookup('config', 'sys-svc-container', 'services.busybox.version') }}"
NODE_IMAGE: "{{ '' if IS_SWARM_MODE else lookup('config', 'sys-svc-container', 'services.node.image') ~ ':' ~ lookup('config', 'sys-svc-container',
'services.node.version') }}"
NODE_IMAGE: "{{ '' if IS_SWARM_MODE else lookup('config', 'sys-svc-container', 'services.node.image') ~ ':' ~ lookup('config', 'sys-svc-container', 'services.node.version')
}}"
DOMAIN: "{{ DOMAIN_PRIMARY }}"
+1 -2
View File
@@ -4,8 +4,7 @@
- name: "✅ Assert {{ DIR_VAR_LIB }} is cluster-shared in swarm mode"
ansible.builtin.assert:
that:
- (IS_COMPOSE_MODE) or ('svc-swarm-node' not in group_names) or ('svc-storage-nfs-client' in group_names) or ('svc-storage-nfs-server' in
group_names)
- (IS_COMPOSE_MODE) or ('svc-swarm-node' not in group_names) or ('svc-storage-nfs-client' in group_names) or ('svc-storage-nfs-server' in group_names)
fail_msg: >-
sys-svc-mail-msmtp on a swarm member requires svc-storage-nfs-client
so {{ DIR_VAR_LIB }} is cluster-shared. Set `storage.backend=nfs` and
+2 -2
View File
@@ -27,8 +27,8 @@ TEST_E2E_PLAYWRIGHT_PERSONAS_ARCHIVE: "/tmp/infinito-playwright-personas.tar"
TEST_E2E_PLAYWRIGHT_SHARED_STAMP: "{{ TEST_E2E_PLAYWRIGHT_SHARED_DIR }}/.installed-version"
TEST_E2E_PLAYWRIGHT_IS_ONION: "{{ lookup('tls', application_id, 'url.base') is search('\\.onion') }}"
TEST_E2E_PLAYWRIGHT_PROXY: "{{ ('socks5://' ~ lookup('tor_socks', '127.0.0.1' if IS_SWARM_MODE else 'host.docker.internal')) if (TEST_E2E_PLAYWRIGHT_IS_ONION
| bool) else '' }}"
TEST_E2E_PLAYWRIGHT_PROXY: "{{ ('socks5://' ~ lookup('tor_socks', '127.0.0.1' if IS_SWARM_MODE else 'host.docker.internal')) if (TEST_E2E_PLAYWRIGHT_IS_ONION | bool)
else '' }}"
TEST_E2E_PLAYWRIGHT_ONION_RUN_TIMEOUT: 5400
TEST_E2E_PLAYWRIGHT_RUN_TIMEOUT_EFFECTIVE: "{{ TEST_E2E_PLAYWRIGHT_ONION_RUN_TIMEOUT if (TEST_E2E_PLAYWRIGHT_IS_ONION | bool) else test_e2e_playwright_run_timeout
@@ -2,7 +2,7 @@
if (typeof window.mermaid === "undefined") {
return;
}
var dark = window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches;
const dark = window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches;
window.mermaid.initialize({
startOnLoad: true,
securityLevel: "strict",
@@ -7,7 +7,6 @@ from pathlib import Path
from utils.cache.yaml import load_yaml
from utils.roles.mapping import ROLE_FILE_META_MAIN, ROLE_FILE_README
SECTION_CHARS = set("=-`:'\"~^_*+#<>")
@@ -91,10 +90,7 @@ def generate_ansible_roles_doc(roles_dir, output_dir):
"Variables",
"---------",
"",
*(
f"- **{key}**: {_one_line(value)}"
for key, value in galaxy_info.items()
),
*(f"- **{key}**: {_one_line(value)}" for key, value in galaxy_info.items()),
]
text = "\n".join(lines) + "\n"
+3 -1
View File
@@ -58,7 +58,9 @@ class TestAuthorProfile(unittest.TestCase):
status, detail = _probe(self.url)
if status is None:
warning(f"{self.url} was not answered ({detail}); profile unverified")
raise unittest.SkipTest("the instance answered the canary but not the probe")
raise unittest.SkipTest(
"the instance answered the canary but not the probe"
)
self.assertIn(
status,
@@ -37,12 +37,8 @@ _IF = re.compile(r"\{%\s*if\s+(?P<expr>.+?)\s*%\}")
_ELIF = re.compile(r"\{%\s*elif\s+(?P<expr>.+?)\s*%\}")
_ELSE = re.compile(r"\{%\s*else\s*%\}")
_ENDIF = re.compile(r"\{%\s*endif\s*%\}")
_COMPOSE_ONLY_GATE = re.compile(
r"not\s+IS_SWARM_MODE|IS_COMPOSE_MODE"
)
_SWARM_ONLY_GATE = re.compile(
r"(?<!not )IS_SWARM_MODE|not\s+IS_COMPOSE_MODE"
)
_COMPOSE_ONLY_GATE = re.compile(r"not\s+IS_SWARM_MODE|IS_COMPOSE_MODE")
_SWARM_ONLY_GATE = re.compile(r"(?<!not )IS_SWARM_MODE|not\s+IS_COMPOSE_MODE")
_SHORT_FORM_RO = re.compile(
r"""
@@ -32,12 +32,8 @@ _IF = re.compile(r"\{%\s*if\s+(?P<expr>.+?)\s*%\}")
_ELIF = re.compile(r"\{%\s*elif\s+(?P<expr>.+?)\s*%\}")
_ELSE = re.compile(r"\{%\s*else\s*%\}")
_ENDIF = re.compile(r"\{%\s*endif\s*%\}")
_COMPOSE_ONLY_GATE = re.compile(
r"not\s+IS_SWARM_MODE|IS_COMPOSE_MODE"
)
_SWARM_ONLY_GATE = re.compile(
r"(?<!not )IS_SWARM_MODE|not\s+IS_COMPOSE_MODE"
)
_COMPOSE_ONLY_GATE = re.compile(r"not\s+IS_SWARM_MODE|IS_COMPOSE_MODE")
_SWARM_ONLY_GATE = re.compile(r"(?<!not )IS_SWARM_MODE|not\s+IS_COMPOSE_MODE")
def _frame_is_compose_only(expr: str, in_else: bool) -> bool:
@@ -31,12 +31,8 @@ _IF = re.compile(r"\{%\s*if\s+(?P<expr>.+?)\s*%\}")
_ELIF = re.compile(r"\{%\s*elif\s+(?P<expr>.+?)\s*%\}")
_ELSE = re.compile(r"\{%\s*else\s*%\}")
_ENDIF = re.compile(r"\{%\s*endif\s*%\}")
_COMPOSE_ONLY_GATE = re.compile(
r"not\s+IS_SWARM_MODE|IS_COMPOSE_MODE"
)
_SWARM_ONLY_GATE = re.compile(
r"(?<!not )IS_SWARM_MODE|not\s+IS_COMPOSE_MODE"
)
_COMPOSE_ONLY_GATE = re.compile(r"not\s+IS_SWARM_MODE|IS_COMPOSE_MODE")
_SWARM_ONLY_GATE = re.compile(r"(?<!not )IS_SWARM_MODE|not\s+IS_COMPOSE_MODE")
def _frame_is_compose_only(expr: str, in_else: bool) -> bool:
@@ -128,7 +128,7 @@ class TestNoOversizedAnsibleBlock(unittest.TestCase):
" when: not IS_SWARM_MODE\n"
" include_tasks: <NN>_<descriptive>.yml\n\n"
"If the sub-file is when-gated, mark it with the header\n"
' # include-gated: when: not IS_SWARM_MODE\n'
" # include-gated: when: not IS_SWARM_MODE\n"
"(see utils/annotations/task_gate.py) so the swarm-compat "
f"lints exempt it.\n\nOffenders:\n{formatted}"
)
@@ -71,7 +71,9 @@ class TestDeploymentModeBooleans(unittest.TestCase):
declared = read_text(str(PROJECT_ROOT / DEFINITION))
for name in ("IS_COMPOSE_MODE", "IS_SWARM_MODE"):
self.assertIn(f"{name}:", declared, f"{DEFINITION} no longer defines {name}")
self.assertIn(
f"{name}:", declared, f"{DEFINITION} no longer defines {name}"
)
if __name__ == "__main__":
@@ -1,8 +1,7 @@
from pathlib import Path
from utils.cache.files import iter_non_ignored_files
from tests.lint.repository import PROJECT_ROOT
from utils.cache.files import iter_non_ignored_files
INDEX_FILES = ("index.rst", "index.md", "README.md", "README.rst")
@@ -31,7 +30,8 @@ def markdown_files() -> list[Path]:
return [
path
for raw in iter_non_ignored_files(extensions=(".md",))
if not set(AGENT_STATE) & set((path := Path(raw)).relative_to(PROJECT_ROOT).parts)
if not set(AGENT_STATE)
& set((path := Path(raw)).relative_to(PROJECT_ROOT).parts)
]
@@ -16,14 +16,16 @@ from __future__ import annotations
import re
import unittest
from pathlib import Path
from typing import NamedTuple
from typing import TYPE_CHECKING, NamedTuple
from utils.annotations.suppress import is_suppressed_at
from utils.cache.files import read_text
from . import PROJECT_ROOT, index_page, markdown_files
if TYPE_CHECKING:
from pathlib import Path
_RULE = "markdown-code-span-linkable"
_FENCE = re.compile(r"^\s*(`{3,}|~{3,})")
@@ -12,13 +12,15 @@ from __future__ import annotations
import re
import unittest
from pathlib import Path
from typing import NamedTuple
from typing import TYPE_CHECKING, NamedTuple
from utils.cache.files import read_text
from . import INDEX_FILES, PROJECT_ROOT, index_page, markdown_files
if TYPE_CHECKING:
from pathlib import Path
_MD_LINK_RE = re.compile(r"!?\[[^\]]*\]\(([^)]+)\)")
_FENCE_RE = re.compile(r"^\s*(`{3,}|~{3,})")
+4 -6
View File
@@ -135,15 +135,13 @@ class TestI18nCatalogs(unittest.TestCase):
cls.findings = []
return
workers = min(len(tasks), os.cpu_count() or 1)
with ProcessPoolExecutor(max_workers=workers, initializer=_load_expected) as pool:
with ProcessPoolExecutor(
max_workers=workers, initializer=_load_expected
) as pool:
cls.findings = list(pool.map(inspect, tasks, chunksize=1))
def _all(self, attribute: str) -> list:
return [
entry
for found in self.findings
for entry in getattr(found, attribute)
]
return [entry for found in self.findings for entry in getattr(found, attribute)]
def test_every_language_has_a_core_catalog(self):
missing = sorted(
@@ -57,7 +57,9 @@ class TestDirectoryIndex(unittest.TestCase):
(self.src / "guide").mkdir()
(self.src / "guide" / "README.md").write_text("# Guide\n", encoding="utf-8")
(self.src / "manual").mkdir()
(self.src / "manual" / "index.rst").write_text("Manual\n======\n", encoding="utf-8")
(self.src / "manual" / "index.rst").write_text(
"Manual\n======\n", encoding="utf-8"
)
(self.src / "both").mkdir()
(self.src / "both" / "index.rst").write_text("Both\n====\n", encoding="utf-8")
(self.src / "both" / "README.md").write_text("# Both\n", encoding="utf-8")
@@ -52,7 +52,9 @@ class TestMermaidFences(unittest.TestCase):
self.assertNotIn("<y>", rendered)
def test_other_languages_stay_literal_blocks(self) -> None:
document = _transform(nodes.literal_block("echo hi", "echo hi", language="bash"))
document = _transform(
nodes.literal_block("echo hi", "echo hi", language="bash")
)
self.assertEqual(len(list(document.findall(nodes.raw))), 0)
self.assertEqual(len(list(document.findall(nodes.literal_block))), 1)
@@ -17,7 +17,9 @@ _TOOLING = str(PROJECT_ROOT / "roles" / "web-app-docs" / "files" / "python")
if _TOOLING not in sys.path:
sys.path.insert(0, _TOOLING)
untranslated_yaml = importlib.import_module("infinito_docs.extensions.untranslated.yaml")
untranslated_yaml = importlib.import_module(
"infinito_docs.extensions.untranslated.yaml"
)
def _document(source: str):
@@ -158,7 +158,8 @@ class TestBuilder(LibraryFixture, unittest.TestCase):
self.library.fetch()
self._drain()
site = self.library.translations / "latest" / "de" / "html" / "version.txt"
self.assertEqual(site.read_text(encoding="utf-8"), "first") # nocheck: cache-read
built = site.read_text(encoding="utf-8") # nocheck: cache-read
self.assertEqual(built, "first")
_commit(self.repo, "second")
self.library.fetch()
@@ -170,7 +171,8 @@ class TestBuilder(LibraryFixture, unittest.TestCase):
"a version rebuild must not leave its translated sites on the old commit",
)
self.assertEqual(self._site("latest", "version.txt"), "second")
self.assertEqual(site.read_text(encoding="utf-8"), "second") # nocheck: cache-read
rebuilt = site.read_text(encoding="utf-8") # nocheck: cache-read
self.assertEqual(rebuilt, "second")
def test_a_failing_language_does_not_mark_the_version_failed(self) -> None:
self._translated_repo("de")
@@ -179,9 +181,7 @@ class TestBuilder(LibraryFixture, unittest.TestCase):
self.library.build("latest")
self.assertEqual(self._state(self.library, "latest")["state"], "ready")
with patch.object(
builder.Builder, "_run", side_effect=OSError("sphinx died")
):
with patch.object(builder.Builder, "_run", side_effect=OSError("sphinx died")):
self.library.build_language("latest", "de")
self.assertEqual(
+3 -1
View File
@@ -28,7 +28,9 @@ class TestBuildTemplate(unittest.TestCase):
def test_a_message_without_a_word_never_enters_the_template(self) -> None:
template = build_template([("a", "`x`"), ("b", "Real prose.")], "core")
self.assertEqual([message.id for message in template if message.id], ["Real prose."])
self.assertEqual(
[message.id for message in template if message.id], ["Real prose."]
)
class TestMerge(unittest.TestCase):
+1 -3
View File
@@ -211,9 +211,7 @@ class TestWriterAndGateAgree(unittest.TestCase):
self.assertFalse(harms(label, label))
def test_a_sentence_that_comes_back_unchanged_is_a_failed_translation(self) -> None:
sentence = (
"Centralized database service shared across applications via Docker."
)
sentence = "Centralized database service shared across applications via Docker."
self.assertTrue(
harms(sentence, sentence),
@@ -106,10 +106,12 @@ class TestCommittingAs(unittest.TestCase):
self.assertEqual(committing_as(), ("Carried Name", "carried@example.com"))
def test_an_empty_carried_address_falls_through_to_git(self) -> None:
with mock.patch.dict("os.environ", {"INFINITO_GIT_AUTHOR_EMAIL": " "}):
with mock.patch("subprocess.run") as run:
run.return_value = mock.Mock(stdout="from-git\n")
self.assertEqual(committing_as(), ("from-git", "from-git"))
with (
mock.patch.dict("os.environ", {"INFINITO_GIT_AUTHOR_EMAIL": " "}),
mock.patch("subprocess.run") as run,
):
run.return_value = mock.Mock(stdout="from-git\n")
self.assertEqual(committing_as(), ("from-git", "from-git"))
if __name__ == "__main__":
+1 -3
View File
@@ -183,9 +183,7 @@ class LibreTranslate:
fail too, so the run stops instead of discarding the rest.
"""
results: list[str | None] = list(texts)
wordy = [
index for index, text in enumerate(texts) if not untranslatable(text)
]
wordy = [index for index, text in enumerate(texts) if not untranslatable(text)]
size = self.batch_size
batches = [wordy[i : i + size] for i in range(0, len(wordy), size)]
refused = damaged = 0
+4 -1
View File
@@ -2,7 +2,10 @@
from __future__ import annotations
from types import ModuleType
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from types import ModuleType
def public_names(module: ModuleType) -> list[str]:
-1
View File
@@ -29,7 +29,6 @@ if TYPE_CHECKING:
from typing import Any
def _enabled_services(variant: Mapping[str, Any]) -> int:
services = variant.get("services") or {}
return sum(