Skip to content

Commit 9272d23

Browse files
Lock file maintenance Python dependencies (16/edge) (#907)
* Lock file maintenance Python dependencies * Add a separate pyproj for libs --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Dragomir Penev <[email protected]>
1 parent e480c99 commit 9272d23

File tree

15 files changed

+626
-486
lines changed

15 files changed

+626
-486
lines changed

lib/charms/postgresql_k8s/v0/postgresql.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
# Increment this PATCH version before using `charmcraft publish-lib` or reset
3737
# to 0 if you are raising the major API version
38-
LIBPATCH = 50
38+
LIBPATCH = 51
3939

4040
# Groups to distinguish HBA access
4141
ACCESS_GROUP_IDENTITY = "identity_access"
@@ -258,7 +258,7 @@ def create_database(
258258
raise PostgreSQLCreateDatabaseError() from e
259259

260260
# Enable preset extensions
261-
self.enable_disable_extensions({plugin: True for plugin in plugins}, database)
261+
self.enable_disable_extensions(dict.fromkeys(plugins, True), database)
262262

263263
def create_user(
264264
self,

lib/pyproject.toml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Copyright 2021 Canonical Ltd.
2+
# See LICENSE file for licensing details.
3+
4+
# Linting tools configuration
5+
[tool.ruff]
6+
# preview and explicit preview are enabled for CPY001
7+
preview = true
8+
target-version = "py38"
9+
src = [".."]
10+
line-length = 99
11+
12+
[tool.ruff.lint]
13+
explicit-preview-rules = true
14+
select = ["A", "E", "W", "F", "C", "N", "D", "I001", "B", "CPY001", "RUF", "S", "SIM", "UP", "TC"]
15+
# Ignore E501 because using black creates errors with this
16+
# Ignore D107 Missing docstring in __init__
17+
ignore = ["E501", "D107"]
18+
19+
[tool.ruff.lint.flake8-copyright]
20+
# Check for properly formatted copyright header in each file
21+
author = "Canonical Ltd."
22+
notice-rgx = "Copyright\\s\\d{4}([-,]\\d{4})*\\s+"
23+
min-file-size = 1
24+
25+
[tool.ruff.lint.mccabe]
26+
max-complexity = 10
27+
28+
[tool.ruff.lint.pydocstyle]
29+
convention = "google"

poetry.lock

Lines changed: 524 additions & 424 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ requires-poetry = ">=2.0.0"
77

88
[tool.poetry.dependencies]
99
python = "^3.10"
10-
ops = "^2.18.1"
11-
boto3 = "^1.37.22"
10+
ops = "^2.20.0"
11+
boto3 = "^1.37.37"
1212
pgconnstr = "^1.0.1"
1313
requests = "^2.32.3"
14-
tenacity = "^9.0.0"
14+
tenacity = "^9.1.2"
1515
pydantic = "^1.10.21"
16-
jinja2 = "^3.1.5"
16+
jinja2 = "^3.1.6"
1717
lightkube = "^0.17.1"
1818
lightkube-models = "^1.28.1.4"
1919
psycopg2 = "^2.9.10"
@@ -40,7 +40,7 @@ jsonschema = "*"
4040
optional = true
4141

4242
[tool.poetry.group.format.dependencies]
43-
ruff = "^0.9.6"
43+
ruff = "^0.11.6"
4444

4545
[tool.poetry.group.lint]
4646
optional = true
@@ -52,23 +52,23 @@ codespell = "^2.4.1"
5252
optional = true
5353

5454
[tool.poetry.group.unit.dependencies]
55-
coverage = {extras = ["toml"], version = "^7.6.12"}
56-
pytest = "^8.3.4"
55+
coverage = {extras = ["toml"], version = "^7.8.0"}
56+
pytest = "^8.3.5"
5757

5858
[tool.poetry.group.integration]
5959
optional = true
6060

6161
[tool.poetry.group.integration.dependencies]
6262
lightkube = "^0.17.1"
63-
pytest = "^8.3.4"
64-
pytest-operator = "^0.40.0"
63+
pytest = "^8.3.5"
64+
pytest-operator = "^0.42.0"
6565
allure-pytest-default-results = "^0.1.2"
6666
# renovate caret doesn't work: https://github.com/renovatebot/renovate/issues/26940
67-
juju = "<=3.6.1.0"
67+
juju = "<=3.6.1.1"
6868
psycopg2-binary = "^2.9.10"
6969
boto3 = "*"
70-
tenacity = "^9.0.0"
71-
allure-pytest = "^2.13.5"
70+
tenacity = "^9.1.2"
71+
allure-pytest = "^2.14.0"
7272

7373
[build-system]
7474
requires = ["poetry-core>=1.0.0"]
@@ -90,22 +90,17 @@ log_cli_level = "INFO"
9090
asyncio_mode = "auto"
9191
markers = ["juju3", "juju_secrets"]
9292

93-
# Formatting tools configuration
94-
[tool.black]
95-
line-length = 99
96-
target-version = ["py38"]
97-
9893
# Linting tools configuration
9994
[tool.ruff]
10095
# preview and explicit preview are enabled for CPY001
10196
preview = true
102-
target-version = "py38"
97+
target-version = "py310"
10398
src = ["src", "."]
10499
line-length = 99
105100

106101
[tool.ruff.lint]
107102
explicit-preview-rules = true
108-
select = ["A", "E", "W", "F", "C", "N", "D", "I001", "B", "CPY", "RUF", "S", "SIM", "UP", "TC"]
103+
select = ["A", "E", "W", "F", "C", "N", "D", "I001", "B", "CPY001", "RUF", "S", "SIM", "UP", "TC"]
109104
extend-ignore = [
110105
"D203",
111106
"D204",

scripts/rotate_logs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def main():
1111
"""Main loop that calls logrotate."""
1212
while True:
1313
# Command is hardcoded
14-
subprocess.run(["/usr/sbin/logrotate", "-f", "/etc/logrotate.d/pgbackrest.logrotate"]) # noqa: S603
14+
subprocess.run(["/usr/sbin/logrotate", "-f", "/etc/logrotate.d/pgbackrest.logrotate"])
1515

1616
# Wait 60 seconds before executing logrotate again.
1717
time.sleep(60)

src/backups.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ def _create_bucket_if_not_exists(self) -> None:
273273
def _empty_data_files(self) -> None:
274274
"""Empty the PostgreSQL data directory in preparation of backup restore."""
275275
try:
276-
self.container.exec("rm -r /var/lib/postgresql/data/pgdata".split()).wait_output()
276+
self.container.exec(["rm", "-r", "/var/lib/postgresql/data/pgdata"]).wait_output()
277277
except ExecError as e:
278278
# If previous PITR restore was unsuccessful, there is no such directory.
279279
if "No such file or directory" not in e.stderr:

tests/integration/ha_tests/helpers.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -352,9 +352,10 @@ async def count_writes(
352352
member_name = f"{member['model']}.{member['name']}"
353353
connection = None
354354
try:
355-
with psycopg2.connect(
356-
connection_string
357-
) as connection, connection.cursor() as cursor:
355+
with (
356+
psycopg2.connect(connection_string) as connection,
357+
connection.cursor() as cursor,
358+
):
358359
cursor.execute("SELECT COUNT(number), MAX(number) FROM continuous_writes;")
359360
results = cursor.fetchone()
360361
count[member_name] = results[0]
@@ -589,9 +590,10 @@ async def is_connection_possible(ops_test: OpsTest, unit_name: str) -> bool:
589590
)
590591
address = await asyncio.wait_for(get_unit_address(ops_test, unit_name), 15)
591592

592-
with db_connect(
593-
host=address, password=password
594-
) as connection, connection.cursor() as cursor:
593+
with (
594+
db_connect(host=address, password=password) as connection,
595+
connection.cursor() as cursor,
596+
):
595597
cursor.execute("SELECT 1;")
596598
success = cursor.fetchone()[0] == 1
597599
connection.close()
@@ -791,9 +793,11 @@ async def is_secondary_up_to_date(ops_test: OpsTest, unit_name: str, expected_wr
791793

792794
try:
793795
for attempt in Retrying(stop=stop_after_delay(60 * 3), wait=wait_fixed(3)):
794-
with attempt, psycopg2.connect(
795-
connection_string
796-
) as connection, connection.cursor() as cursor:
796+
with (
797+
attempt,
798+
psycopg2.connect(connection_string) as connection,
799+
connection.cursor() as cursor,
800+
):
797801
cursor.execute("SELECT COUNT(number), MAX(number) FROM continuous_writes;")
798802
results = cursor.fetchone()
799803
if results[0] != expected_writes or results[1] != expected_writes:

tests/integration/ha_tests/test_replication.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,10 @@ async def test_no_data_replicated_between_clusters(
125125
for unit in ops_test.model.applications[new_cluster_app].units:
126126
address = await get_unit_address(ops_test, unit.name)
127127
try:
128-
with db_connect(
129-
host=address, password=password
130-
) as connection, connection.cursor() as cursor:
128+
with (
129+
db_connect(host=address, password=password) as connection,
130+
connection.cursor() as cursor,
131+
):
131132
cursor.execute(
132133
"SELECT EXISTS (SELECT FROM information_schema.tables"
133134
" WHERE table_schema = 'public' AND table_name = 'continuous_writes');"

tests/integration/helpers.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -344,10 +344,13 @@ async def execute_query_on_unit(
344344
The result of the query.
345345
"""
346346
extra_connection_parameters = f" sslmode={sslmode}" if sslmode is not None else ""
347-
with psycopg2.connect(
348-
f"dbname='{database}' user='operator' host='{unit_address}'"
349-
f"password='{password}' connect_timeout=10{extra_connection_parameters}"
350-
) as connection, connection.cursor() as cursor:
347+
with (
348+
psycopg2.connect(
349+
f"dbname='{database}' user='operator' host='{unit_address}'"
350+
f"password='{password}' connect_timeout=10{extra_connection_parameters}"
351+
) as connection,
352+
connection.cursor() as cursor,
353+
):
351354
cursor.execute(query)
352355
output = list(itertools.chain(*cursor.fetchall()))
353356
return output

tests/integration/new_relations/test_relations_coherence.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,10 @@ async def test_relations(ops_test: OpsTest, charm):
131131
connection = None
132132
should_fail = database == DATABASE_DEFAULT_NAME
133133
try:
134-
with psycopg2.connect(
135-
connection_string
136-
) as connection, connection.cursor() as cursor:
134+
with (
135+
psycopg2.connect(connection_string) as connection,
136+
connection.cursor() as cursor,
137+
):
137138
cursor.execute("SELECT data FROM test;")
138139
data = cursor.fetchone()
139140
assert data[0] == "some data"

0 commit comments

Comments
 (0)