Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 97941d4

Browse files
committed
Run lint script with latest black
1 parent ebcc0f6 commit 97941d4

File tree

268 files changed

+2783
-1696
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

268 files changed

+2783
-1696
lines changed

contrib/cmdclient/console.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def _domain(self):
9292
return self.config["user"].split(":")[1]
9393

9494
def do_config(self, line):
95-
""" Show the config for this client: "config"
95+
"""Show the config for this client: "config"
9696
Edit a key value mapping: "config key value" e.g. "config token 1234"
9797
Config variables:
9898
user: The username to auth with.
@@ -360,7 +360,7 @@ def do_joinalias(self, line):
360360
print(e)
361361

362362
def do_topic(self, line):
363-
""""topic [set|get] <roomid> [<newtopic>]"
363+
""" "topic [set|get] <roomid> [<newtopic>]"
364364
Set the topic for a room: topic set <roomid> <newtopic>
365365
Get the topic for a room: topic get <roomid>
366366
"""
@@ -690,7 +690,7 @@ def do_online(self, line):
690690
self._do_presence_state(2, line)
691691

692692
def _parse(self, line, keys, force_keys=False):
693-
""" Parses the given line.
693+
"""Parses the given line.
694694
695695
Args:
696696
line : The line to parse
@@ -721,7 +721,7 @@ def _run_and_pprint(
721721
query_params={"access_token": None},
722722
alt_text=None,
723723
):
724-
""" Runs an HTTP request and pretty prints the output.
724+
"""Runs an HTTP request and pretty prints the output.
725725
726726
Args:
727727
method: HTTP method

contrib/cmdclient/http.py

+8-13
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,10 @@
2323

2424

2525
class HttpClient:
26-
""" Interface for talking json over http
27-
"""
26+
"""Interface for talking json over http"""
2827

2928
def put_json(self, url, data):
30-
""" Sends the specifed json data using PUT
29+
"""Sends the specifed json data using PUT
3130
3231
Args:
3332
url (str): The URL to PUT data to.
@@ -41,7 +40,7 @@ def put_json(self, url, data):
4140
pass
4241

4342
def get_json(self, url, args=None):
44-
""" Gets some json from the given host homeserver and path
43+
"""Gets some json from the given host homeserver and path
4544
4645
Args:
4746
url (str): The URL to GET data from.
@@ -58,7 +57,7 @@ def get_json(self, url, args=None):
5857

5958

6059
class TwistedHttpClient(HttpClient):
61-
""" Wrapper around the twisted HTTP client api.
60+
"""Wrapper around the twisted HTTP client api.
6261
6362
Attributes:
6463
agent (twisted.web.client.Agent): The twisted Agent used to send the
@@ -87,8 +86,7 @@ def get_json(self, url, args=None):
8786
defer.returnValue(json.loads(body))
8887

8988
def _create_put_request(self, url, json_data, headers_dict={}):
90-
""" Wrapper of _create_request to issue a PUT request
91-
"""
89+
"""Wrapper of _create_request to issue a PUT request"""
9290

9391
if "Content-Type" not in headers_dict:
9492
raise defer.error(RuntimeError("Must include Content-Type header for PUTs"))
@@ -98,8 +96,7 @@ def _create_put_request(self, url, json_data, headers_dict={}):
9896
)
9997

10098
def _create_get_request(self, url, headers_dict={}):
101-
""" Wrapper of _create_request to issue a GET request
102-
"""
99+
"""Wrapper of _create_request to issue a GET request"""
103100
return self._create_request("GET", url, headers_dict=headers_dict)
104101

105102
@defer.inlineCallbacks
@@ -127,8 +124,7 @@ def do_request(
127124

128125
@defer.inlineCallbacks
129126
def _create_request(self, method, url, producer=None, headers_dict={}):
130-
""" Creates and sends a request to the given url
131-
"""
127+
"""Creates and sends a request to the given url"""
132128
headers_dict["User-Agent"] = ["Synapse Cmd Client"]
133129

134130
retries_left = 5
@@ -185,8 +181,7 @@ def stopProducing(self):
185181

186182

187183
class _JsonProducer:
188-
""" Used by the twisted http client to create the HTTP body from json
189-
"""
184+
"""Used by the twisted http client to create the HTTP body from json"""
190185

191186
def __init__(self, jsn):
192187
self.data = jsn

contrib/experiments/cursesio.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ def print_log(self, text):
6363
self.redraw()
6464

6565
def redraw(self):
66-
""" method for redisplaying lines
67-
based on internal list of lines """
66+
"""method for redisplaying lines
67+
based on internal list of lines"""
6868

6969
self.stdscr.clear()
7070
self.paintStatus(self.statusText)

contrib/experiments/test_messaging.py

+13-23
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def excpetion_errback(failure):
5656

5757

5858
class InputOutput:
59-
""" This is responsible for basic I/O so that a user can interact with
59+
"""This is responsible for basic I/O so that a user can interact with
6060
the example app.
6161
"""
6262

@@ -68,8 +68,7 @@ def set_home_server(self, server):
6868
self.server = server
6969

7070
def on_line(self, line):
71-
""" This is where we process commands.
72-
"""
71+
"""This is where we process commands."""
7372

7473
try:
7574
m = re.match(r"^join (\S+)$", line)
@@ -133,7 +132,7 @@ def emit(self, record):
133132

134133

135134
class Room:
136-
""" Used to store (in memory) the current membership state of a room, and
135+
"""Used to store (in memory) the current membership state of a room, and
137136
which home servers we should send PDUs associated with the room to.
138137
"""
139138

@@ -148,8 +147,7 @@ def __init__(self, room_name):
148147
self.have_got_metadata = False
149148

150149
def add_participant(self, participant):
151-
""" Someone has joined the room
152-
"""
150+
"""Someone has joined the room"""
153151
self.participants.add(participant)
154152
self.invited.discard(participant)
155153

@@ -160,14 +158,13 @@ def add_participant(self, participant):
160158
self.oldest_server = server
161159

162160
def add_invited(self, invitee):
163-
""" Someone has been invited to the room
164-
"""
161+
"""Someone has been invited to the room"""
165162
self.invited.add(invitee)
166163
self.servers.add(origin_from_ucid(invitee))
167164

168165

169166
class HomeServer(ReplicationHandler):
170-
""" A very basic home server implentation that allows people to join a
167+
"""A very basic home server implentation that allows people to join a
171168
room and then invite other people.
172169
"""
173170

@@ -181,8 +178,7 @@ def __init__(self, server_name, replication_layer, output):
181178
self.output = output
182179

183180
def on_receive_pdu(self, pdu):
184-
""" We just received a PDU
185-
"""
181+
"""We just received a PDU"""
186182
pdu_type = pdu.pdu_type
187183

188184
if pdu_type == "sy.room.message":
@@ -199,23 +195,20 @@ def on_receive_pdu(self, pdu):
199195
)
200196

201197
def _on_message(self, pdu):
202-
""" We received a message
203-
"""
198+
"""We received a message"""
204199
self.output.print_line(
205200
"#%s %s %s" % (pdu.context, pdu.content["sender"], pdu.content["body"])
206201
)
207202

208203
def _on_join(self, context, joinee):
209-
""" Someone has joined a room, either a remote user or a local user
210-
"""
204+
"""Someone has joined a room, either a remote user or a local user"""
211205
room = self._get_or_create_room(context)
212206
room.add_participant(joinee)
213207

214208
self.output.print_line("#%s %s %s" % (context, joinee, "*** JOINED"))
215209

216210
def _on_invite(self, origin, context, invitee):
217-
""" Someone has been invited
218-
"""
211+
"""Someone has been invited"""
219212
room = self._get_or_create_room(context)
220213
room.add_invited(invitee)
221214

@@ -228,8 +221,7 @@ def _on_invite(self, origin, context, invitee):
228221

229222
@defer.inlineCallbacks
230223
def send_message(self, room_name, sender, body):
231-
""" Send a message to a room!
232-
"""
224+
"""Send a message to a room!"""
233225
destinations = yield self.get_servers_for_context(room_name)
234226

235227
try:
@@ -247,8 +239,7 @@ def send_message(self, room_name, sender, body):
247239

248240
@defer.inlineCallbacks
249241
def join_room(self, room_name, sender, joinee):
250-
""" Join a room!
251-
"""
242+
"""Join a room!"""
252243
self._on_join(room_name, joinee)
253244

254245
destinations = yield self.get_servers_for_context(room_name)
@@ -269,8 +260,7 @@ def join_room(self, room_name, sender, joinee):
269260

270261
@defer.inlineCallbacks
271262
def invite_to_room(self, room_name, sender, invitee):
272-
""" Invite someone to a room!
273-
"""
263+
"""Invite someone to a room!"""
274264
self._on_invite(self.server_name, room_name, invitee)
275265

276266
destinations = yield self.get_servers_for_context(room_name)

contrib/jitsimeetbridge/jitsimeetbridge.py

+6-9
Original file line numberDiff line numberDiff line change
@@ -193,15 +193,12 @@ def advertiseSsrcs(self):
193193
time.sleep(7)
194194
print("SSRC spammer started")
195195
while self.running:
196-
ssrcMsg = (
197-
"<presence to='%(tojid)s' xmlns='jabber:client'><x xmlns='http://jabber.org/protocol/muc'/><c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='http://jitsi.org/jitsimeet' ver='0WkSdhFnAUxrz4ImQQLdB80GFlE='/><nick xmlns='http://jabber.org/protocol/nick'>%(nick)s</nick><stats xmlns='http://jitsi.org/jitmeet/stats'><stat name='bitrate_download' value='175'/><stat name='bitrate_upload' value='176'/><stat name='packetLoss_total' value='0'/><stat name='packetLoss_download' value='0'/><stat name='packetLoss_upload' value='0'/></stats><media xmlns='http://estos.de/ns/mjs'><source type='audio' ssrc='%(assrc)s' direction='sendre'/><source type='video' ssrc='%(vssrc)s' direction='sendre'/></media></presence>"
198-
% {
199-
"tojid": "%s@%s/%s" % (ROOMNAME, ROOMDOMAIN, self.shortJid),
200-
"nick": self.userId,
201-
"assrc": self.ssrcs["audio"],
202-
"vssrc": self.ssrcs["video"],
203-
}
204-
)
196+
ssrcMsg = "<presence to='%(tojid)s' xmlns='jabber:client'><x xmlns='http://jabber.org/protocol/muc'/><c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='http://jitsi.org/jitsimeet' ver='0WkSdhFnAUxrz4ImQQLdB80GFlE='/><nick xmlns='http://jabber.org/protocol/nick'>%(nick)s</nick><stats xmlns='http://jitsi.org/jitmeet/stats'><stat name='bitrate_download' value='175'/><stat name='bitrate_upload' value='176'/><stat name='packetLoss_total' value='0'/><stat name='packetLoss_download' value='0'/><stat name='packetLoss_upload' value='0'/></stats><media xmlns='http://estos.de/ns/mjs'><source type='audio' ssrc='%(assrc)s' direction='sendre'/><source type='video' ssrc='%(vssrc)s' direction='sendre'/></media></presence>" % {
197+
"tojid": "%s@%s/%s" % (ROOMNAME, ROOMDOMAIN, self.shortJid),
198+
"nick": self.userId,
199+
"assrc": self.ssrcs["audio"],
200+
"vssrc": self.ssrcs["video"],
201+
}
205202
res = self.sendIq(ssrcMsg)
206203
print("reply from ssrc announce: ", res)
207204
time.sleep(10)

scripts-dev/mypy_synapse_plugin.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ def cached_function_method_signature(ctx: MethodSigContext) -> CallableType:
8787
arg_kinds.append(ARG_NAMED_OPT) # Arg is an optional kwarg.
8888

8989
signature = signature.copy_modified(
90-
arg_types=arg_types, arg_names=arg_names, arg_kinds=arg_kinds,
90+
arg_types=arg_types,
91+
arg_names=arg_names,
92+
arg_kinds=arg_kinds,
9193
)
9294

9395
return signature

stubs/sortedcontainers/sorteddict.pyi

+6-2
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,16 @@ class SortedDict(Dict[_KT, _VT]):
8989
def __reduce__(
9090
self,
9191
) -> Tuple[
92-
Type[SortedDict[_KT, _VT]], Tuple[Callable[[_KT], Any], List[Tuple[_KT, _VT]]],
92+
Type[SortedDict[_KT, _VT]],
93+
Tuple[Callable[[_KT], Any], List[Tuple[_KT, _VT]]],
9394
]: ...
9495
def __repr__(self) -> str: ...
9596
def _check(self) -> None: ...
9697
def islice(
97-
self, start: Optional[int] = ..., stop: Optional[int] = ..., reverse=bool,
98+
self,
99+
start: Optional[int] = ...,
100+
stop: Optional[int] = ...,
101+
reverse=bool,
98102
) -> Iterator[_KT]: ...
99103
def bisect_left(self, value: _KT) -> int: ...
100104
def bisect_right(self, value: _KT) -> int: ...

stubs/sortedcontainers/sortedlist.pyi

+13-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ class SortedList(MutableSequence[_T]):
3131

3232
DEFAULT_LOAD_FACTOR: int = ...
3333
def __init__(
34-
self, iterable: Optional[Iterable[_T]] = ..., key: Optional[_Key[_T]] = ...,
34+
self,
35+
iterable: Optional[Iterable[_T]] = ...,
36+
key: Optional[_Key[_T]] = ...,
3537
): ...
3638
# NB: currently mypy does not honour return type, see mypy #3307
3739
@overload
@@ -76,10 +78,18 @@ class SortedList(MutableSequence[_T]):
7678
def __len__(self) -> int: ...
7779
def reverse(self) -> None: ...
7880
def islice(
79-
self, start: Optional[int] = ..., stop: Optional[int] = ..., reverse=bool,
81+
self,
82+
start: Optional[int] = ...,
83+
stop: Optional[int] = ...,
84+
reverse=bool,
8085
) -> Iterator[_T]: ...
8186
def _islice(
82-
self, min_pos: int, min_idx: int, max_pos: int, max_idx: int, reverse: bool,
87+
self,
88+
min_pos: int,
89+
min_idx: int,
90+
max_pos: int,
91+
max_idx: int,
92+
reverse: bool,
8393
) -> Iterator[_T]: ...
8494
def irange(
8595
self,

synapse/api/auth.py

+11-5
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ async def get_user_by_req(
168168
rights: str = "access",
169169
allow_expired: bool = False,
170170
) -> synapse.types.Requester:
171-
""" Get a registered user's ID.
171+
"""Get a registered user's ID.
172172
173173
Args:
174174
request: An HTTP request with an access_token query parameter.
@@ -294,9 +294,12 @@ async def _get_appservice_user_id(self, request):
294294
return user_id, app_service
295295

296296
async def get_user_by_access_token(
297-
self, token: str, rights: str = "access", allow_expired: bool = False,
297+
self,
298+
token: str,
299+
rights: str = "access",
300+
allow_expired: bool = False,
298301
) -> TokenLookupResult:
299-
""" Validate access token and get user_id from it
302+
"""Validate access token and get user_id from it
300303
301304
Args:
302305
token: The access token to get the user by
@@ -489,7 +492,7 @@ def get_appservice_by_req(self, request: SynapseRequest) -> ApplicationService:
489492
return service
490493

491494
async def is_server_admin(self, user: UserID) -> bool:
492-
""" Check if the given user is a local server admin.
495+
"""Check if the given user is a local server admin.
493496
494497
Args:
495498
user: user to check
@@ -500,7 +503,10 @@ async def is_server_admin(self, user: UserID) -> bool:
500503
return await self.store.is_server_admin(user)
501504

502505
def compute_auth_events(
503-
self, event, current_state_ids: StateMap[str], for_verification: bool = False,
506+
self,
507+
event,
508+
current_state_ids: StateMap[str],
509+
for_verification: bool = False,
504510
) -> List[str]:
505511
"""Given an event and current state return the list of event IDs used
506512
to auth an event.

synapse/api/constants.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,7 @@ class UserTypes:
128128

129129

130130
class RelationTypes:
131-
"""The types of relations known to this server.
132-
"""
131+
"""The types of relations known to this server."""
133132

134133
ANNOTATION = "m.annotation"
135134
REPLACE = "m.replace"

0 commit comments

Comments
 (0)