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

Commit bd4d958

Browse files
Bump ruff from 0.0.252 to 0.0.259 (#15328)
* Bump ruff from 0.0.252 to 0.0.259 Bumps [ruff](https://github.com/charliermarsh/ruff) from 0.0.252 to 0.0.259. - [Release notes](https://github.com/charliermarsh/ruff/releases) - [Changelog](https://github.com/charliermarsh/ruff/blob/main/BREAKING_CHANGES.md) - [Commits](astral-sh/ruff@v0.0.252...v0.0.259) --- updated-dependencies: - dependency-name: ruff dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> * Fix new warnings * Mypy * Newsfile --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Erik Johnston <[email protected]>
1 parent 96f163d commit bd4d958

File tree

12 files changed

+54
-35
lines changed

12 files changed

+54
-35
lines changed

changelog.d/15328.misc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Bump ruff from 0.0.252 to 0.0.259.

poetry.lock

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

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ all = [
311311
# We pin black so that our tests don't start failing on new releases.
312312
isort = ">=5.10.1"
313313
black = ">=22.3.0"
314-
ruff = "0.0.252"
314+
ruff = "0.0.259"
315315

316316
# Typechecking
317317
mypy = "*"

synapse/events/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ def __init__(
462462
# Signatures is a dict of dicts, and this is faster than doing a
463463
# copy.deepcopy
464464
signatures = {
465-
name: {sig_id: sig for sig_id, sig in sigs.items()}
465+
name: dict(sigs.items())
466466
for name, sigs in event_dict.pop("signatures", {}).items()
467467
}
468468

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

synapse/events/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ def serialize_event(
355355
time_now_ms = int(time_now_ms)
356356

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

360360
d["event_id"] = e.event_id
361361

synapse/storage/database.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1504,8 +1504,8 @@ def simple_upsert_many_txn_emulated(
15041504
self.engine.lock_table(txn, "user_ips")
15051505

15061506
for keyv, valv in zip(key_values, value_values):
1507-
_keys = {x: y for x, y in zip(key_names, keyv)}
1508-
_vals = {x: y for x, y in zip(value_names, valv)}
1507+
_keys = dict(zip(key_names, keyv))
1508+
_vals = dict(zip(value_names, valv))
15091509

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

synapse/storage/databases/main/events.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
Optional,
2828
Set,
2929
Tuple,
30+
cast,
3031
)
3132

3233
import attr
@@ -1348,9 +1349,7 @@ def _update_outliers_txn(
13481349
[event.event_id for event, _ in events_and_contexts],
13491350
)
13501351

1351-
have_persisted: Dict[str, bool] = {
1352-
event_id: outlier for event_id, outlier in txn
1353-
}
1352+
have_persisted = dict(cast(Iterable[Tuple[str, bool]], txn))
13541353

13551354
logger.debug(
13561355
"_update_outliers_txn: events=%s have_persisted=%s",

synapse/storage/databases/main/pusher.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ async def _set_device_id_for_pushers(
518518
def set_device_id_for_pushers_txn(txn: LoggingTransaction) -> int:
519519
txn.execute(
520520
"""
521-
SELECT
521+
SELECT
522522
p.id AS pusher_id,
523523
p.device_id AS pusher_device_id,
524524
at.device_id AS token_device_id

synapse/storage/databases/main/stats.py

+12-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,17 @@
1616
import logging
1717
from enum import Enum
1818
from itertools import chain
19-
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union, cast
19+
from typing import (
20+
TYPE_CHECKING,
21+
Any,
22+
Dict,
23+
Iterable,
24+
List,
25+
Optional,
26+
Tuple,
27+
Union,
28+
cast,
29+
)
2030

2131
from typing_extensions import Counter
2232

@@ -523,7 +533,7 @@ def _fetch_current_state_stats(
523533
""",
524534
(room_id,),
525535
)
526-
membership_counts = {membership: cnt for membership, cnt in txn}
536+
membership_counts = dict(cast(Iterable[Tuple[str, int]], txn))
527537

528538
txn.execute(
529539
"""

synapse/storage/databases/main/stream.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
Any,
4242
Collection,
4343
Dict,
44+
Iterable,
4445
List,
4546
Optional,
4647
Set,
@@ -1343,7 +1344,9 @@ def _reset_federation_positions_txn(self, txn: LoggingTransaction) -> None:
13431344
GROUP BY type
13441345
"""
13451346
txn.execute(sql)
1346-
min_positions = {typ: pos for typ, pos in txn} # Map from type -> min position
1347+
min_positions = dict(
1348+
cast(Iterable[Tuple[str, int]], txn)
1349+
) # Map from type -> min position
13471350

13481351
# Ensure we do actually have some values here
13491352
assert set(min_positions) == {"federation", "events"}

tests/replication/slave/storage/test_events.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ def build_event(
412412
self.get_success(
413413
self.master_store.add_push_actions_to_staging(
414414
event.event_id,
415-
{user_id: actions for user_id, actions in push_actions},
415+
dict(push_actions),
416416
False,
417417
"main",
418418
)

tests/server.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -983,15 +983,21 @@ def cleanup() -> None:
983983
dropped = True
984984
except psycopg2.OperationalError as e:
985985
warnings.warn(
986-
"Couldn't drop old db: " + str(e), category=UserWarning
986+
"Couldn't drop old db: " + str(e),
987+
category=UserWarning,
988+
stacklevel=2,
987989
)
988990
time.sleep(0.5)
989991

990992
cur.close()
991993
db_conn.close()
992994

993995
if not dropped:
994-
warnings.warn("Failed to drop old DB.", category=UserWarning)
996+
warnings.warn(
997+
"Failed to drop old DB.",
998+
category=UserWarning,
999+
stacklevel=2,
1000+
)
9951001

9961002
if not LEAVE_DB:
9971003
# Register the cleanup hook

0 commit comments

Comments
 (0)