Skip to content

Commit 0377cd7

Browse files
Cycle 11: apply ruff --fix (import ordering, SIM117 nested-with)
Extending linting to all four packages (run-tests.sh previously only linted the wire package) surfaced a handful of style drift that had accumulated unchecked. Auto-fixes applied. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 9123a31 commit 0377cd7

3 files changed

Lines changed: 7 additions & 10 deletions

File tree

src/dqliteclient/cluster.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
from dqliteclient.protocol import DqliteProtocol
1616
from dqliteclient.retry import retry_with_backoff
1717

18-
1918
# Type alias for a redirect-target policy. Returns True if the address
2019
# should be accepted, False to reject with a ClusterError.
2120
RedirectPolicy = Callable[[str], bool]
@@ -67,9 +66,7 @@ def _check_redirect(self, address: str) -> None:
6766
if self._redirect_policy is None:
6867
return
6968
if not self._redirect_policy(address):
70-
raise ClusterError(
71-
f"Leader redirect to {address!r} rejected by redirect_policy"
72-
)
69+
raise ClusterError(f"Leader redirect to {address!r} rejected by redirect_policy")
7370

7471
async def find_leader(self) -> str:
7572
"""Find the current cluster leader.

src/dqliteclient/connection.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,7 @@ def is_connected(self) -> bool:
116116

117117
def __repr__(self) -> str:
118118
state = "connected" if self._protocol is not None else "disconnected"
119-
return (
120-
f"<DqliteConnection address={self._address!r} database={self._database!r} {state}>"
121-
)
119+
return f"<DqliteConnection address={self._address!r} database={self._database!r} {state}>"
122120

123121
@property
124122
def in_transaction(self) -> bool:

tests/test_redirect_policy.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,11 @@ def test_rejects_unknown_redirect(self) -> None:
3838
redirect_policy=allowlist_policy(["10.0.0.1:9001"]),
3939
)
4040
# A compromised peer redirects to an attacker-controlled host.
41-
with patch.object(cc, "_query_leader", new=AsyncMock(return_value="attacker.com:9001")):
42-
with pytest.raises(ClusterError, match="rejected"):
43-
asyncio.run(cc.find_leader())
41+
with (
42+
patch.object(cc, "_query_leader", new=AsyncMock(return_value="attacker.com:9001")),
43+
pytest.raises(ClusterError, match="rejected"),
44+
):
45+
asyncio.run(cc.find_leader())
4446

4547
def test_no_policy_means_any_redirect_accepted(self) -> None:
4648
"""Default (None) policy preserves legacy behavior."""

0 commit comments

Comments
 (0)