Skip to content

Commit a8ee157

Browse files
committed
linter
1 parent a28b3be commit a8ee157

File tree

8 files changed

+42
-71
lines changed

8 files changed

+42
-71
lines changed

fishjam/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
"""
2-
.. include:: ../README.md
3-
"""
1+
""".. include:: ../README.md"""
42

53
# pylint: disable=locally-disabled, no-name-in-module, import-error
64

fishjam/_webhook_notifier.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
"""
2-
Module defining a function allowing decoding received webhook
3-
notification from fishjam to notification structs.
4-
"""
5-
1+
"""Module for decoding received webhook notifications from Fishjam."""
62
from typing import Union
73

84
import betterproto
@@ -15,8 +11,8 @@
1511

1612

1713
def receive_binary(binary: bytes) -> Union[AllowedNotification, None]:
18-
"""
19-
Transform received protobuf notification to adequate notification instance.
14+
"""Transform received protobuf notification to adequate notification instance.
15+
2016
The available notifications are listed in `fishjam.events` module.
2117
"""
2218
message = ServerMessage().parse(binary)

fishjam/_ws_notifier.py

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
"""
2-
Notifier listening to WebSocket events
3-
"""
1+
"""Notifier listening to WebSocket events"""
42

53
import asyncio
64
import inspect
@@ -32,19 +30,14 @@
3230

3331

3432
class FishjamNotifier:
35-
"""
36-
Allows for receiving WebSocket messages from Fishjam.
37-
"""
33+
"""Allows for receiving WebSocket messages from Fishjam."""
3834

3935
def __init__(
4036
self,
4137
fishjam_id: str,
4238
management_token: str,
4339
):
44-
"""
45-
Create FishjamNotifier instance, providing the fishjam id and management token.
46-
"""
47-
40+
"""Create a FishjamNotifier instance with an ID and management token."""
4841
websocket_url = get_fishjam_url(fishjam_id).replace("http", "ws")
4942
self._fishjam_url = f"{websocket_url}/socket/server/websocket"
5043
self._management_token: str = management_token
@@ -56,16 +49,12 @@ def __init__(
5649
self._notification_handler: NotificationHandler | None = None
5750

5851
def on_server_notification(self, handler: NotificationHandler):
59-
"""
60-
Decorator used for defining handler for Fishjam Notifications
61-
"""
52+
"""Decorator used for defining handler for Fishjam Notifications"""
6253
self._notification_handler = handler
6354
return handler
6455

6556
async def connect(self):
66-
"""
67-
A coroutine which connects FishjamNotifier to Fishjam and listens for
68-
all incoming messages from the Fishjam.
57+
"""Connects to Fishjam and listens for all incoming messages.
6958
7059
It runs until the connection isn't closed.
7160
@@ -94,8 +83,7 @@ async def connect(self):
9483
self._websocket = None
9584

9685
async def wait_ready(self) -> None:
97-
"""
98-
Waits until the notifier is connected and authenticated to Fishjam.
86+
"""Waits until the notifier is connected and authenticated to Fishjam.
9987
10088
If already connected, returns immediately.
10189
"""

fishjam/agent/agent.py

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,10 @@ class OutgoingAudioTrackOptions:
5858

5959
@dataclass(frozen=True)
6060
class OutgoingTrack:
61-
"""
62-
Represents an outgoing track of an agent connected to Fishjam,
63-
created by :func:`Agent.add_track`.
64-
"""
61+
"""Represents an outgoing track of an agent connected to Fishjam.
6562
63+
This is created by :func:`Agent.add_track`.
64+
"""
6665
id: str
6766
"""The global identifier of the track."""
6867
session: AgentSession
@@ -71,8 +70,7 @@ class OutgoingTrack:
7170
"""The parameters used to create the track."""
7271

7372
async def send_chunk(self, data: bytes):
74-
"""
75-
Send a chunk of audio to Fishjam on this track.
73+
"""Send a chunk of audio to Fishjam on this track.
7674
7775
Peers connected to the room of the agent will receive this data.
7876
"""
@@ -86,8 +84,7 @@ async def send_chunk(self, data: bytes):
8684
await self.session._send(message)
8785

8886
async def interrupt(self):
89-
"""
90-
Interrupt current track.
87+
"""Interrupt current track.
9188
9289
Any audio that has been sent, but not played
9390
will be cleared and be prevented from playing.
@@ -111,10 +108,7 @@ def __init__(self, agent: Agent, websocket: ClientConnection):
111108
self._closed = False
112109

113110
async def receive(self) -> AsyncIterator[IncomingAgentMessage]:
114-
"""
115-
Returns an infinite async iterator over the incoming messages from Fishjam to
116-
the agent.
117-
"""
111+
"""Returns an infinite async iterator over incoming messages from Fishjam."""
118112
while message := await self._ws.recv(decode=False):
119113
parsed = AgentResponse().parse(message)
120114
_, msg = betterproto.which_one_of(parsed, "content")
@@ -123,8 +117,7 @@ async def receive(self) -> AsyncIterator[IncomingAgentMessage]:
123117
yield content
124118

125119
async def add_track(self, options: OutgoingAudioTrackOptions):
126-
"""
127-
Adds a track to the connected agent, with the specified options and metadata.
120+
"""Adds a track to the connected agent, with the specified options and metadata.
128121
129122
Returns an instance of :class:`OutgoingTrack`, which can be used to send data
130123
over the added track.
@@ -152,27 +145,25 @@ async def _send(self, message: AgentRequest):
152145
await self._ws.send(bytes(message), text=False)
153146

154147
async def disconnect(self):
155-
"""
156-
Ends the agent session by closing the websocket connection.
148+
"""Ends the agent session by closing the websocket connection.
149+
157150
Useful when you don't use the context manager to obtain the session.
158151
"""
159152
await self._ws.close()
160153

161154

162155
class Agent:
163-
"""
164-
Allows for connecting to a Fishjam room as an agent peer.
156+
"""Allows for connecting to a Fishjam room as an agent peer.
157+
165158
Provides callbacks for receiving audio.
166159
"""
167160

168161
def __init__(self, id: str, room_id: str, token: str, fishjam_url: str):
169-
"""
170-
Create Agent instance, providing the fishjam id and management token.
162+
"""Create Agent instance, providing the fishjam id and management token.
171163
172164
This constructor should not be called directly.
173165
Instead, you should call :func:`fishjam.FishjamClient.create_agent`.
174166
"""
175-
176167
self.id = id
177168
self.room_id = room_id
178169

@@ -181,8 +172,7 @@ def __init__(self, id: str, room_id: str, token: str, fishjam_url: str):
181172

182173
@asynccontextmanager
183174
async def connect(self):
184-
"""
185-
Connect the agent to Fishjam to start receiving messages.
175+
"""Connect the agent to Fishjam to start receiving messages.
186176
187177
Incoming messages from Fishjam will be routed to handlers
188178
defined with :func:`on_track_data`.

fishjam/api/_fishjam_client.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
"""
2-
Fishjam client used to manage rooms
3-
"""
1+
"""Fishjam client used to manage rooms"""
42

53
from dataclasses import dataclass, field
64
from typing import Any, Literal, cast
@@ -263,7 +261,6 @@ def get_all_rooms(self) -> list[Room]:
263261
Returns:
264262
list[Room]: A list of all available Room objects.
265263
"""
266-
267264
rooms = cast(RoomsListingResponse, self._request(room_get_all_rooms)).data
268265

269266
return [
@@ -279,7 +276,6 @@ def get_room(self, room_id: str) -> Room:
279276
Returns:
280277
Room: The Room object corresponding to the given ID.
281278
"""
282-
283279
room = cast(
284280
RoomDetailsResponse, self._request(room_get_room, room_id=room_id)
285281
).data
@@ -293,7 +289,6 @@ def delete_peer(self, room_id: str, peer_id: str) -> None:
293289
room_id: The ID of the room the peer belongs to.
294290
peer_id: The ID of the peer to delete.
295291
"""
296-
297292
return self._request(room_delete_peer, id=peer_id, room_id=room_id)
298293

299294
def delete_room(self, room_id: str) -> None:
@@ -302,7 +297,6 @@ def delete_room(self, room_id: str) -> None:
302297
Args:
303298
room_id: The ID of the room to delete.
304299
"""
305-
306300
return self._request(room_delete_room, room_id=room_id)
307301

308302
def refresh_peer_token(self, room_id: str, peer_id: str) -> str:
@@ -315,7 +309,6 @@ def refresh_peer_token(self, room_id: str, peer_id: str) -> str:
315309
Returns:
316310
str: The new peer token.
317311
"""
318-
319312
response = cast(
320313
PeerRefreshTokenResponse,
321314
self._request(room_refresh_token, id=peer_id, room_id=room_id),
@@ -332,7 +325,6 @@ def create_livestream_viewer_token(self, room_id: str) -> str:
332325
Returns:
333326
str: The generated viewer token.
334327
"""
335-
336328
response = cast(
337329
ViewerToken, self._request(viewer_generate_viewer_token, room_id=room_id)
338330
)
@@ -348,7 +340,6 @@ def create_livestream_streamer_token(self, room_id: str) -> str:
348340
Returns:
349341
str: The generated streamer token.
350342
"""
351-
352343
response = cast(
353344
StreamerToken,
354345
self._request(streamer_generate_streamer_token, room_id=room_id),
@@ -364,7 +355,6 @@ def subscribe_peer(self, room_id: str, peer_id: str, target_peer_id: str):
364355
peer_id: The ID of the subscribing peer.
365356
target_peer_id: The ID of the peer to subscribe to.
366357
"""
367-
368358
self._request(
369359
room_subscribe_peer,
370360
room_id=room_id,
@@ -380,7 +370,6 @@ def subscribe_tracks(self, room_id: str, peer_id: str, track_ids: list[str]):
380370
peer_id: The ID of the subscribing peer.
381371
track_ids: A list of track IDs to subscribe to.
382372
"""
383-
384373
self._request(
385374
room_subscribe_tracks,
386375
room_id=room_id,

fishjam/errors.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,9 @@
55

66

77
class HTTPError(Exception):
8-
""""""
9-
108
@staticmethod
119
def from_response(response: Response[Error]):
1210
"""@private"""
13-
1411
if not response.parsed:
1512
raise RuntimeError("Got endpoint error reponse without parsed field")
1613

fishjam/events/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
"""
2-
.. include:: ../../docs/server_notifications.md
3-
"""
1+
""".. include:: ../../docs/server_notifications.md"""
42

53
# Exported messages
64
from fishjam.events._protos.fishjam import (

pyproject.toml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,28 @@ build-backend = "hatchling.build"
6969

7070
[tool.ruff.lint]
7171
select = ["W", "I", "F", "E", "D"]
72-
ignore = ["D107"]
72+
ignore = [
73+
"D100",
74+
"D101",
75+
"D102",
76+
"D103",
77+
"D104",
78+
"D105",
79+
"D107",
80+
"D415", # """@private""" would not be allowed
81+
]
7382

7483
[tool.ruff.lint.pydocstyle]
7584
convention = "google"
7685

7786
[tool.ruff.lint.extend-per-file-ignores]
78-
"fishjam/_openapi_client/**" = ["E501"]
87+
"fishjam/_openapi_client/**" = ["E501", "D"]
88+
"fishjam/events/_protos/**" = ["D"]
89+
"tests/**" = ["D"]
90+
"scripts.py" = ["D"]
91+
"" = ["D"]
92+
93+
7994

8095
[tool.pytest.ini_options]
8196
markers = [

0 commit comments

Comments
 (0)