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

Commit a442e6b

Browse files
committed
Remove types from comments.
1 parent b2c2b03 commit a442e6b

25 files changed

+70
-82
lines changed

synapse/config/logger.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -317,10 +317,9 @@ def setup_logging(
317317
Set up the logging subsystem.
318318
319319
Args:
320-
config (LoggingConfig | synapse.config.worker.WorkerConfig):
321-
configuration data
320+
config: configuration data
322321
323-
use_worker_options (bool): True to use the 'worker_log_config' option
322+
use_worker_options: True to use the 'worker_log_config' option
324323
instead of 'log_config'.
325324
326325
logBeginner: The Twisted logBeginner to use.

synapse/federation/transport/client.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -280,12 +280,11 @@ async def make_membership_event(
280280
Note that this does not append any events to any graphs.
281281
282282
Args:
283-
destination (str): address of remote homeserver
284-
room_id (str): room to join/leave
285-
user_id (str): user to be joined/left
286-
membership (str): one of join/leave
287-
params (dict[str, str|Iterable[str]]): Query parameters to include in the
288-
request.
283+
destination: address of remote homeserver
284+
room_id: room to join/leave
285+
user_id: user to be joined/left
286+
membership: one of join/leave
287+
params: Query parameters to include in the request.
289288
290289
Returns:
291290
Succeeds when we get a 2xx HTTP response. The result

synapse/federation/transport/server/_base.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,10 @@ class BaseFederationServlet:
224224
225225
With arguments:
226226
227-
origin (unicode|None): The authenticated server_name of the calling server,
227+
origin (str|None): The authenticated server_name of the calling server,
228228
unless REQUIRE_AUTH is set to False and authentication failed.
229229
230-
content (unicode|None): decoded json body of the request. None if the
230+
content (str|None): decoded json body of the request. None if the
231231
request was a GET.
232232
233233
query (dict[bytes, list[bytes]]): Query params from the request. url-decoded

synapse/handlers/e2e_keys.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,7 @@ async def _process_self_signatures(
870870
- signatures of the user's master key by the user's devices.
871871
872872
Args:
873-
user_id (string): the user uploading the keys
873+
user_id: the user uploading the keys
874874
signatures (dict[string, dict]): map of devices to signed keys
875875
876876
Returns:

synapse/handlers/federation.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1596,8 +1596,8 @@ async def get_room_complexity(
15961596
Fetch the complexity of a remote room over federation.
15971597
15981598
Args:
1599-
remote_room_hosts (list[str]): The remote servers to ask.
1600-
room_id (str): The room ID to ask about.
1599+
remote_room_hosts: The remote servers to ask.
1600+
room_id: The room ID to ask about.
16011601
16021602
Returns:
16031603
Dict contains the complexity

synapse/handlers/identity.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ async def ask_id_server_for_third_party_invite(
711711
inviter_display_name: The current display name of the
712712
inviter.
713713
inviter_avatar_url: The URL of the inviter's avatar.
714-
id_access_token (str): The access token to authenticate to the identity
714+
id_access_token: The access token to authenticate to the identity
715715
server with
716716
717717
Returns:

synapse/http/additional_resource.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ def __init__(
4545
4646
Args:
4747
hs: homeserver
48-
handler ((twisted.web.server.Request) -> twisted.internet.defer.Deferred):
49-
function to be called to handle the request.
48+
handler: function to be called to handle the request.
5049
"""
5150
super().__init__()
5251
self._handler = handler

synapse/http/server.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ def register_paths(
267267
request. The first argument will be the request object and
268268
subsequent arguments will be any matched groups from the regex.
269269
This should return either tuple of (code, response), or None.
270-
servlet_classname (str): The name of the handler to be used in prometheus
270+
servlet_classname: The name of the handler to be used in prometheus
271271
and opentracing logs.
272272
"""
273273

synapse/http/site.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ def _started_processing(self, servlet_name: str) -> None:
400400
be sure to call finished_processing.
401401
402402
Args:
403-
servlet_name (str): the name of the servlet which will be
403+
servlet_name: the name of the servlet which will be
404404
processing this request. This is used in the metrics.
405405
406406
It is possible to update this afterwards by updating

synapse/logging/context.py

+10-12
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,7 @@ def __init__(self, copy_from: "Optional[ContextResourceUsage]" = None) -> None:
117117
"""Create a new ContextResourceUsage
118118
119119
Args:
120-
copy_from (ContextResourceUsage|None): if not None, an object to
121-
copy stats from
120+
copy_from: if not None, an object to copy stats from
122121
"""
123122
if copy_from is None:
124123
self.reset()
@@ -162,7 +161,7 @@ def __iadd__(self, other: "ContextResourceUsage") -> "ContextResourceUsage":
162161
"""Add another ContextResourceUsage's stats to this one's.
163162
164163
Args:
165-
other (ContextResourceUsage): the other resource usage object
164+
other: the other resource usage object
166165
"""
167166
self.ru_utime += other.ru_utime
168167
self.ru_stime += other.ru_stime
@@ -898,13 +897,12 @@ def defer_to_thread(
898897
on it.
899898
900899
Args:
901-
reactor (twisted.internet.base.ReactorBase): The reactor in whose main thread
902-
the Deferred will be invoked, and whose threadpool we should use for the
903-
function.
900+
reactor: The reactor in whose main thread the Deferred will be invoked,
901+
and whose threadpool we should use for the function.
904902
905903
Normally this will be hs.get_reactor().
906904
907-
f (callable): The function to call.
905+
f: The function to call.
908906
909907
args: positional arguments to pass to f.
910908
@@ -939,13 +937,13 @@ def defer_to_threadpool(
939937
on it.
940938
941939
Args:
942-
reactor (twisted.internet.base.ReactorBase): The reactor in whose main thread
943-
the Deferred will be invoked. Normally this will be hs.get_reactor().
940+
reactor: The reactor in whose main thread the Deferred will be invoked.
941+
Normally this will be hs.get_reactor().
944942
945-
threadpool (twisted.python.threadpool.ThreadPool): The threadpool to use for
946-
running `f`. Normally this will be hs.get_reactor().getThreadPool().
943+
threadpool: The threadpool to use for running `f`. Normally this will be
944+
hs.get_reactor().getThreadPool().
947945
948-
f (callable): The function to call.
946+
f: The function to call.
949947
950948
args: positional arguments to pass to f.
951949

synapse/logging/opentracing.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,7 @@ def inject_header_dict(
721721
destination: address of entity receiving the span context. Must be given unless
722722
check_destination is False. The context will only be injected if the
723723
destination matches the opentracing whitelist
724-
check_destination (bool): If false, destination will be ignored and the context
724+
check_destination: If false, destination will be ignored and the context
725725
will always be injected.
726726
727727
Note:

synapse/rest/media/v1/media_repository.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,8 @@ async def _get_remote_media_impl(
344344
download from remote server.
345345
346346
Args:
347-
server_name (str): Remote server_name where the media originated.
348-
media_id (str): The media ID of the content (as defined by the
347+
server_name: Remote server_name where the media originated.
348+
media_id: The media ID of the content (as defined by the
349349
remote server).
350350
351351
Returns:

synapse/server_notices/consent_server_notices.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,8 @@ def copy_with_str_subst(x: Any, substitutions: Any) -> Any:
113113
"""Deep-copy a structure, carrying out string substitutions on any strings
114114
115115
Args:
116-
x (object): structure to be copied
117-
substitutions (object): substitutions to be made - passed into the
118-
string '%' operator
116+
x: structure to be copied
117+
substitutions: substitutions to be made - passed into the string '%' operator
119118
120119
Returns:
121120
copy of x

synapse/storage/controllers/persist_events.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,8 @@ async def add_to_queue(
204204
process to to so, calling the per_item_callback for each item.
205205
206206
Args:
207-
room_id (str):
208-
task (_EventPersistQueueTask): A _PersistEventsTask or
209-
_UpdateCurrentStateTask to process.
207+
room_id:
208+
task: A _PersistEventsTask or _UpdateCurrentStateTask to process.
210209
211210
Returns:
212211
the result returned by the `_per_item_callback` passed to

synapse/storage/databases/main/events.py

+10-12
Original file line numberDiff line numberDiff line change
@@ -1282,9 +1282,10 @@ def _filter_events_and_contexts_for_duplicates(
12821282
Pick the earliest non-outlier if there is one, else the earliest one.
12831283
12841284
Args:
1285-
events_and_contexts (list[(EventBase, EventContext)]):
1285+
events_and_contexts:
1286+
12861287
Returns:
1287-
list[(EventBase, EventContext)]: filtered list
1288+
filtered list
12881289
"""
12891290
new_events_and_contexts: OrderedDict[
12901291
str, Tuple[EventBase, EventContext]
@@ -1310,9 +1311,8 @@ def _update_room_depths_txn(
13101311
"""Update min_depth for each room
13111312
13121313
Args:
1313-
txn (twisted.enterprise.adbapi.Connection): db connection
1314-
events_and_contexts (list[(EventBase, EventContext)]): events
1315-
we are persisting
1314+
txn: db connection
1315+
events_and_contexts: events we are persisting
13161316
"""
13171317
depth_updates: Dict[str, int] = {}
13181318
for event, context in events_and_contexts:
@@ -1583,13 +1583,11 @@ def _update_metadata_tables_txn(
15831583
"""Update all the miscellaneous tables for new events
15841584
15851585
Args:
1586-
txn (twisted.enterprise.adbapi.Connection): db connection
1587-
events_and_contexts (list[(EventBase, EventContext)]): events
1588-
we are persisting
1589-
all_events_and_contexts (list[(EventBase, EventContext)]): all
1590-
events that we were going to persist. This includes events
1591-
we've already persisted, etc, that wouldn't appear in
1592-
events_and_context.
1586+
txn: db connection
1587+
events_and_contexts: events we are persisting
1588+
all_events_and_contexts: all events that we were going to persist.
1589+
This includes events we've already persisted, etc, that wouldn't
1590+
appear in events_and_context.
15931591
inhibit_local_membership_updates: Stop the local_current_membership
15941592
from being updated by these events. This should be set to True
15951593
for backfilled events because backfilled events in the past do

synapse/storage/databases/main/monthly_active_users.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ async def reap_monthly_active_users(self) -> None:
217217
def _reap_users(txn: LoggingTransaction, reserved_users: List[str]) -> None:
218218
"""
219219
Args:
220-
reserved_users (tuple): reserved users to preserve
220+
reserved_users: reserved users to preserve
221221
"""
222222

223223
thirty_days_ago = int(self._clock.time_msec()) - (1000 * 60 * 60 * 24 * 30)
@@ -370,8 +370,8 @@ def upsert_monthly_active_user_txn(
370370
should not appear in the MAU stats).
371371
372372
Args:
373-
txn (cursor):
374-
user_id (str): user to add/update
373+
txn:
374+
user_id: user to add/update
375375
"""
376376
assert (
377377
self._update_on_this_worker

synapse/storage/databases/main/registration.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,7 @@ def get_user_id_by_threepid_txn(
953953
"""Returns user id from threepid
954954
955955
Args:
956-
txn (cursor):
956+
txn:
957957
medium: threepid medium e.g. email
958958
address: threepid address e.g. [email protected]
959959
@@ -1283,8 +1283,8 @@ def set_expiration_date_for_user_txn(
12831283
"""Sets an expiration date to the account with the given user ID.
12841284
12851285
Args:
1286-
user_id (str): User ID to set an expiration date for.
1287-
use_delta (bool): If set to False, the expiration date for the user will be
1286+
user_id: User ID to set an expiration date for.
1287+
use_delta: If set to False, the expiration date for the user will be
12881288
now + validity period. If set to True, this expiration date will be a
12891289
random value in the [now + period - d ; now + period] range, d being a
12901290
delta equal to 10% of the validity period.

synapse/types.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ def deserialize(
143143
Requester.
144144
145145
Args:
146-
store (DataStore): Used to convert AS ID to AS object
147-
input (dict): A dict produced by `serialize`
146+
store: Used to convert AS ID to AS object
147+
input: A dict produced by `serialize`
148148
149149
Returns:
150150
Requester

synapse/util/caches/deferred_cache.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def get(
153153
Args:
154154
key:
155155
callback: Gets called when the entry in the cache is invalidated
156-
update_metrics (bool): whether to update the cache hit rate metrics
156+
update_metrics: whether to update the cache hit rate metrics
157157
158158
Returns:
159159
A Deferred which completes with the result. Note that this may later fail

synapse/util/caches/lrucache.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -389,11 +389,11 @@ def __init__(
389389
cache_name: The name of this cache, for the prometheus metrics. If unset,
390390
no metrics will be reported on this cache.
391391
392-
cache_type (type):
392+
cache_type:
393393
type of underlying cache to be used. Typically one of dict
394394
or TreeCache.
395395
396-
size_callback (func(V) -> int | None):
396+
size_callback:
397397
398398
metrics_collection_callback:
399399
metrics collection callback. This is called early in the metrics
@@ -403,7 +403,7 @@ def __init__(
403403
404404
Ignored if cache_name is None.
405405
406-
apply_cache_factor_from_config (bool): If true, `max_size` will be
406+
apply_cache_factor_from_config: If true, `max_size` will be
407407
multiplied by a cache factor derived from the homeserver config
408408
409409
clock:

synapse/util/ratelimitutils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ def ratelimit(self, host: str) -> "_GeneratorContextManager[defer.Deferred[None]
183183
# Handle request ...
184184
185185
Args:
186-
host (str): Origin of incoming request.
186+
host: Origin of incoming request.
187187
188188
Returns:
189189
context manager which returns a deferred.

synapse/util/wheel_timer.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def fetch(self, now: int) -> List[T]:
9090
"""Fetch any objects that have timed out
9191
9292
Args:
93-
now (ms): Current time in msec
93+
now: Current time in msec
9494
9595
Returns:
9696
list: List of objects that have timed out

tests/replication/test_multi_media_repo.py

-2
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,6 @@ def _build_test_server(connection_creator):
246246
Args:
247247
connection_creator (IOpenSSLServerConnectionCreator): thing to build
248248
SSL connections
249-
sanlist (list[bytes]): list of the SAN entries for the cert returned
250-
by the server
251249
252250
Returns:
253251
TLSMemoryBIOProtocol

tests/server_notices/test_resource_limits_server_notices.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14+
from typing import Tuple
1415
from unittest.mock import Mock
1516

1617
from twisted.test.proto_helpers import MemoryReactor
@@ -350,14 +351,14 @@ def test_invite_with_notice(self):
350351

351352
self.assertTrue(notice_in_room, "No server notice in room")
352353

353-
def _trigger_notice_and_join(self):
354+
def _trigger_notice_and_join(self) -> Tuple[str, str, str]:
354355
"""Creates enough active users to hit the MAU limit and trigger a system notice
355356
about it, then joins the system notices room with one of the users created.
356357
357358
Returns:
358-
user_id (str): The ID of the user that joined the room.
359-
tok (str): The access token of the user that joined the room.
360-
room_id (str): The ID of the room that's been joined.
359+
user_id: The ID of the user that joined the room.
360+
tok: The access token of the user that joined the room.
361+
room_id: The ID of the room that's been joined.
361362
"""
362363
user_id = None
363364
tok = None

0 commit comments

Comments
 (0)