Skip to content

Commit d01e84b

Browse files
committed
chore: format
1 parent ded6147 commit d01e84b

File tree

7 files changed

+35
-37
lines changed

7 files changed

+35
-37
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/astral-sh/ruff-pre-commit
3-
rev: v0.8.4
3+
rev: v0.14.13
44
hooks:
55
- id: ruff-format
66
files: ^(sse_starlette|tests)/

Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,18 +107,18 @@ QUALITY: ## ############################################################
107107

108108
.PHONY: format
109109
format: ## perform ruff formatting
110-
@ruff format $(pkg_src) $(tests_src)
110+
@pre-commit run ruff-format --all-files
111111

112-
.PHONY: format-check
113-
format-check: ## perform black formatting
114-
@ruff format --check $(pkg_src) $(tests_src)
112+
# .PHONY: format-check
113+
# format-check: ## check ruff formatting
114+
# @ruff format --check $(pkg_src) $(tests_src)
115115

116116
.PHONY: style
117117
style: format ## perform code style format
118118

119119
.PHONY: lint
120120
lint: ## check style with ruff
121-
ruff check $(pkg_src) $(tests_src)
121+
ruff check --fix $(pkg_src) $(tests_src)
122122

123123
.PHONY: mypy
124124
mypy: ## check type hint annotations

tests/experimentation/test_multiple_consumers_asyncio.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,9 @@ async def test_sse_multiple_consumers(
197197

198198
# Verify expectations
199199
for i, client in enumerate(clients):
200-
assert (
201-
client.received_lines == expected_lines
202-
), f"Client {i} received {client.received_lines} lines, expected {expected_lines}"
200+
assert client.received_lines == expected_lines, (
201+
f"Client {i} received {client.received_lines} lines, expected {expected_lines}"
202+
)
203203

204204
assert not errors, f"Consumers encountered errors: {errors}"
205205

tests/experimentation/test_multiple_consumers_threads.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,7 @@ async def make_arequest(url, expected_lines=2):
115115
except httpcore.RemoteProtocolError as e:
116116
_log.error(e)
117117
finally:
118-
assert (
119-
i == expected_lines
120-
), (
118+
assert i == expected_lines, (
121119
f"Expected {expected_lines} lines"
122120
) # not part of test runner, failure is not reported
123121

@@ -128,9 +126,7 @@ async def make_arequest(url, expected_lines=2):
128126
# i=0, line='data: 1'
129127
# i=1, line=''
130128
# ...
131-
assert (
132-
i == expected_lines
133-
), (
129+
assert i == expected_lines, (
134130
f"Expected {expected_lines} lines"
135131
) # not part of test runner, failure is not reported
136132

tests/integration/test_multiple_consumers.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ async def test_sse_server_termination(caplog, app_path, expected_lines):
8585

8686
# Check error count: one connection error per client
8787
error_count = sum(1 for _, error in results if error is not None)
88-
assert (
89-
error_count == N_CONSUMERS
90-
), f"Expected {N_CONSUMERS} errors, got {error_count}"
88+
assert error_count == N_CONSUMERS, (
89+
f"Expected {N_CONSUMERS} errors, got {error_count}"
90+
)
9191

9292
# Verify error messages
9393
for _, error in results:
@@ -102,9 +102,9 @@ async def test_sse_server_termination(caplog, app_path, expected_lines):
102102
_log.info(f"Message counts received: {message_counts}")
103103

104104
# Since we're killing the server early, we expect incomplete message counts
105-
assert all(
106-
count < expected_lines for count in message_counts
107-
), f"Expected all counts to be less than {expected_lines}, got {message_counts}"
105+
assert all(count < expected_lines for count in message_counts), (
106+
f"Expected all counts to be less than {expected_lines}, got {message_counts}"
107+
)
108108

109109
finally:
110110
# Cleanup container if it's still around

tests/test_issue152.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,9 @@ async def tracking_watcher():
124124

125125
await asyncio.sleep(0.1)
126126

127-
assert (
128-
len(watcher_starts) == 1
129-
), f"Rapid calls spawned {len(watcher_starts)} watchers, expected 1"
127+
assert len(watcher_starts) == 1, (
128+
f"Rapid calls spawned {len(watcher_starts)} watchers, expected 1"
129+
)
130130
finally:
131131
sse_module._shutdown_watcher = original_watcher
132132

tests/test_multi_loop.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ async def get_state():
8484

8585
assert not errors, f"Errors occurred: {errors}"
8686
assert len(states) == 3
87-
assert (
88-
len(set(id(s) for s in states)) == 3
89-
), "States should be unique per thread"
87+
assert len(set(id(s) for s in states)) == 3, (
88+
"States should be unique per thread"
89+
)
9090

9191

9292
class TestIssue149HandleExitSignaling:
@@ -162,9 +162,9 @@ async def wait_for_exit(task_id: int):
162162
except asyncio.CancelledError:
163163
pass
164164

165-
assert (
166-
len(exited) == num_tasks
167-
), f"Only {len(exited)}/{num_tasks} tasks woke up."
165+
assert len(exited) == num_tasks, (
166+
f"Only {len(exited)}/{num_tasks} tasks woke up."
167+
)
168168

169169
@pytest.mark.asyncio
170170
async def test_manual_shutdown_ignores_signal(self):
@@ -184,14 +184,14 @@ async def wait_for_exit():
184184
AppStatus.original_handler = None
185185
AppStatus.handle_exit()
186186
await asyncio.sleep(1.0)
187-
assert (
188-
not task_exited.is_set()
189-
), "Task woke up despite automatic signaling being disabled."
187+
assert not task_exited.is_set(), (
188+
"Task woke up despite automatic signaling being disabled."
189+
)
190190
AppStatus.should_exit = True # Manually signal shutdown
191191
await asyncio.wait([task], timeout=1.0)
192-
assert (
193-
task_exited.is_set()
194-
), "Task did not wake up after manual shutdown signal."
192+
assert task_exited.is_set(), (
193+
"Task did not wake up after manual shutdown signal."
194+
)
195195
finally:
196196
AppStatus.enable_automatic_graceful_drain = original_drain
197197
AppStatus.original_handler = original_handler
@@ -258,7 +258,9 @@ async def wait_for_exit():
258258
# If the uvicorn check weren't bypassed, task would wake up
259259
await asyncio.sleep(1.0)
260260

261-
assert not task_exited.is_set(), "Task woke up from uvicorn.should_exit despite auto-drain being disabled."
261+
assert not task_exited.is_set(), (
262+
"Task woke up from uvicorn.should_exit despite auto-drain being disabled."
263+
)
262264

263265
# Now manually signal shutdown
264266
AppStatus.should_exit = True

0 commit comments

Comments
 (0)