Skip to content

Commit 22e47f7

Browse files
authored
increase ruff line-length (#377)
1 parent 132e562 commit 22e47f7

34 files changed

+119
-345
lines changed

examples/agent_dispatch.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,7 @@ async def create_token_with_agent_dispatch() -> str:
4343
.with_grants(api.VideoGrants(room_join=True, room=room_name))
4444
.with_room_config(
4545
api.RoomConfiguration(
46-
agents=[
47-
api.RoomAgentDispatch(
48-
agent_name="test-agent", metadata="my_metadata"
49-
)
50-
],
46+
agents=[api.RoomAgentDispatch(agent_name="test-agent", metadata="my_metadata")],
5147
),
5248
)
5349
.to_jwt()

examples/basic_room.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,11 @@
1212
async def main(room: rtc.Room) -> None:
1313
@room.on("participant_connected")
1414
def on_participant_connected(participant: rtc.RemoteParticipant) -> None:
15-
logging.info(
16-
"participant connected: %s %s", participant.sid, participant.identity
17-
)
15+
logging.info("participant connected: %s %s", participant.sid, participant.identity)
1816

1917
@room.on("participant_disconnected")
2018
def on_participant_disconnected(participant: rtc.RemoteParticipant):
21-
logging.info(
22-
"participant disconnected: %s %s", participant.sid, participant.identity
23-
)
19+
logging.info("participant disconnected: %s %s", participant.sid, participant.identity)
2420

2521
@room.on("local_track_published")
2622
def on_local_track_published(
@@ -78,9 +74,7 @@ def on_track_unsubscribed(
7874
logging.info("track unsubscribed: %s", publication.sid)
7975

8076
@room.on("track_muted")
81-
def on_track_muted(
82-
publication: rtc.RemoteTrackPublication, participant: rtc.RemoteParticipant
83-
):
77+
def on_track_muted(publication: rtc.RemoteTrackPublication, participant: rtc.RemoteParticipant):
8478
logging.info("track muted: %s", publication.sid)
8579

8680
@room.on("track_unmuted")
@@ -94,9 +88,7 @@ def on_data_received(data: rtc.DataPacket):
9488
logging.info("received data from %s: %s", data.participant.identity, data.data)
9589

9690
@room.on("connection_quality_changed")
97-
def on_connection_quality_changed(
98-
participant: rtc.Participant, quality: rtc.ConnectionQuality
99-
):
91+
def on_connection_quality_changed(participant: rtc.Participant, quality: rtc.ConnectionQuality):
10092
logging.info("connection quality changed for %s", participant.identity)
10193

10294
@room.on("track_subscription_failed")

examples/data-streams/data_streams.py

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,12 @@ async def greetParticipant(identity: str):
2727
topic="files",
2828
)
2929

30-
async def on_chat_message_received(
31-
reader: rtc.TextStreamReader, participant_identity: str
32-
):
30+
async def on_chat_message_received(reader: rtc.TextStreamReader, participant_identity: str):
3331
full_text = await reader.read_all()
34-
logger.info(
35-
"Received chat message from %s: '%s'", participant_identity, full_text
36-
)
32+
logger.info("Received chat message from %s: '%s'", participant_identity, full_text)
3733

38-
async def on_welcome_image_received(
39-
reader: rtc.ByteStreamReader, participant_identity: str
40-
):
41-
logger.info(
42-
"Received image from %s: '%s'", participant_identity, reader.info["name"]
43-
)
34+
async def on_welcome_image_received(reader: rtc.ByteStreamReader, participant_identity: str):
35+
logger.info("Received image from %s: '%s'", participant_identity, reader.info["name"])
4436
with open(reader.info["name"], mode="wb") as f:
4537
async for chunk in reader:
4638
f.write(chunk)
@@ -49,9 +41,7 @@ async def on_welcome_image_received(
4941

5042
@room.on("participant_connected")
5143
def on_participant_connected(participant: rtc.RemoteParticipant):
52-
logger.info(
53-
"participant connected: %s %s", participant.sid, participant.identity
54-
)
44+
logger.info("participant connected: %s %s", participant.sid, participant.identity)
5545
asyncio.create_task(greetParticipant(participant.identity))
5646

5747
room.set_text_stream_handler(

examples/e2ee.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,7 @@ async def draw_cube(source: rtc.VideoSource):
9797

9898
async def main(room: rtc.Room):
9999
@room.on("e2ee_state_changed")
100-
def on_e2ee_state_changed(
101-
participant: rtc.Participant, state: rtc.EncryptionState
102-
) -> None:
100+
def on_e2ee_state_changed(participant: rtc.Participant, state: rtc.EncryptionState) -> None:
103101
logging.info("e2ee state changed: %s %s", participant.identity, state)
104102

105103
logging.info("connecting to %s", URL)

examples/face_landmark/face_landmark.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,7 @@ def draw_landmarks_on_image(rgb_image, detection_result):
7272
face_landmarks_proto = landmark_pb2.NormalizedLandmarkList()
7373
face_landmarks_proto.landmark.extend(
7474
[
75-
landmark_pb2.NormalizedLandmark(
76-
x=landmark.x, y=landmark.y, z=landmark.z
77-
)
75+
landmark_pb2.NormalizedLandmark(x=landmark.x, y=landmark.y, z=landmark.z)
7876
for landmark in face_landmarks
7977
]
8078
)
@@ -113,9 +111,7 @@ async def frame_loop(video_stream: rtc.VideoStream) -> None:
113111
arr = arr.reshape((buffer.height, buffer.width, 3))
114112

115113
mp_image = mp.Image(image_format=mp.ImageFormat.SRGB, data=arr)
116-
detection_result = landmarker.detect_for_video(
117-
mp_image, frame_event.timestamp_us
118-
)
114+
detection_result = landmarker.detect_for_video(mp_image, frame_event.timestamp_us)
119115

120116
draw_landmarks_on_image(arr, detection_result)
121117

examples/room_example.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ async def main():
1515

1616
@room.on("participant_connected")
1717
def on_participant_connected(participant: rtc.RemoteParticipant):
18-
logger.info(
19-
"participant connected: %s %s", participant.sid, participant.identity
20-
)
18+
logger.info("participant connected: %s %s", participant.sid, participant.identity)
2119

2220
async def receive_frames(stream: rtc.VideoStream):
2321
async for frame in stream:

examples/rpc.py

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@
1010
LIVEKIT_API_SECRET = os.getenv("LIVEKIT_API_SECRET")
1111
LIVEKIT_URL = os.getenv("LIVEKIT_URL")
1212
if not LIVEKIT_API_KEY or not LIVEKIT_API_SECRET or not LIVEKIT_URL:
13-
raise ValueError(
14-
"Missing required environment variables. Please check your .env.local file."
15-
)
13+
raise ValueError("Missing required environment variables. Please check your .env.local file.")
1614

1715

1816
async def main():
@@ -82,9 +80,7 @@ async def main():
8280
finally:
8381
# Clean up all rooms
8482
print("Disconnecting all participants...")
85-
await asyncio.gather(
86-
*(room.disconnect() for room in rooms), return_exceptions=True
87-
)
83+
await asyncio.gather(*(room.disconnect() for room in rooms), return_exceptions=True)
8884
print("Cleanup complete")
8985

9086

@@ -121,9 +117,7 @@ async def divide_method(
121117
json_data = json.loads(data.payload)
122118
dividend = json_data["dividend"]
123119
divisor = json_data["divisor"]
124-
print(
125-
f"[Math Genius] {data.caller_identity} wants to divide {dividend} by {divisor}."
126-
)
120+
print(f"[Math Genius] {data.caller_identity} wants to divide {dividend} by {divisor}.")
127121

128122
result = dividend / divisor
129123
return json.dumps({"result": result})
@@ -132,9 +126,7 @@ async def divide_method(
132126
async def long_calculation_method(
133127
data: RpcInvocationData,
134128
):
135-
print(
136-
f"[Math Genius] Starting a very long calculation for {data.caller_identity}"
137-
)
129+
print(f"[Math Genius] Starting a very long calculation for {data.caller_identity}")
138130
print(
139131
f"[Math Genius] This will take 30 seconds even though you're only giving me {data.response_timeout} seconds"
140132
)
@@ -202,9 +194,7 @@ async def perform_divide(room: rtc.Room):
202194
print(f"[Caller] The result is {parsed_response['result']}")
203195
except rtc.RpcError as error:
204196
if error.code == rtc.RpcError.ErrorCode.APPLICATION_ERROR:
205-
print(
206-
"[Caller] Aww something went wrong with that one, lets try something else."
207-
)
197+
print("[Caller] Aww something went wrong with that one, lets try something else.")
208198
else:
209199
print(f"[Caller] RPC call failed with unexpected RpcError: {error}")
210200
except Exception as error:

examples/video-stream/audio_wave.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,7 @@ def draw_timestamp(self, canvas: np.ndarray, fps: float):
104104
y = int((height - text_height) * 0.4 + baseline)
105105
cv2.putText(canvas, text, (x, y), font_face, font_scale, (0, 0, 0), thickness)
106106

107-
def draw_current_wave(
108-
self, canvas: np.ndarray, audio_samples: np.ndarray
109-
) -> np.ndarray:
107+
def draw_current_wave(self, canvas: np.ndarray, audio_samples: np.ndarray) -> np.ndarray:
110108
"""Draw the current waveform and return the current values"""
111109
height, width = canvas.shape[:2]
112110
center_y = height // 2 + 100
@@ -136,9 +134,7 @@ def draw_volume_history(self, canvas: np.ndarray, current_volume: float):
136134
center_y = height // 2
137135

138136
self.volume_history.append(current_volume)
139-
cv2.line(
140-
canvas, (0, center_y - 250), (width, center_y - 250), (200, 200, 200), 1
141-
)
137+
cv2.line(canvas, (0, center_y - 250), (width, center_y - 250), (200, 200, 200), 1)
142138

143139
volume_x = np.linspace(0, width, len(self.volume_history), dtype=int)
144140
volume_y = center_y - 250 + (np.array(self.volume_history) * 200)
@@ -158,9 +154,7 @@ async def video_generator(
158154
input_audio: asyncio.Queue[Union[rtc.AudioFrame, _AudioEndSentinel]],
159155
av_sync: rtc.AVSynchronizer, # only used for drawing the actual fps on the video
160156
) -> AsyncIterable[tuple[rtc.VideoFrame, Optional[rtc.AudioFrame]]]:
161-
canvas = np.zeros(
162-
(media_info.video_height, media_info.video_width, 4), dtype=np.uint8
163-
)
157+
canvas = np.zeros((media_info.video_height, media_info.video_width, 4), dtype=np.uint8)
164158
canvas.fill(255)
165159

166160
def _np_to_video_frame(image: np.ndarray) -> rtc.VideoFrame:

examples/video-stream/video_play.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@
1414
try:
1515
import av
1616
except ImportError:
17-
raise RuntimeError(
18-
"av is required to run this example, install with `pip install av`"
19-
)
17+
raise RuntimeError("av is required to run this example, install with `pip install av`")
2018

2119
# ensure LIVEKIT_URL, LIVEKIT_API_KEY, and LIVEKIT_API_SECRET are set
2220

livekit-api/livekit/api/_service.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@
1010

1111

1212
class Service(ABC):
13-
def __init__(
14-
self, session: aiohttp.ClientSession, host: str, api_key: str, api_secret: str
15-
):
13+
def __init__(self, session: aiohttp.ClientSession, host: str, api_key: str, api_secret: str):
1614
self._client = TwirpClient(session, host, "livekit")
1715
self.api_key = api_key
1816
self.api_secret = api_secret

0 commit comments

Comments
 (0)