mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-28 13:57:43 +00:00
style(lint): state zip's strictness in the subnet regex
`ruff`'s B905 wants every `zip()` to say whether it tolerates operands of different length. Here it never sees one: both operands are the `packed` form of an address from the same network, so both are four bytes for IPv4 and sixteen for IPv6. `strict=True` states that, and turns a silently truncated - and therefore too permissive - regex into an error should the invariant ever break. The three other files carry `ruff format` reflows the same run produced. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
8215b64648
commit
4d79f7c19f
4 files changed
+13
-4
No files matched your search
@@ -52,7 +52,9 @@ class LookupModule(LookupBase):
|
||||
"subnet_address_regex lookup: application_id is required in variables"
|
||||
)
|
||||
|
||||
config_lookup = lookup_loader.get("config", loader=self._loader, templar=templar)
|
||||
config_lookup = lookup_loader.get(
|
||||
"config", loader=self._loader, templar=templar
|
||||
)
|
||||
subnet = config_lookup.run(
|
||||
[str(application_id), "networks.local.subnet"], variables=vars_
|
||||
)[0]
|
||||
|
||||
@@ -49,7 +49,9 @@ class LookupModule(LookupBase):
|
||||
"subnet_gateway lookup: application_id is required in variables"
|
||||
)
|
||||
|
||||
config_lookup = lookup_loader.get("config", loader=self._loader, templar=templar)
|
||||
config_lookup = lookup_loader.get(
|
||||
"config", loader=self._loader, templar=templar
|
||||
)
|
||||
subnet = config_lookup.run(
|
||||
[str(application_id), "networks.local.subnet"], variables=vars_
|
||||
)[0]
|
||||
|
||||
@@ -7,7 +7,9 @@ import unittest
|
||||
|
||||
from utils.cache.files import PROJECT_ROOT, read_text
|
||||
|
||||
DRILL = PROJECT_ROOT / "scripts" / "tests" / "deploy" / "swarm" / "routine" / "00_one.sh"
|
||||
DRILL = (
|
||||
PROJECT_ROOT / "scripts" / "tests" / "deploy" / "swarm" / "routine" / "00_one.sh"
|
||||
)
|
||||
GATE = PROJECT_ROOT / "scripts" / "tests" / "deploy" / "roundtrip.sh"
|
||||
MARKER = "==> swarm drill complete: app="
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ from __future__ import annotations
|
||||
|
||||
import ipaddress
|
||||
|
||||
|
||||
def _octet_pattern(low: int, high: int) -> str:
|
||||
if low == high:
|
||||
return str(low)
|
||||
@@ -39,7 +40,9 @@ def subnet_address_regex(subnet: str) -> str:
|
||||
return r"\.".join(
|
||||
_octet_pattern(low, high)
|
||||
for low, high in zip(
|
||||
network.network_address.packed, network.broadcast_address.packed
|
||||
network.network_address.packed,
|
||||
network.broadcast_address.packed,
|
||||
strict=True,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
Reference in new issue
Block a user