aboutsummaryrefslogtreecommitdiffstats
path: root/poc/spike3_node.py
diff options
context:
space:
mode:
authorChristophe Besson <cbesson@gmail.com>2026-09-19 14:24:13 +0200
committerChristophe Besson <cbesson@gmail.com>2026-09-19 14:24:13 +0200
commit86188385cbdae1ee90c1dca7a7b9db2edef1ecd4 (patch)
treecc01153f05e84ad6cd34556caecd3f4bc335d0bd /poc/spike3_node.py
parentd2495a2c4b89fbbfc18cefec83ae96cabdd745e2 (diff)
downloadmeshbay-86188385cbdae1ee90c1dca7a7b9db2edef1ecd4.tar.gz
style: ruff's own fixes, mechanically applied
`ruff check .` had gone unrun long enough to report 568 errors, which is the same as having no linter: the next real finding would have been invisible in the noise. This is the 521 it fixes by itself, in 173 files, and nothing else — the 98 it cannot fix are the next commit. What actually changed: import sorting (225), imports nobody used (87, none of them a re-export — no `__init__.py` is touched, which was the one way this could have broken an import elsewhere), `datetime.timezone.utc` to `datetime.UTC` (69) and `asyncio.TimeoutError` to `TimeoutError` (18), both plain aliases on the 3.12 this project requires, `Optional[X]` to `X | None` (24), and f-strings with nothing to interpolate (19). Checked rather than assumed: every module in the three packages still imports, and the suite is 2893 passed — the same count, test for test, as the merge before it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Diffstat (limited to 'poc/spike3_node.py')
-rw-r--r--poc/spike3_node.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/poc/spike3_node.py b/poc/spike3_node.py
index c0ddde0..0b6d694 100644
--- a/poc/spike3_node.py
+++ b/poc/spike3_node.py
@@ -12,12 +12,17 @@ Sequence:
8. Simulate token refresh
"""
-import asyncio, httpx, base64, json, os, time
+import asyncio
+import base64
+import json
+import time
from pathlib import Path
+
+import httpx
+import jwt
+from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey
from cryptography.hazmat.primitives.asymmetric.x25519 import X25519PrivateKey
-from cryptography.hazmat.primitives import serialization
-import jwt
HUB_URL = "http://meshbay.org"
STATE_FILE = Path("node_state.json") # persists keys and tokens between runs
@@ -52,7 +57,7 @@ def _load_or_generate_keys(state: dict) -> tuple:
sk_x = X25519PrivateKey.generate()
state["sk_ed25519_b64"] = _sk_to_b64(sk_ed)
state["sk_x25519_b64"] = _sk_to_b64(sk_x)
- print(f" Generated new keypair")
+ print(" Generated new keypair")
return sk_ed, sk_x
# ── Main ──────────────────────────────────────────────────────────────────────
@@ -101,7 +106,7 @@ async def main():
state["user_id"] = r.json()["user_id"]
print(f" {PASS} Registered — user_id={state['user_id'][:8]}...")
elif r.status_code == 409:
- print(f" Already registered (409) — continuing with existing account")
+ print(" Already registered (409) — continuing with existing account")
else:
raise RuntimeError(f"Register failed: {r.status_code} {r.text}")
@@ -149,7 +154,7 @@ async def main():
node_id = r.json()["node_id"]
state["node_id"] = node_id
print(f" {PASS} Node announced — node_id={node_id[:8]}...")
- print(f" endpoint_hint : None (STUN/UPnP discovery in Spike 4)")
+ print(" endpoint_hint : None (STUN/UPnP discovery in Spike 4)")
# ── Step 7: Retrieve node record ──────────────────────────────────────
print("\n[ 7 ] Retrieve node record from hub")