Skip to content

Commit 73495f8

Browse files
dbrattliclaude
andcommitted
Format test files with ruff
Apply ruff formatting to all test files as Stage 0 of the test linting enablement plan. This separates formatting changes from type annotation work for cleaner diffs and easier review. Changes: - 19 files reformatted (mainly removing unnecessary line breaks) - 167 files already formatted (no changes) - All tests still pass 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 917e11b commit 73495f8

19 files changed

+95
-123
lines changed

tests/test_observable/test_batch_4_7_fluent.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,7 @@ def test_last_or_default_with_default(self) -> None:
5858
"""Verify last_or_default returns default when empty."""
5959
source: Observable[int] = rx.empty()
6060

61-
fluent_result: Observable[int | None] = source.last_or_default(
62-
default_value=42
63-
)
61+
fluent_result: Observable[int | None] = source.last_or_default(default_value=42)
6462
pipe_result: Observable[int | None] = source.pipe(
6563
ops.last_or_default(default_value=42)
6664
)
@@ -199,7 +197,9 @@ def test_skip_last_with_time_equivalence(self) -> None:
199197

200198
# With immediate scheduler and duration=0, should take all
201199
fluent_result: Observable[int] = source.skip_last_with_time(0, scheduler)
202-
pipe_result: Observable[int] = source.pipe(ops.skip_last_with_time(0, scheduler))
200+
pipe_result: Observable[int] = source.pipe(
201+
ops.skip_last_with_time(0, scheduler)
202+
)
203203

204204
fluent_values: list[int] = []
205205
pipe_values: list[int] = []
@@ -220,7 +220,9 @@ def test_take_last_with_time_equivalence(self) -> None:
220220

221221
# With immediate scheduler and large duration, should take all
222222
fluent_result: Observable[int] = source.take_last_with_time(1000, scheduler)
223-
pipe_result: Observable[int] = source.pipe(ops.take_last_with_time(1000, scheduler))
223+
pipe_result: Observable[int] = source.pipe(
224+
ops.take_last_with_time(1000, scheduler)
225+
)
224226

225227
fluent_values: list[int] = []
226228
pipe_values: list[int] = []
@@ -241,7 +243,9 @@ def test_skip_until_with_time_equivalence(self) -> None:
241243

242244
# With immediate scheduler and start_time in the past, should take all
243245
fluent_result: Observable[int] = source.skip_until_with_time(0, scheduler)
244-
pipe_result: Observable[int] = source.pipe(ops.skip_until_with_time(0, scheduler))
246+
pipe_result: Observable[int] = source.pipe(
247+
ops.skip_until_with_time(0, scheduler)
248+
)
245249

246250
fluent_values: list[int] = []
247251
pipe_values: list[int] = []
@@ -262,7 +266,9 @@ def test_take_until_with_time_equivalence(self) -> None:
262266

263267
# With immediate scheduler, use end_time=0 to avoid WouldBlockException
264268
fluent_result: Observable[int] = source.take_until_with_time(0, scheduler)
265-
pipe_result: Observable[int] = source.pipe(ops.take_until_with_time(0, scheduler))
269+
pipe_result: Observable[int] = source.pipe(
270+
ops.take_until_with_time(0, scheduler)
271+
)
266272

267273
fluent_values: list[int] = []
268274
pipe_values: list[int] = []

tests/test_observable/test_buffer.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,6 @@ def closing_mapper():
268268

269269
def test_toggle_closing_with_empty_observable(self):
270270
with marbles_testing(timespan=1.0) as (start, cold, hot, exp):
271-
272271
lookup = {"a": [2, 3], "b": [5], "c": [7], "d": [8, 9]}
273272

274273
openings = hot("---a-------b------c---d-------|")
@@ -291,7 +290,6 @@ def closing_mapper(key):
291290

292291
def test_toggle_closing_with_only_first_item(self):
293292
with marbles_testing(timespan=1.0) as (start, cold, hot, exp):
294-
295293
lookup = {"a": [2, 3], "b": [5], "c": [7], "d": [8, 9]}
296294

297295
openings = hot("---a-------b------c---d-------|")
@@ -319,7 +317,6 @@ class TestException(Exception):
319317
ex = TestException("test exception")
320318

321319
with marbles_testing(timespan=1.0) as (start, cold, hot, exp):
322-
323320
lookup = {"a": [2, 3], "b": [5], "c": [7], "d": [8, 9]}
324321

325322
openings = hot("---a-------b------c---d-------|")
@@ -347,7 +344,6 @@ class TestException(Exception):
347344
ex = TestException("test exception")
348345

349346
with marbles_testing(timespan=1.0) as (start, cold, hot, exp):
350-
351347
lookup = {"a": [2, 3], "b": [5], "c": [7], "d": [8, 9]}
352348

353349
openings = hot("---a-------b-----#", error=ex)
@@ -375,7 +371,6 @@ class TestException(Exception):
375371
ex = TestException("test exception")
376372

377373
with marbles_testing(timespan=1.0) as (start, cold, hot, exp):
378-
379374
lookup = {"a": [2, 3], "b": [5], "c": [7], "d": [8, 9]}
380375

381376
openings = hot("---a-------b------c---d-------|")

tests/test_observable/test_combination_fluent.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,7 @@ def test_zip_with_iterable_equivalence(self) -> None:
141141
source: Observable[int] = rx.of(1, 2, 3)
142142
iterable: list[str] = ["a", "b", "c"]
143143

144-
fluent_result: Observable[tuple[int, str]] = source.zip_with_iterable(
145-
iterable
146-
)
144+
fluent_result: Observable[tuple[int, str]] = source.zip_with_iterable(iterable)
147145
pipe_result: Observable[tuple[int, str]] = source.pipe(
148146
ops.zip_with_iterable(iterable)
149147
)
@@ -206,7 +204,9 @@ def test_group_join_equivalence(self) -> None:
206204
fluent_count: list[int] = []
207205
pipe_count: list[int] = []
208206

209-
def subscribe_to_group(x: tuple[int, Observable[int]], count_list: list[int]) -> None:
207+
def subscribe_to_group(
208+
x: tuple[int, Observable[int]], count_list: list[int]
209+
) -> None:
210210
_value, group = x
211211
group_values: list[int] = []
212212
group.subscribe(on_next=group_values.append)

tests/test_observable/test_conditional_fluent.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,7 @@ def test_find_equivalence(self) -> None:
4646
"""Verify find fluent and functional styles are equivalent."""
4747
source: Observable[int] = rx.of(1, 2, 3, 4, 5)
4848

49-
fluent_result: Observable[int | None] = source.find(
50-
lambda x, i, obs: x > 3
51-
)
49+
fluent_result: Observable[int | None] = source.find(lambda x, i, obs: x > 3)
5250
pipe_result: Observable[int | None] = source.pipe(
5351
ops.find(lambda x, i, obs: x > 3)
5452
)
@@ -99,9 +97,7 @@ def test_find_index_not_found(self) -> None:
9997
"""Test find_index when element is not found."""
10098
source: Observable[int] = rx.of(1, 2, 3)
10199

102-
result: Observable[int | None] = source.find_index(
103-
lambda x, i, obs: x > 10
104-
)
100+
result: Observable[int | None] = source.find_index(lambda x, i, obs: x > 10)
105101

106102
values: list[int | None] = []
107103
result.subscribe(on_next=values.append)

tests/test_observable/test_connectableobservable.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
class MySubject(Observable, ObserverBase):
2020
def __init__(self):
21-
2221
super(MySubject, self).__init__()
2322

2423
self.dispose_on_map = {}

tests/test_observable/test_filtering_fluent.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -410,11 +410,10 @@ def test_complex_chain(self) -> None:
410410
source: Observable[int] = rx.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
411411

412412
result: Observable[int] = (
413-
source
414-
.filter(lambda x: x % 2 == 0) # [2, 4, 6, 8, 10]
415-
.map(lambda x: x * 2) # [4, 8, 12, 16, 20]
416-
.skip(1) # [8, 12, 16, 20]
417-
.take(3) # [8, 12, 16]
413+
source.filter(lambda x: x % 2 == 0) # [2, 4, 6, 8, 10]
414+
.map(lambda x: x * 2) # [4, 8, 12, 16, 20]
415+
.skip(1) # [8, 12, 16, 20]
416+
.take(3) # [8, 12, 16]
418417
)
419418

420419
values: list[int] = []
@@ -427,11 +426,10 @@ def test_complex_phase3_chain(self) -> None:
427426
source: Observable[int] = rx.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
428427

429428
result: Observable[bool] = (
430-
source
431-
.skip_last(2) # [1, 2, 3, 4, 5, 6, 7, 8]
432-
.take_last(6) # [3, 4, 5, 6, 7, 8]
433-
.filter(lambda x: x % 2 == 0) # [4, 6, 8]
434-
.all(lambda x: x > 3) # Check if all > 3
429+
source.skip_last(2) # [1, 2, 3, 4, 5, 6, 7, 8]
430+
.take_last(6) # [3, 4, 5, 6, 7, 8]
431+
.filter(lambda x: x % 2 == 0) # [4, 6, 8]
432+
.all(lambda x: x > 3) # Check if all > 3
435433
)
436434

437435
values: list[bool] = []

tests/test_observable/test_groupby.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,6 @@ def action1(scheduler, state):
372372

373373
def action2(scheduler, state):
374374
def next(group):
375-
376375
result = scheduler.create_observer()
377376
c["inners"][group.key] = group
378377
c["results"][group.key] = result

tests/test_observable/test_join.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,6 @@ def create():
924924
assert subscribe_schedulers["duration_y"] is scheduler
925925

926926
def test_join_op_forward_scheduler_None(self):
927-
928927
subscribe_schedulers = {
929928
"x": "unknown",
930929
"y": "unknown",

tests/test_observable/test_mathematical_fluent.py

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,7 @@ class Person(NamedTuple):
116116
)
117117

118118
fluent_result: Observable[list[Person]] = source.min_by(lambda x: x.age)
119-
pipe_result: Observable[list[Person]] = source.pipe(
120-
ops.min_by(lambda x: x.age)
121-
)
119+
pipe_result: Observable[list[Person]] = source.pipe(ops.min_by(lambda x: x.age))
122120

123121
fluent_values: list[list[Person]] = []
124122
pipe_values: list[list[Person]] = []
@@ -147,9 +145,7 @@ class Person(NamedTuple):
147145
)
148146

149147
fluent_result: Observable[list[Person]] = source.max_by(lambda x: x.age)
150-
pipe_result: Observable[list[Person]] = source.pipe(
151-
ops.max_by(lambda x: x.age)
152-
)
148+
pipe_result: Observable[list[Person]] = source.pipe(ops.max_by(lambda x: x.age))
153149

154150
fluent_values: list[list[Person]] = []
155151
pipe_values: list[list[Person]] = []
@@ -171,13 +167,12 @@ def test_filter_with_average(self) -> None:
171167
source: Observable[int] = rx.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
172168

173169
result: Observable[float] = (
174-
source
175-
.filter(lambda x: x % 2 == 0) # [2, 4, 6, 8, 10]
176-
.take_while(lambda x: x < 9) # [2, 4, 6, 8]
177-
.map(lambda x: x * 2) # [4, 8, 12, 16]
178-
.distinct_until_changed() # [4, 8, 12, 16]
179-
.start_with(0) # [0, 4, 8, 12, 16]
180-
.average() # [8.0]
170+
source.filter(lambda x: x % 2 == 0) # [2, 4, 6, 8, 10]
171+
.take_while(lambda x: x < 9) # [2, 4, 6, 8]
172+
.map(lambda x: x * 2) # [4, 8, 12, 16]
173+
.distinct_until_changed() # [4, 8, 12, 16]
174+
.start_with(0) # [0, 4, 8, 12, 16]
175+
.average() # [8.0]
181176
)
182177

183178
values: list[float] = []

tests/test_observable/test_method_chaining.py

Lines changed: 33 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,10 @@ def test_complex_chain(self) -> None:
3333
source: Observable[int] = rx.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
3434

3535
result: Observable[int] = (
36-
source
37-
.filter(lambda x: x % 2 == 0) # [2, 4, 6, 8, 10]
38-
.map(lambda x: x * 2) # [4, 8, 12, 16, 20]
39-
.skip(1) # [8, 12, 16, 20]
40-
.take(3) # [8, 12, 16]
36+
source.filter(lambda x: x % 2 == 0) # [2, 4, 6, 8, 10]
37+
.map(lambda x: x * 2) # [4, 8, 12, 16, 20]
38+
.skip(1) # [8, 12, 16, 20]
39+
.take(3) # [8, 12, 16]
4140
)
4241

4342
values: list[int] = []
@@ -50,8 +49,7 @@ def test_chain_with_reduce(self) -> None:
5049
source: Observable[int] = rx.of(1, 2, 3, 4, 5)
5150

5251
result: Observable[int] = (
53-
source
54-
.filter(lambda x: x > 2)
52+
source.filter(lambda x: x > 2)
5553
.map(lambda x: x * 2)
5654
.reduce(lambda acc, x: acc + x, 0)
5755
)
@@ -66,13 +64,9 @@ def test_mixed_fluent_and_pipe(self) -> None:
6664
source: Observable[int] = rx.of(1, 2, 3, 4, 5)
6765

6866
# Start with fluent, then use pipe
69-
result: Observable[int] = (
70-
source
71-
.map(lambda x: x * 2)
72-
.pipe(
73-
ops.filter(lambda x: x > 5),
74-
ops.take(2),
75-
)
67+
result: Observable[int] = source.map(lambda x: x * 2).pipe(
68+
ops.filter(lambda x: x > 5),
69+
ops.take(2),
7670
)
7771

7872
values: list[int] = []
@@ -89,13 +83,12 @@ def test_transformation_filtering_mathematical(self) -> None:
8983
source: Observable[int] = rx.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
9084

9185
result: Observable[float] = (
92-
source
93-
.filter(lambda x: x % 2 == 0) # FilteringMixin: [2, 4, 6, 8, 10]
94-
.take_while(lambda x: x < 9) # FilteringMixin: [2, 4, 6, 8]
95-
.map(lambda x: x * 2) # TransformationMixin: [4, 8, 12, 16]
96-
.distinct_until_changed() # FilteringMixin: [4, 8, 12, 16]
97-
.start_with(0) # CombinationMixin: [0, 4, 8, 12, 16]
98-
.average() # MathematicalMixin: [8.0]
86+
source.filter(lambda x: x % 2 == 0) # FilteringMixin: [2, 4, 6, 8, 10]
87+
.take_while(lambda x: x < 9) # FilteringMixin: [2, 4, 6, 8]
88+
.map(lambda x: x * 2) # TransformationMixin: [4, 8, 12, 16]
89+
.distinct_until_changed() # FilteringMixin: [4, 8, 12, 16]
90+
.start_with(0) # CombinationMixin: [0, 4, 8, 12, 16]
91+
.average() # MathematicalMixin: [8.0]
9992
)
10093

10194
values: list[float] = []
@@ -108,11 +101,10 @@ def test_filtering_testing_chain(self) -> None:
108101
source: Observable[int] = rx.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
109102

110103
result: Observable[bool] = (
111-
source
112-
.skip_last(2) # FilteringMixin: [1, 2, 3, 4, 5, 6, 7, 8]
113-
.take_last(6) # FilteringMixin: [3, 4, 5, 6, 7, 8]
114-
.filter(lambda x: x % 2 == 0) # FilteringMixin: [4, 6, 8]
115-
.all(lambda x: x > 3) # TestingMixin: Check if all > 3
104+
source.skip_last(2) # FilteringMixin: [1, 2, 3, 4, 5, 6, 7, 8]
105+
.take_last(6) # FilteringMixin: [3, 4, 5, 6, 7, 8]
106+
.filter(lambda x: x % 2 == 0) # FilteringMixin: [4, 6, 8]
107+
.all(lambda x: x > 3) # TestingMixin: Check if all > 3
116108
)
117109

118110
values: list[bool] = []
@@ -131,12 +123,11 @@ def cleanup_action() -> None:
131123
action_called = True
132124

133125
result: Observable[list[int]] = (
134-
source
135-
.do_action(side_effects.append) # UtilityMixin
136-
.filter(lambda x: x > 2) # FilteringMixin
137-
.map(lambda x: x * 2) # TransformationMixin
138-
.to_list() # UtilityMixin
139-
.finally_action(cleanup_action) # UtilityMixin
126+
source.do_action(side_effects.append) # UtilityMixin
127+
.filter(lambda x: x > 2) # FilteringMixin
128+
.map(lambda x: x * 2) # TransformationMixin
129+
.to_list() # UtilityMixin
130+
.finally_action(cleanup_action) # UtilityMixin
140131
)
141132

142133
values: list[list[int]] = []
@@ -152,10 +143,9 @@ def test_combination_error_handling(self) -> None:
152143
fallback: Observable[int] = rx.of(1, 2, 3)
153144

154145
result: Observable[int] = (
155-
source
156-
.catch(fallback) # ErrorHandlingMixin
157-
.start_with(0) # CombinationMixin
158-
.take(3) # FilteringMixin
146+
source.catch(fallback) # ErrorHandlingMixin
147+
.start_with(0) # CombinationMixin
148+
.take(3) # FilteringMixin
159149
)
160150

161151
values: list[int] = []
@@ -170,11 +160,11 @@ def test_windowing_transformation_testing(self) -> None:
170160
# Test partition followed by operations on one partition
171161
evens, _odds = source.partition(lambda x: x % 2 == 0)
172162

173-
result: Observable[bool] = (
174-
evens
175-
.map(lambda x: x * 2) # TransformationMixin: [4, 8, 12]
176-
.all(lambda x: x % 4 == 0) # TestingMixin: Check divisible by 4
177-
)
163+
result: Observable[bool] = evens.map(
164+
lambda x: x * 2
165+
).all( # TransformationMixin: [4, 8, 12]
166+
lambda x: x % 4 == 0
167+
) # TestingMixin: Check divisible by 4
178168

179169
values: list[bool] = []
180170
result.subscribe(on_next=values.append)
@@ -190,8 +180,7 @@ def test_pipe_then_fluent(self) -> None:
190180
source: Observable[int] = rx.of(1, 2, 3, 4, 5)
191181

192182
result: Observable[int] = (
193-
source
194-
.pipe(
183+
source.pipe(
195184
ops.filter(lambda x: x > 2),
196185
ops.map(lambda x: x * 2),
197186
)
@@ -209,8 +198,7 @@ def test_fluent_then_pipe_then_fluent(self) -> None:
209198
source: Observable[int] = rx.of(1, 2, 3, 4, 5, 6, 7, 8)
210199

211200
result: Observable[int] = (
212-
source
213-
.filter(lambda x: x > 2)
201+
source.filter(lambda x: x > 2)
214202
.pipe(
215203
ops.map(lambda x: x * 2),
216204
ops.take(3),

0 commit comments

Comments
 (0)