Skip to content

Commit

Permalink
Update ruff to much newer version (#9433)
Browse files Browse the repository at this point in the history
Includes a multidict patch release to fix build with newer cpython.
  • Loading branch information
cloneable authored Oct 18, 2024
1 parent 98fee7a commit 15fecff
Show file tree
Hide file tree
Showing 10 changed files with 145 additions and 122 deletions.
207 changes: 112 additions & 95 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ kafka-python = "^2.0.2"

[tool.poetry.group.dev.dependencies]
mypy = "==1.3.0"
ruff = "^0.2.2"
ruff = "^0.7.0"

[build-system]
requires = ["poetry-core>=1.0.0"]
Expand Down
4 changes: 2 additions & 2 deletions test_runner/fixtures/neon_cli.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import annotations

import abc
import json
import os
import re
Expand Down Expand Up @@ -30,7 +29,8 @@
T = TypeVar("T")


class AbstractNeonCli(abc.ABC):
# Used to be an ABC. abc.ABC removed due to linter without name change.
class AbstractNeonCli:
"""
A typed wrapper around an arbitrary Neon CLI tool.
Supports a way to run arbitrary command directly via CLI.
Expand Down
18 changes: 9 additions & 9 deletions test_runner/fixtures/neon_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,9 +386,9 @@ def __init__(

self.pageserver_virtual_file_io_engine: Optional[str] = pageserver_virtual_file_io_engine

self.pageserver_default_tenant_config_compaction_algorithm: Optional[
dict[str, Any]
] = pageserver_default_tenant_config_compaction_algorithm
self.pageserver_default_tenant_config_compaction_algorithm: Optional[dict[str, Any]] = (
pageserver_default_tenant_config_compaction_algorithm
)
if self.pageserver_default_tenant_config_compaction_algorithm is not None:
log.debug(
f"Overriding pageserver default compaction algorithm to {self.pageserver_default_tenant_config_compaction_algorithm}"
Expand Down Expand Up @@ -1062,9 +1062,9 @@ def __init__(self, config: NeonEnvBuilder):
ps_cfg["virtual_file_io_engine"] = self.pageserver_virtual_file_io_engine
if config.pageserver_default_tenant_config_compaction_algorithm is not None:
tenant_config = ps_cfg.setdefault("tenant_config", {})
tenant_config[
"compaction_algorithm"
] = config.pageserver_default_tenant_config_compaction_algorithm
tenant_config["compaction_algorithm"] = (
config.pageserver_default_tenant_config_compaction_algorithm
)

if self.pageserver_remote_storage is not None:
ps_cfg["remote_storage"] = remote_storage_to_toml_dict(
Expand Down Expand Up @@ -1108,9 +1108,9 @@ def __init__(self, config: NeonEnvBuilder):
if config.auth_enabled:
sk_cfg["auth_enabled"] = True
if self.safekeepers_remote_storage is not None:
sk_cfg[
"remote_storage"
] = self.safekeepers_remote_storage.to_toml_inline_table().strip()
sk_cfg["remote_storage"] = (
self.safekeepers_remote_storage.to_toml_inline_table().strip()
)
self.safekeepers.append(
Safekeeper(env=self, id=id, port=port, extra_opts=config.safekeeper_extra_opts)
)
Expand Down
2 changes: 1 addition & 1 deletion test_runner/fixtures/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ def wait_until(
time.sleep(interval)
continue
return res
raise Exception("timed out while waiting for %s" % func) from last_exception
raise Exception(f"timed out while waiting for {func}") from last_exception


def assert_eq(a, b) -> None:
Expand Down
14 changes: 8 additions & 6 deletions test_runner/performance/test_logical_replication.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,10 @@ def test_subscriber_lag(
check_pgbench_still_running(pub_workload, "pub")
check_pgbench_still_running(sub_workload, "sub")

with psycopg2.connect(pub_connstr) as pub_conn, psycopg2.connect(
sub_connstr
) as sub_conn:
with (
psycopg2.connect(pub_connstr) as pub_conn,
psycopg2.connect(sub_connstr) as sub_conn,
):
with pub_conn.cursor() as pub_cur, sub_conn.cursor() as sub_cur:
lag = measure_logical_replication_lag(sub_cur, pub_cur)

Expand Down Expand Up @@ -242,9 +243,10 @@ def test_publisher_restart(
["pgbench", "-c10", pgbench_duration, "-Mprepared"],
env=pub_env,
)
with psycopg2.connect(pub_connstr) as pub_conn, psycopg2.connect(
sub_connstr
) as sub_conn:
with (
psycopg2.connect(pub_connstr) as pub_conn,
psycopg2.connect(sub_connstr) as sub_conn,
):
with pub_conn.cursor() as pub_cur, sub_conn.cursor() as sub_cur:
lag = measure_logical_replication_lag(sub_cur, pub_cur)

Expand Down
12 changes: 8 additions & 4 deletions test_runner/performance/test_physical_replication.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,14 @@ def test_ro_replica_lag(
check_pgbench_still_running(master_workload)
check_pgbench_still_running(replica_workload)
time.sleep(sync_interval_min * 60)
with psycopg2.connect(master_connstr) as conn_master, psycopg2.connect(
replica_connstr
) as conn_replica:
with conn_master.cursor() as cur_master, conn_replica.cursor() as cur_replica:
with (
psycopg2.connect(master_connstr) as conn_master,
psycopg2.connect(replica_connstr) as conn_replica,
):
with (
conn_master.cursor() as cur_master,
conn_replica.cursor() as cur_replica,
):
lag = measure_replication_lag(cur_master, cur_replica)
log.info(f"Replica lagged behind master by {lag} seconds")
zenbenchmark.record("replica_lag", lag, "s", MetricReport.LOWER_IS_BETTER)
Expand Down
2 changes: 1 addition & 1 deletion test_runner/regress/test_download_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def endpoint_handler_build_tag(request: Request) -> Response:
mimetype="application/octet-stream",
headers=[
("Content-Length", str(file_size)),
("Content-Disposition", 'attachment; filename="%s"' % file_name),
("Content-Disposition", f'attachment; filename="{file_name}"'),
],
direct_passthrough=True,
)
Expand Down
4 changes: 2 additions & 2 deletions test_runner/regress/test_next_xid.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,13 +254,13 @@ def advance_multixid_to(
# missing. That's OK for our purposes. Autovacuum will print some warnings about the
# missing segments, but will clean it up by truncating the SLRUs up to the new value,
# closing the gap.
segname = "%04X" % MultiXactIdToOffsetSegment(next_multi_xid)
segname = f"{MultiXactIdToOffsetSegment(next_multi_xid):04X}"
log.info(f"Creating dummy segment pg_multixact/offsets/{segname}")
with open(vanilla_pg.pgdatadir / "pg_multixact" / "offsets" / segname, "w") as of:
of.write("\0" * SLRU_PAGES_PER_SEGMENT * BLCKSZ)
of.flush()

segname = "%04X" % MXOffsetToMemberSegment(next_multi_offset)
segname = f"{MXOffsetToMemberSegment(next_multi_offset):04X}"
log.info(f"Creating dummy segment pg_multixact/members/{segname}")
with open(vanilla_pg.pgdatadir / "pg_multixact" / "members" / segname, "w") as of:
of.write("\0" * SLRU_PAGES_PER_SEGMENT * BLCKSZ)
Expand Down
2 changes: 1 addition & 1 deletion test_runner/regress/test_timeline_delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ def test_timeline_delete_works_for_remote_smoke(
env = neon_env_builder.init_start()

ps_http = env.pageserver.http_client()
pg = env.endpoints.create_start("main")
env.endpoints.create_start("main")

tenant_id = env.initial_tenant
timeline_id = env.initial_timeline
Expand Down

1 comment on commit 15fecff

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5308 tests run: 5083 passed, 1 failed, 224 skipped (full report)


Failures on Postgres 16

  • test_storage_controller_many_tenants[github-actions-selfhosted]: release-x86-64
# Run all failed tests locally:
scripts/pytest -vv -n $(nproc) -k "test_storage_controller_many_tenants[release-pg16-github-actions-selfhosted]"
Flaky tests (2)

Postgres 17

Code coverage* (full report)

  • functions: 31.3% (7566 of 24162 functions)
  • lines: 48.9% (59905 of 122585 lines)

* collected from Rust tests only


The comment gets automatically updated with the latest test results
15fecff at 2024-10-18T12:45:39.014Z :recycle:

Please sign in to comment.