From 76ee519b93fb4f4317eb0a9ebac3927d858a0515 Mon Sep 17 00:00:00 2001 From: Jack McCarthy <37917934+Deicyde@users.noreply.github.com> Date: Mon, 5 Oct 2026 17:45:00 -0400 Subject: [PATCH] Say that acquire raises on a malformed lease The docstring listed malformed leases as acquirable, but _read_lease raises MalformedLeaseError before steal is consulted, as the README's claim contract says. The test now covers steal=True too. --- autoform_cli/claims.py | 5 ++++- tests/test_claims.py | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/autoform_cli/claims.py b/autoform_cli/claims.py index ecc0bf7d..bc60a969 100644 --- a/autoform_cli/claims.py +++ b/autoform_cli/claims.py @@ -390,7 +390,10 @@ def expired(cls, lease: Mapping[str, Any], now: float | None = None) -> bool: return expires_at <= comparison_time def acquire(self, key: str, ttl: int | float = CLAIM_TTL_S, steal: bool = False, note: str = "") -> bool: - """CAS-acquire a free, expired, malformed, owned, or explicitly stolen lease.""" + """CAS-acquire a free, expired, owned, or explicitly stolen lease. + + A malformed lease raises ``MalformedLeaseError``, even with ``steal``. + """ key = _validate_key(key) _validate_ttl(ttl) self._ensure_scratch() diff --git a/tests/test_claims.py b/tests/test_claims.py index 43eddfcf..cda1ad8c 100644 --- a/tests/test_claims.py +++ b/tests/test_claims.py @@ -255,6 +255,7 @@ def test_malformed_lease_is_unverifiable_and_not_takeover_eligible(tmp_path: Pat lambda: board.renew("malformed"), lambda: board.release("malformed"), lambda: board.acquire("malformed", ttl=600), + lambda: board.acquire("malformed", ttl=600, steal=True), ): with pytest.raises(claims.MalformedLeaseError): operation()