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

Bump ruff from 0.0.252 to 0.0.259 #15328

Merged
merged 4 commits into from
Mar 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/15328.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Bump ruff from 0.0.252 to 0.0.259.
38 changes: 19 additions & 19 deletions poetry.lock

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

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ all = [
# We pin black so that our tests don't start failing on new releases.
isort = ">=5.10.1"
black = ">=22.3.0"
ruff = "0.0.252"
ruff = "0.0.259"

# Typechecking
mypy = "*"
Expand Down
4 changes: 2 additions & 2 deletions synapse/events/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ def __init__(
# Signatures is a dict of dicts, and this is faster than doing a
# copy.deepcopy
signatures = {
name: {sig_id: sig for sig_id, sig in sigs.items()}
name: dict(sigs.items())
for name, sigs in event_dict.pop("signatures", {}).items()
}

Expand Down Expand Up @@ -510,7 +510,7 @@ def __init__(
# Signatures is a dict of dicts, and this is faster than doing a
# copy.deepcopy
signatures = {
name: {sig_id: sig for sig_id, sig in sigs.items()}
name: dict(sigs.items())
for name, sigs in event_dict.pop("signatures", {}).items()
}

Expand Down
2 changes: 1 addition & 1 deletion synapse/events/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ def serialize_event(
time_now_ms = int(time_now_ms)

# Should this strip out None's?
d = {k: v for k, v in e.get_dict().items()}
d = dict(e.get_dict().items())

d["event_id"] = e.event_id

Expand Down
4 changes: 2 additions & 2 deletions synapse/storage/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -1504,8 +1504,8 @@ def simple_upsert_many_txn_emulated(
self.engine.lock_table(txn, "user_ips")

for keyv, valv in zip(key_values, value_values):
_keys = {x: y for x, y in zip(key_names, keyv)}
_vals = {x: y for x, y in zip(value_names, valv)}
_keys = dict(zip(key_names, keyv))
_vals = dict(zip(value_names, valv))

self.simple_upsert_txn_emulated(txn, table, _keys, _vals, lock=False)

Expand Down
5 changes: 2 additions & 3 deletions synapse/storage/databases/main/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
Optional,
Set,
Tuple,
cast,
)

import attr
Expand Down Expand Up @@ -1348,9 +1349,7 @@ def _update_outliers_txn(
[event.event_id for event, _ in events_and_contexts],
)

have_persisted: Dict[str, bool] = {
event_id: outlier for event_id, outlier in txn
}
have_persisted = dict(cast(Iterable[Tuple[str, bool]], txn))

logger.debug(
"_update_outliers_txn: events=%s have_persisted=%s",
Expand Down
2 changes: 1 addition & 1 deletion synapse/storage/databases/main/pusher.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ async def _set_device_id_for_pushers(
def set_device_id_for_pushers_txn(txn: LoggingTransaction) -> int:
txn.execute(
"""
SELECT
SELECT
p.id AS pusher_id,
p.device_id AS pusher_device_id,
at.device_id AS token_device_id
Expand Down
14 changes: 12 additions & 2 deletions synapse/storage/databases/main/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,17 @@
import logging
from enum import Enum
from itertools import chain
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union, cast
from typing import (
TYPE_CHECKING,
Any,
Dict,
Iterable,
List,
Optional,
Tuple,
Union,
cast,
)

from typing_extensions import Counter

Expand Down Expand Up @@ -523,7 +533,7 @@ def _fetch_current_state_stats(
""",
(room_id,),
)
membership_counts = {membership: cnt for membership, cnt in txn}
membership_counts = dict(cast(Iterable[Tuple[str, int]], txn))

txn.execute(
"""
Expand Down
5 changes: 4 additions & 1 deletion synapse/storage/databases/main/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
Any,
Collection,
Dict,
Iterable,
List,
Optional,
Set,
Expand Down Expand Up @@ -1343,7 +1344,9 @@ def _reset_federation_positions_txn(self, txn: LoggingTransaction) -> None:
GROUP BY type
"""
txn.execute(sql)
min_positions = {typ: pos for typ, pos in txn} # Map from type -> min position
min_positions = dict(
cast(Iterable[Tuple[str, int]], txn)
) # Map from type -> min position

# Ensure we do actually have some values here
assert set(min_positions) == {"federation", "events"}
Expand Down
2 changes: 1 addition & 1 deletion tests/replication/slave/storage/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ def build_event(
self.get_success(
self.master_store.add_push_actions_to_staging(
event.event_id,
{user_id: actions for user_id, actions in push_actions},
dict(push_actions),
False,
"main",
)
Expand Down
10 changes: 8 additions & 2 deletions tests/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -983,15 +983,21 @@ def cleanup() -> None:
dropped = True
except psycopg2.OperationalError as e:
warnings.warn(
"Couldn't drop old db: " + str(e), category=UserWarning
"Couldn't drop old db: " + str(e),
category=UserWarning,
stacklevel=2,
)
time.sleep(0.5)

cur.close()
db_conn.close()

if not dropped:
warnings.warn("Failed to drop old DB.", category=UserWarning)
warnings.warn(
"Failed to drop old DB.",
category=UserWarning,
stacklevel=2,
)

if not LEAVE_DB:
# Register the cleanup hook
Expand Down