Skip to content

Commit

Permalink
Bump ruff from 0.3.7 to 0.5.0 (#17381)
Browse files Browse the repository at this point in the history
  • Loading branch information
dependabot[bot] committed Jul 5, 2024
1 parent 8e9e6f1 commit 20de685
Show file tree
Hide file tree
Showing 13 changed files with 41 additions and 36 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jobs:
- 'pyproject.toml'
- 'poetry.lock'
- '.github/workflows/tests.yml'
linting_readme:
- 'README.rst'
Expand Down Expand Up @@ -139,7 +139,7 @@ jobs:

- name: Semantic checks (ruff)
# --quiet suppresses the update check.
run: poetry run ruff --quiet .
run: poetry run ruff check --quiet .

lint-mypy:
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions changelog.d/17381.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix linting errors from new `ruff` version.
39 changes: 20 additions & 19 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ target-version = ['py38', 'py39', 'py310', 'py311']
[tool.ruff]
line-length = 88

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

Expand Down
2 changes: 1 addition & 1 deletion scripts-dev/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ python3 -m black "${files[@]}"

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

# Catch any common programming mistakes in Rust code.
#
Expand Down
2 changes: 1 addition & 1 deletion synapse/_scripts/generate_workers_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@


class MockHomeserver(HomeServer):
DATASTORE_CLASS = DataStore # type: ignore
DATASTORE_CLASS = DataStore

def __init__(self, config: HomeServerConfig, worker_app: Optional[str]) -> None:
super().__init__(config.server.server_name, config=config)
Expand Down
2 changes: 1 addition & 1 deletion synapse/_scripts/update_synapse_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@


class MockHomeserver(HomeServer):
DATASTORE_CLASS = DataStore # type: ignore [assignment]
DATASTORE_CLASS = DataStore

def __init__(self, config: HomeServerConfig):
super().__init__(
Expand Down
2 changes: 1 addition & 1 deletion synapse/app/admin_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def __init__(


class AdminCmdServer(HomeServer):
DATASTORE_CLASS = AdminCmdStore # type: ignore
DATASTORE_CLASS = AdminCmdStore


async def export_data_command(hs: HomeServer, args: argparse.Namespace) -> None:
Expand Down
2 changes: 1 addition & 1 deletion synapse/app/generic_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ class GenericWorkerStore(


class GenericWorkerServer(HomeServer):
DATASTORE_CLASS = GenericWorkerStore # type: ignore
DATASTORE_CLASS = GenericWorkerStore

def _listen_http(self, listener_config: ListenerConfig) -> None:
assert listener_config.http_options is not None
Expand Down
2 changes: 1 addition & 1 deletion synapse/app/homeserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def gz_wrap(r: Resource) -> Resource:


class SynapseHomeServer(HomeServer):
DATASTORE_CLASS = DataStore # type: ignore
DATASTORE_CLASS = DataStore

def _listener_http(
self,
Expand Down
2 changes: 0 additions & 2 deletions synapse/federation/sender/per_destination_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,6 @@ def attempt_new_transaction(self) -> None:
)

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

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

pending_pdus = []
while True:
self._new_data_to_send = False

Expand Down
14 changes: 9 additions & 5 deletions synapse/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import abc
import functools
import logging
from typing import TYPE_CHECKING, Callable, Dict, List, Optional, TypeVar, cast
from typing import TYPE_CHECKING, Callable, Dict, List, Optional, Type, TypeVar, cast

from typing_extensions import TypeAlias

Expand Down Expand Up @@ -161,6 +161,7 @@
from synapse.handlers.jwt import JwtHandler
from synapse.handlers.oidc import OidcHandler
from synapse.handlers.saml import SamlHandler
from synapse.storage._base import SQLBaseStore


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

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

def __init__(
self,
Expand Down
2 changes: 1 addition & 1 deletion tests/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,7 @@ def connect_client(


class TestHomeServer(HomeServer):
DATASTORE_CLASS = DataStore # type: ignore[assignment]
DATASTORE_CLASS = DataStore


def setup_test_homeserver(
Expand Down

0 comments on commit 20de685

Please sign in to comment.