diff --git a/agents.md b/agents.md index e61c34ad8..55339b3e8 100644 --- a/agents.md +++ b/agents.md @@ -8,7 +8,7 @@ In a checkout the CLI starts the daemon with `gleam run` (entry: `src/albedo.gle The package manager is gleam. Please when you want to add a package, which is never unless told to, do `gleam add ...` (dev deps: `gleam add --dev ...`), please do not try to edit `manifest.toml` yourself. Gleam generates it. -PLEASE USE `gleam check` to type check and `gleam format src test` to format Gleam. Python is formatted with `ruff format priv/python test`, linted with `ruff check`, and type-checked with `ty check`. Both checks cover `priv/python` and all Python files in `test`, including manual tools; settings live in `pyproject.toml`. `nix develop` puts Ruff and ty on PATH. Outside it, use `uvx ruff@0.15.14 check` and `uvx ty@0.0.84 check`, matching the pre-commit pins. `pre-commit run --all-files` formats Gleam and Python, checks Python lint, and runs ty across the project. The commit hook formats staged files and runs both Python checks. `nix fmt` also applies Ruff lint fixes. +PLEASE USE `gleam check` to type check and `gleam format src test` to format Gleam. Python is formatted with `ruff format priv/python test`, linted with `ruff check`, and type-checked with `ty check`. Both checks cover `priv/python` and all Python files in `test`, including manual tools; settings live in `pyproject.toml`. Ruff, ty, and Pyright target Python 3.11. The Nix development shell and packaged daemon use Python 3.11. `nix develop` puts Ruff and ty on PATH. Outside it, use `uvx ruff@0.15.14 check` and `uvx ty@0.0.84 check`, matching the pre-commit pins. `pre-commit run --all-files` formats Gleam and Python, checks Python lint, and runs ty across the project. The commit hook formats staged files and runs both Python checks. `nix fmt` also applies Ruff lint fixes. For Go changes, run gopls with `staticcheck` and all available analyses enabled, alongside vet and tests. Fix diagnostics by simplifying the code, without adding wrappers or obscuring control flow. diff --git a/default.nix b/default.nix index 2152ceb9f..62c374ead 100644 --- a/default.nix +++ b/default.nix @@ -6,7 +6,7 @@ fetchurl, gleam, beamPackages, - python3, + python311, bash, coreutils, makeWrapper, @@ -132,7 +132,7 @@ ln -s ${usageCore}/bin/usage $out/lib/albedo/albedo/priv/bin/usage makeWrapper $out/lib/albedo/entrypoint.sh $out/bin/albedo-daemon \ --add-flags run \ - --prefix PATH : ${lib.makeBinPath [erlang python3 bash coreutils render]} + --prefix PATH : ${lib.makeBinPath [erlang python311 bash coreutils render]} runHook postInstall ''; }; @@ -144,7 +144,7 @@ in modRoot = "cli"; subPackages = ["cmd/albedo"]; vendorHash = "sha256-RXAAUgTw2JR25IBswfBbxzJXk0Q+zIvW0jxtfeQTI1U="; - nativeBuildInputs = [makeWrapper python3]; + nativeBuildInputs = [makeWrapper python311]; ALBEDO_NO_BROWSER = "1"; postInstall = '' wrapProgram $out/bin/albedo \ diff --git a/flake/devShells.nix b/flake/devShells.nix index 0987ba5d4..01b79df0f 100644 --- a/flake/devShells.nix +++ b/flake/devShells.nix @@ -13,7 +13,7 @@ _: { gleam beamPackages.erlang (beamPackages.rebar3WithPlugins {plugins = [beamPackages.pc];}) - python3 + python311 pre-commit ruff ty diff --git a/pyproject.toml b/pyproject.toml index 2f7b012fc..c7d369eeb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,12 +1,12 @@ [tool.ruff] -target-version = "py314" +target-version = "py311" include = ["priv/python/**/*.py", "test/**/*.py", "pyproject.toml"] [tool.ruff.lint] select = ["E4", "E7", "E9", "F"] [tool.ty.environment] -python-version = "3.14" +python-version = "3.11" extra-paths = ["priv/python", "test", "test/harness", "test/e2e"] [tool.ty.src] diff --git a/robot-docs/extensions.md b/robot-docs/extensions.md index 62e7a73c5..21b820517 100644 --- a/robot-docs/extensions.md +++ b/robot-docs/extensions.md @@ -169,7 +169,7 @@ the target resolves per call from a `host=` argument, then `remote.configure(hos } ``` -the kernel bundle supports Python 3.11 and newer; remote boot uses `python3` unless the `python` setting selects another executable. the bundle-wide syntax check uses the minimum version in `pyrightconfig.json`, and `priv/python/ruff.toml` keeps formatting compatible with it. +the kernel bundle supports Python 3.11 and newer; remote boot uses `python3` unless the `python` setting selects another executable. the bundle-wide syntax check uses the minimum version in `pyrightconfig.json`. Ruff, ty, the Nix development shell, and the packaged runtime also target Python 3.11. a bare host asks the remote for its `pwd` once. if the host is reachable but its kernel cannot boot (no python, staging failed, bad handshake), `connect()` still returns and prints a warning: the connection is degraded to SSH command mode, where only `rem.run(program, *args, cwd=, env=, stdin=, timeout=300)`, `rem.shell(command, cwd=, env=, stdin=, timeout=300)`, `rem.read(path)`, `rem.write(path, content)`, and `rem.show_image(path_or_bytes)` answer and everything else raises. here `stdin` accepts only text or bytes, not a file or another job, and `.pipe()` is unavailable. The connect warning shows the degraded-only escape hatch `rem.shell('git log --oneline | rg fix')`, which invokes `bash -c` on the host for pipes or other shell syntax. `rem.shell()` does not exist in kernel mode. Neither the quoted-argv `rem.run()` fallback nor `rem.shell()` can offer process-group supervision, so stopping or timing out an ssh client does not prove the remote program stopped. an unreachable host fails `connect()`. connections are scoped: a lost SSH channel invalidates the connection rather than silently reconnecting, and `await rem.close()` ends it. connections run under `BatchMode=yes`, so key-based auth is required. diff --git a/test/e2e/daemon_test.py b/test/e2e/daemon_test.py index 4dc51dc5d..9a0a8c93c 100644 --- a/test/e2e/daemon_test.py +++ b/test/e2e/daemon_test.py @@ -190,7 +190,7 @@ class DaemonTest(unittest.TestCase): payload = None if body is None else json.dumps(body) connection.request(method, path, payload, headers) connection.getresponse().read() - except http.client.HTTPException, OSError: + except (http.client.HTTPException, OSError): if connection: connection.close() connection = None diff --git a/test/e2e/harness.py b/test/e2e/harness.py index 2a03d1699..34efc5881 100644 --- a/test/e2e/harness.py +++ b/test/e2e/harness.py @@ -390,7 +390,7 @@ class Provider: if reply.usage is not None: completed["usage"] = reply.usage emit({"type": "response.completed", "response": completed}) - except BrokenPipeError, ConnectionResetError: + except (BrokenPipeError, ConnectionResetError): pass def close(self): @@ -451,7 +451,7 @@ class _Response(http.client.HTTPResponse): else: try: self.read() - except OSError, http.client.HTTPException: + except (OSError, http.client.HTTPException): connection.reusable = False super().close() if connection is not None: @@ -553,7 +553,7 @@ class Daemon: def _stop(self, timeout): try: self.api("/shutdown", {}).close() - except OSError, http.client.HTTPException: + except (OSError, http.client.HTTPException): pass deadline = time.monotonic() + timeout while _alive(self._pid): diff --git a/test/e2e/run.py b/test/e2e/run.py index 337927252..fb51b22df 100644 --- a/test/e2e/run.py +++ b/test/e2e/run.py @@ -80,7 +80,7 @@ def execute_alone(test): def run_suite(suite, jobs, exclusive_jobs): try: durations = json.loads(DURATIONS.read_text()) - except OSError, ValueError: + except (OSError, ValueError): durations = {} selected = sorted(cases(suite), key=lambda test: -durations.get(test.id(), 0)) exclusive = [test for test in selected if marked(test, "_e2e_exclusive")] diff --git a/test/manual/attached_benchmark.py b/test/manual/attached_benchmark.py index ef3d35236..4b8686afa 100644 --- a/test/manual/attached_benchmark.py +++ b/test/manual/attached_benchmark.py @@ -173,7 +173,7 @@ def run(output, prompt, timeout): for key, _ in selector.select(max(0, next_sample - time.monotonic())): try: chunk = os.read(key.fd, 65536) - except BlockingIOError, OSError: + except (BlockingIOError, OSError): chunk = b"" if chunk: terminal.write(chunk) diff --git a/test/manual/go_port_smoke.py b/test/manual/go_port_smoke.py index 903185e9e..8e95cc67d 100755 --- a/test/manual/go_port_smoke.py +++ b/test/manual/go_port_smoke.py @@ -304,7 +304,7 @@ class StrictMockDaemon: while not parent.stop_stream.wait(0.2): self.wfile.write(b": keepalive\n\n") self.wfile.flush() - except BrokenPipeError, ConnectionResetError: + except (BrokenPipeError, ConnectionResetError): pass return @@ -454,7 +454,7 @@ def run_pty_scenario(binary, home_dir, args, rows, cols, duration=2.5, input_key data = os.read(key.fd, 4096) if data: raw_output.extend(data) - except BlockingIOError, OSError: + except (BlockingIOError, OSError): pass elapsed = time.monotonic() - started @@ -481,7 +481,7 @@ def run_pty_scenario(binary, home_dir, args, rows, cols, duration=2.5, input_key if not data: break raw_output.extend(data) - except BlockingIOError, OSError: + except (BlockingIOError, OSError): break finally: if child.poll() is None: @@ -826,7 +826,7 @@ def test_sse_retention_and_memory(binary, out_dir): data = os.read(key.fd, 8192) if data: raw_output.extend(data) - except BlockingIOError, OSError: + except (BlockingIOError, OSError): pass try: @@ -863,7 +863,7 @@ def test_sse_retention_and_memory(binary, out_dir): if not data: break raw_output.extend(data) - except BlockingIOError, OSError: + except (BlockingIOError, OSError): break finally: if child.poll() is None: