style!: adopt the core lint bar and migrate to it

The package carried no ruff configuration at all, so it ran on the defaults (E4+E7+E9+F) while infinito-nexus-core, its only consumer, holds itself to a far wider selection. Measured against that selection this tree had 224 findings. It now has none.

The selector list is core's verbatim so both repositories answer to one bar. target-version stays py39 rather than core's py311, because requires-python still declares >=3.9 and pyupgrade would otherwise propose syntax the declared minimum cannot run. Every ignore carries its reason: S603/S607 in particular, since running docker and dump binaries from PATH in list form is this tool's whole job and is already injection-safe.

Two conversions are judgement rather than mechanics. os.path.join(dir, '') was the rsync idiom for a trailing separator, which Path drops, so it becomes an explicit os.sep. os.path.abspath stays where Path.resolve() would follow symlinks and let a symlinked volume test as inside the snapshot subject.

BREAKING CHANGE: VersionMismatch is renamed VersionMismatchError.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-08-18 01:51:18 +02:00
parent 94637c32aa
commit efcfe88e7f
18 changed files with 157 additions and 91 deletions

View File

@@ -3,7 +3,10 @@
from __future__ import annotations
import shutil
from pathlib import Path
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from pathlib import Path
def touch(p: Path) -> None:

View File

@@ -1,8 +1,8 @@
import io
import os
import tempfile
import unittest
from contextlib import redirect_stderr
from pathlib import Path
import pandas as pd
@@ -15,7 +15,7 @@ EXPECTED_COLUMNS = ["instance", "database", "username", "password"]
class TestLoadDatabasesDf(unittest.TestCase):
def test_missing_csv_is_handled_with_warning_and_empty_df(self) -> None:
with tempfile.TemporaryDirectory() as td:
missing_path = os.path.join(td, "does-not-exist.csv")
missing_path = str(Path(td) / "does-not-exist.csv")
buf = io.StringIO()
with redirect_stderr(buf):
@@ -31,8 +31,8 @@ class TestLoadDatabasesDf(unittest.TestCase):
def test_empty_csv_is_handled_with_warning_and_empty_df(self) -> None:
with tempfile.TemporaryDirectory() as td:
empty_path = os.path.join(td, "databases.csv")
with open(empty_path, "w", encoding="utf-8") as f:
empty_path = Path(td) / "databases.csv"
with empty_path.open("w", encoding="utf-8") as f:
f.write("")
buf = io.StringIO()
@@ -49,10 +49,10 @@ class TestLoadDatabasesDf(unittest.TestCase):
def test_valid_csv_loads_without_warning(self) -> None:
with tempfile.TemporaryDirectory() as td:
csv_path = os.path.join(td, "databases.csv")
csv_path = Path(td) / "databases.csv"
content = "instance;database;username;password\nmyapp;*;dbuser;secret\n"
with open(csv_path, "w", encoding="utf-8") as f:
with csv_path.open("w", encoding="utf-8") as f:
f.write(content)
buf = io.StringIO()

View File

@@ -2,15 +2,13 @@ import tempfile
import unittest
from unittest.mock import patch
import pandas
import pandas as pd
from baudolo.backup import db as db_mod
def _df(rows):
return pandas.DataFrame(
rows, columns=["instance", "database", "username", "password"]
)
return pd.DataFrame(rows, columns=["instance", "database", "username", "password"])
def _capture_dumps(*, db_type, rows, container, dump_tool="mariadb-dump"):

View File

@@ -10,6 +10,7 @@ from __future__ import annotations
import os
import tempfile
import unittest
from pathlib import Path
from unittest import mock
from baudolo.backup.snapshot import SnapshotError, snapshot_source, unsnapshotted
@@ -19,8 +20,8 @@ from baudolo.backup.volume import Backing
class TestUnsnapshotted(unittest.TestCase):
def setUp(self) -> None:
self.subject = tempfile.mkdtemp()
self.mountpoint = os.path.join(self.subject, "volumes", "app", "_data")
os.makedirs(self.mountpoint)
self.mountpoint = str(Path(self.subject) / "volumes" / "app" / "_data")
Path(self.mountpoint).mkdir(parents=True)
def backing(self, **kwargs) -> Backing:
return Backing(kwargs.pop("mountpoint", self.mountpoint), **kwargs)
@@ -71,7 +72,7 @@ class TestUnsnapshotted(unittest.TestCase):
def test_an_unreadable_mountpoint_is_not(self) -> None:
reason = unsnapshotted(
self.backing(mountpoint=os.path.join(self.subject, "gone")), self.subject
self.backing(mountpoint=str(Path(self.subject) / "gone")), self.subject
)
self.assertIn("could not be read", reason)
@@ -79,12 +80,12 @@ class TestUnsnapshotted(unittest.TestCase):
class TestSnapshotSource(unittest.TestCase):
def setUp(self) -> None:
self.subject = tempfile.mkdtemp()
self.mountpoint = os.path.join(self.subject, "volumes", "app", "_data")
os.makedirs(self.mountpoint)
self.snapshot = os.path.join(
self.subject, ".baudolo-tag", "volumes", "app", "_data"
self.mountpoint = str(Path(self.subject) / "volumes" / "app" / "_data")
Path(self.mountpoint).mkdir(parents=True)
self.snapshot = str(
Path(self.subject) / ".baudolo-tag" / "volumes" / "app" / "_data"
)
os.makedirs(self.snapshot)
Path(self.snapshot).mkdir(parents=True)
self.backing = Backing(self.mountpoint)
def test_a_captured_volume_reads_from_the_snapshot(self) -> None:
@@ -114,7 +115,7 @@ class TestSnapshotSource(unittest.TestCase):
def test_a_volume_created_after_the_snapshot_degrades(self) -> None:
source, reason = snapshot_source(
lambda path: os.path.join(self.subject, "absent") + "/",
lambda path: str(Path(self.subject) / "absent") + "/",
self.backing,
self.subject,
)