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

Commit aa483cb

Browse files
authored
Update ruff config (#16283)
Enable additional checks & clean-up unneeded configuration.
1 parent c1c6c95 commit aa483cb

File tree

26 files changed

+63
-64
lines changed

26 files changed

+63
-64
lines changed

changelog.d/16283.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Enable additional linting checks.

contrib/cmdclient/http.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ def put_json(self, url, data):
3737
Deferred: Succeeds when we get a 2xx HTTP response. The result
3838
will be the decoded JSON body.
3939
"""
40-
pass
4140

4241
def get_json(self, url, args=None):
4342
"""Gets some json from the given host homeserver and path
@@ -53,7 +52,6 @@ def get_json(self, url, args=None):
5352
Deferred: Succeeds when we get a 2xx HTTP response. The result
5453
will be the decoded JSON body.
5554
"""
56-
pass
5755

5856

5957
class TwistedHttpClient(HttpClient):

docker/start.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ def main(args: List[str], environ: MutableMapping[str, str]) -> None:
239239
log("Could not find %s, will not use" % (jemallocpath,))
240240

241241
# if there are no config files passed to synapse, try adding the default file
242-
if not any(p.startswith("--config-path") or p.startswith("-c") for p in args):
242+
if not any(p.startswith(("--config-path", "-c")) for p in args):
243243
config_dir = environ.get("SYNAPSE_CONFIG_DIR", "/data")
244244
config_path = environ.get(
245245
"SYNAPSE_CONFIG_PATH", config_dir + "/homeserver.yaml"

pyproject.toml

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,33 +43,39 @@ target-version = ['py38', 'py39', 'py310', 'py311']
4343
[tool.ruff]
4444
line-length = 88
4545

46-
# See https://github.com/charliermarsh/ruff/#pycodestyle
46+
# See https://beta.ruff.rs/docs/rules/#error-e
4747
# for error codes. The ones we ignore are:
48-
# E731: do not assign a lambda expression, use a def
4948
# E501: Line too long (black enforces this for us)
49+
# E731: do not assign a lambda expression, use a def
5050
#
5151
# flake8-bugbear compatible checks. Its error codes are described at
52-
# https://github.com/charliermarsh/ruff/#flake8-bugbear
53-
# B019: Use of functools.lru_cache or functools.cache on methods can lead to memory leaks
52+
# https://beta.ruff.rs/docs/rules/#flake8-bugbear-b
5453
# B023: Functions defined inside a loop must not use variables redefined in the loop
55-
# B024: Abstract base class with no abstract method.
5654
ignore = [
57-
"B019",
5855
"B023",
59-
"B024",
6056
"E501",
6157
"E731",
6258
]
6359
select = [
64-
# pycodestyle checks.
60+
# pycodestyle
6561
"E",
6662
"W",
67-
# pyflakes checks.
63+
# pyflakes
6864
"F",
69-
# flake8-bugbear checks.
65+
# flake8-bugbear
7066
"B0",
71-
# flake8-comprehensions checks.
67+
# flake8-comprehensions
7268
"C4",
69+
# flake8-2020
70+
"YTT",
71+
# flake8-slots
72+
"SLOT",
73+
# flake8-debugger
74+
"T10",
75+
# flake8-pie
76+
"PIE",
77+
# flake8-executable
78+
"EXE",
7379
]
7480

7581
[tool.isort]

scripts-dev/mypy_synapse_plugin.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@ def get_method_signature_hook(
3030
self, fullname: str
3131
) -> Optional[Callable[[MethodSigContext], CallableType]]:
3232
if fullname.startswith(
33-
"synapse.util.caches.descriptors.CachedFunction.__call__"
34-
) or fullname.startswith(
35-
"synapse.util.caches.descriptors._LruCachedFunction.__call__"
33+
(
34+
"synapse.util.caches.descriptors.CachedFunction.__call__",
35+
"synapse.util.caches.descriptors._LruCachedFunction.__call__",
36+
)
3637
):
3738
return cached_function_method_signature
3839
return None

synapse/_scripts/update_synapse_database.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#!/usr/bin/env python
21
# Copyright 2019 The Matrix.org Foundation C.I.C.
32
#
43
# Licensed under the Apache License, Version 2.0 (the "License");

synapse/events/snapshot.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ async def persist(
5555
A method to convert an UnpersistedEventContext to an EventContext, suitable for
5656
sending to the database with the associated event.
5757
"""
58-
pass
5958

6059
@abstractmethod
6160
async def get_prev_state_ids(
@@ -69,7 +68,6 @@ async def get_prev_state_ids(
6968
state_filter: specifies the type of state event to fetch from DB, example:
7069
EventTypes.JoinRules
7170
"""
72-
pass
7371

7472

7573
@attr.s(slots=True, auto_attribs=True)

synapse/media/url_previewer.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -846,9 +846,7 @@ def _is_media(content_type: str) -> bool:
846846

847847
def _is_html(content_type: str) -> bool:
848848
content_type = content_type.lower()
849-
return content_type.startswith("text/html") or content_type.startswith(
850-
"application/xhtml"
851-
)
849+
return content_type.startswith(("text/html", "application/xhtml"))
852850

853851

854852
def _is_json(content_type: str) -> bool:

synapse/storage/background_updates.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,13 @@ class Constraint(metaclass=abc.ABCMeta):
6262
@abc.abstractmethod
6363
def make_check_clause(self, table: str) -> str:
6464
"""Returns an SQL expression that checks the row passes the constraint."""
65-
pass
6665

6766
@abc.abstractmethod
6867
def make_constraint_clause_postgres(self) -> str:
6968
"""Returns an SQL clause for creating the constraint.
7069
7170
Only used on Postgres DBs
7271
"""
73-
pass
7472

7573

7674
@attr.s(auto_attribs=True)

synmark/suites/logging.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ class Config:
112112
start = perf_counter()
113113

114114
# Send a bunch of useful messages
115-
for i in range(0, loops):
115+
for i in range(loops):
116116
logger.info("test message %s", i)
117117

118118
if len(handler._buffer) == handler.maximum_buffer:

0 commit comments

Comments
 (0)