Skip to content

Commit 20de685

Browse files
Bump ruff from 0.3.7 to 0.5.0 (#17381)
1 parent 8e9e6f1 commit 20de685

File tree

13 files changed

+41
-36
lines changed

13 files changed

+41
-36
lines changed

.github/workflows/tests.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ jobs:
7373
- 'pyproject.toml'
7474
- 'poetry.lock'
7575
- '.github/workflows/tests.yml'
76-
76+
7777
linting_readme:
7878
- 'README.rst'
7979
@@ -139,7 +139,7 @@ jobs:
139139

140140
- name: Semantic checks (ruff)
141141
# --quiet suppresses the update check.
142-
run: poetry run ruff --quiet .
142+
run: poetry run ruff check --quiet .
143143

144144
lint-mypy:
145145
runs-on: ubuntu-latest

changelog.d/17381.misc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix linting errors from new `ruff` version.

poetry.lock

+20-19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ target-version = ['py38', 'py39', 'py310', 'py311']
4343
[tool.ruff]
4444
line-length = 88
4545

46+
[tool.ruff.lint]
4647
# See https://beta.ruff.rs/docs/rules/#error-e
4748
# for error codes. The ones we ignore are:
4849
# E501: Line too long (black enforces this for us)
@@ -321,7 +322,7 @@ all = [
321322
# This helps prevents merge conflicts when running a batch of dependabot updates.
322323
isort = ">=5.10.1"
323324
black = ">=22.7.0"
324-
ruff = "0.3.7"
325+
ruff = "0.5.0"
325326
# Type checking only works with the pydantic.v1 compat module from pydantic v2
326327
pydantic = "^2"
327328

scripts-dev/lint.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ python3 -m black "${files[@]}"
112112

113113
# Catch any common programming mistakes in Python code.
114114
# --quiet suppresses the update check.
115-
ruff --quiet --fix "${files[@]}"
115+
ruff check --quiet --fix "${files[@]}"
116116

117117
# Catch any common programming mistakes in Rust code.
118118
#

synapse/_scripts/generate_workers_map.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444

4545

4646
class MockHomeserver(HomeServer):
47-
DATASTORE_CLASS = DataStore # type: ignore
47+
DATASTORE_CLASS = DataStore
4848

4949
def __init__(self, config: HomeServerConfig, worker_app: Optional[str]) -> None:
5050
super().__init__(config.server.server_name, config=config)

synapse/_scripts/update_synapse_database.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242

4343
class MockHomeserver(HomeServer):
44-
DATASTORE_CLASS = DataStore # type: ignore [assignment]
44+
DATASTORE_CLASS = DataStore
4545

4646
def __init__(self, config: HomeServerConfig):
4747
super().__init__(

synapse/app/admin_cmd.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def __init__(
110110

111111

112112
class AdminCmdServer(HomeServer):
113-
DATASTORE_CLASS = AdminCmdStore # type: ignore
113+
DATASTORE_CLASS = AdminCmdStore
114114

115115

116116
async def export_data_command(hs: HomeServer, args: argparse.Namespace) -> None:

synapse/app/generic_worker.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ class GenericWorkerStore(
163163

164164

165165
class GenericWorkerServer(HomeServer):
166-
DATASTORE_CLASS = GenericWorkerStore # type: ignore
166+
DATASTORE_CLASS = GenericWorkerStore
167167

168168
def _listen_http(self, listener_config: ListenerConfig) -> None:
169169
assert listener_config.http_options is not None

synapse/app/homeserver.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def gz_wrap(r: Resource) -> Resource:
8181

8282

8383
class SynapseHomeServer(HomeServer):
84-
DATASTORE_CLASS = DataStore # type: ignore
84+
DATASTORE_CLASS = DataStore
8585

8686
def _listener_http(
8787
self,

synapse/federation/sender/per_destination_queue.py

-2
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,6 @@ def attempt_new_transaction(self) -> None:
322322
)
323323

324324
async def _transaction_transmission_loop(self) -> None:
325-
pending_pdus: List[EventBase] = []
326325
try:
327326
self.transmission_loop_running = True
328327

@@ -338,7 +337,6 @@ async def _transaction_transmission_loop(self) -> None:
338337
# not caught up yet
339338
return
340339

341-
pending_pdus = []
342340
while True:
343341
self._new_data_to_send = False
344342

synapse/server.py

+9-5
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import abc
2929
import functools
3030
import logging
31-
from typing import TYPE_CHECKING, Callable, Dict, List, Optional, TypeVar, cast
31+
from typing import TYPE_CHECKING, Callable, Dict, List, Optional, Type, TypeVar, cast
3232

3333
from typing_extensions import TypeAlias
3434

@@ -161,6 +161,7 @@
161161
from synapse.handlers.jwt import JwtHandler
162162
from synapse.handlers.oidc import OidcHandler
163163
from synapse.handlers.saml import SamlHandler
164+
from synapse.storage._base import SQLBaseStore
164165

165166

166167
# The annotation for `cache_in_self` used to be
@@ -255,10 +256,13 @@ class HomeServer(metaclass=abc.ABCMeta):
255256
"stats",
256257
]
257258

258-
# This is overridden in derived application classes
259-
# (such as synapse.app.homeserver.SynapseHomeServer) and gives the class to be
260-
# instantiated during setup() for future return by get_datastores()
261-
DATASTORE_CLASS = abc.abstractproperty()
259+
@property
260+
@abc.abstractmethod
261+
def DATASTORE_CLASS(self) -> Type["SQLBaseStore"]:
262+
# This is overridden in derived application classes
263+
# (such as synapse.app.homeserver.SynapseHomeServer) and gives the class to be
264+
# instantiated during setup() for future return by get_datastores()
265+
pass
262266

263267
def __init__(
264268
self,

tests/server.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -946,7 +946,7 @@ def connect_client(
946946

947947

948948
class TestHomeServer(HomeServer):
949-
DATASTORE_CLASS = DataStore # type: ignore[assignment]
949+
DATASTORE_CLASS = DataStore
950950

951951

952952
def setup_test_homeserver(

0 commit comments

Comments
 (0)