Skip to content

Commit 349a26f

Browse files
committed
fix all ruff lints
Signed-off-by: Sreekanth <prsreekanth920@gmail.com>
1 parent 8912b10 commit 349a26f

40 files changed

Lines changed: 177 additions & 218 deletions

packages/pynumaflow-lite/manifests/accumulator/accumulator_stream_sorter.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
import asyncio
99
import signal
10+
from collections.abc import AsyncIterator
1011
from datetime import datetime
11-
from typing import AsyncIterator
1212

1313
from pynumaflow_lite.accumulator import (
1414
Accumulator,
@@ -107,7 +107,6 @@ async def main():
107107
"""
108108
Start the accumulator server.
109109
"""
110-
import signal
111110

112111
server = AccumulatorAsyncServer()
113112

@@ -124,10 +123,7 @@ async def main():
124123
await server.start(StreamSorter)
125124
print("Shutting down gracefully...")
126125
except asyncio.CancelledError:
127-
try:
128-
server.stop()
129-
except Exception:
130-
pass
126+
server.stop()
131127
return
132128

133129
if __name__ == "__main__":

packages/pynumaflow-lite/manifests/batchmap/batchmap_cat.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import asyncio
22
import signal
3-
from collections.abc import AsyncIterable
4-
from typing import Awaitable, Callable
3+
from collections.abc import AsyncIterable, Awaitable, Callable
54

65
from pynumaflow_lite import batchmapper
76
from pynumaflow_lite.batchmapper import Message
@@ -41,10 +40,7 @@ async def start(
4140
await server.start(f)
4241
print("Shutting down gracefully...")
4342
except asyncio.CancelledError:
44-
try:
45-
server.stop()
46-
except Exception:
47-
pass
43+
server.stop()
4844
return
4945

5046

packages/pynumaflow-lite/manifests/map/map_cat.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import asyncio
22
import signal
3-
from typing import Awaitable, Callable
3+
from collections.abc import Awaitable, Callable
44

55
from pynumaflow_lite import mapper
66

@@ -38,10 +38,7 @@ async def start(f: Callable[[list[str], mapper.Datum], Awaitable[mapper.Messages
3838
print("Shutting down gracefully...")
3939
except asyncio.CancelledError:
4040
# Fallback in case the task was cancelled by the runner
41-
try:
42-
server.stop()
43-
except Exception:
44-
pass
41+
server.stop()
4542
return
4643

4744

packages/pynumaflow-lite/manifests/mapstream/mapstream_cat.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import asyncio
22
import signal
3-
from collections.abc import AsyncIterator
4-
from typing import Callable
3+
from collections.abc import AsyncIterator, Callable
54

65
from pynumaflow_lite import mapstreamer
76
from pynumaflow_lite.mapstreamer import Message
@@ -34,10 +33,7 @@ async def start(f: Callable[[list[str], mapstreamer.Datum], AsyncIterator[Messag
3433
await server.start(f)
3534
print("Shutting down gracefully...")
3635
except asyncio.CancelledError:
37-
try:
38-
server.stop()
39-
except Exception:
40-
pass
36+
server.stop()
4137
return
4238

4339

packages/pynumaflow-lite/manifests/reduce/reduce_counter_class.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,7 @@ async def start(creator: type[reducer.Reducer], init_args: tuple):
4242
await server.start(creator, init_args)
4343
print("Shutting down gracefully...")
4444
except asyncio.CancelledError:
45-
try:
46-
server.stop()
47-
except Exception:
48-
pass
45+
server.stop()
4946
return
5047

5148

packages/pynumaflow-lite/manifests/reducestream/reducestream_counter.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,7 @@ async def start(creator: type, init_args: tuple):
8888
await server.start(creator, init_args)
8989
print("Shutting down gracefully...")
9090
except asyncio.CancelledError:
91-
try:
92-
server.stop()
93-
except Exception:
94-
pass
91+
server.stop()
9592
return
9693

9794

packages/pynumaflow-lite/manifests/session_reduce/session_reduce_counter_class.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,7 @@ async def main():
7272
await server.start(SessionReduceCounter)
7373
print("Shutting down gracefully...")
7474
except asyncio.CancelledError:
75-
try:
76-
server.stop()
77-
except Exception:
78-
pass
75+
server.stop()
7976
return
8077

8178
if __name__ == "__main__":

packages/pynumaflow-lite/manifests/sideinput/sideinput_example.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@
1414
import threading
1515
from threading import Thread
1616

17-
from pynumaflow_lite import mapper, sideinputer
1817
from watchfiles import watch
1918

19+
from pynumaflow_lite import mapper, sideinputer
20+
2021

2122
class ExampleSideInput(sideinputer.SideInput):
2223
"""
@@ -32,7 +33,7 @@ async def retrieve_handler(self) -> sideinputer.Response:
3233
"""
3334
time_now = datetime.datetime.now()
3435
# val is the value to be broadcasted
35-
val = f"an example: {str(time_now)}"
36+
val = f"an example: {time_now!s}"
3637
self.counter += 1
3738
# broadcast_message() is used to indicate that there is a broadcast
3839
return sideinputer.Response.broadcast_message(val.encode("utf-8"))
@@ -65,7 +66,7 @@ def file_watcher(self):
6566
path = sideinputer.DIR_PATH
6667
for changes in watch(path):
6768
for change in changes:
68-
change_type, file_path = change
69+
_change_type, file_path = change
6970
if file_path.endswith(self.watched_file):
7071
with self.data_value_lock:
7172
self.update_data_from_file(file_path)

packages/pynumaflow-lite/manifests/sink/sink_log.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import asyncio
22
import logging
33
import signal
4-
from collections.abc import AsyncIterable, AsyncIterator
5-
from typing import Awaitable, Callable
4+
from collections.abc import AsyncIterable, AsyncIterator, Awaitable, Callable
65

76
from pynumaflow_lite import sinker
87
from pynumaflow_lite._sink_dtypes import Sinker
@@ -43,10 +42,7 @@ async def start(
4342
await server.start(f)
4443
print("Shutting down gracefully...")
4544
except asyncio.CancelledError:
46-
try:
47-
server.stop()
48-
except Exception:
49-
pass
45+
server.stop()
5046
return
5147

5248

packages/pynumaflow-lite/manifests/source/simple_source.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ async def read_handler(
3333
)
3434

3535
# Generate the requested number of messages
36-
for i in range(datum.num_records):
36+
for _ in range(datum.num_records):
3737
# Create message payload
3838
payload = f"message-{self.counter}".encode()
3939

@@ -110,10 +110,7 @@ async def start():
110110
await server.start(handler)
111111
print("Shutting down gracefully...")
112112
except asyncio.CancelledError:
113-
try:
114-
server.stop()
115-
except Exception:
116-
pass
113+
server.stop()
117114
return
118115

119116

0 commit comments

Comments
 (0)