mirror of
https://github.com/kuhyx/utils.git
synced 2026-11-17 21:45:08 +01:00
The three Python packages pinned ruff twice at different versions: requirements.txt at 0.16.7, .pre-commit-config.yaml at v0.15.2. Only the older one ever ran, so `select = ["ALL"]` was enforced two minor versions behind. Measured before aligning: v0.15.2 reports 0 findings, every 0.16.x reports CPY001 on each file -- 70 crdt-sync, 23 freedays, 71 gatelock, and no other rule. Resolved by adding the notice rather than ignoring the rule, so the gate keeps its teeth. Two gatelock modules sat at exactly the 250-line cap, so a one-line header tipped them to 251. Both are split along a real seam rather than shaved: _widget_fills.py colour arithmetic over LockConfig, no tkinter import _surfaces_focus.py selects among existing surfaces, never mutates them The focus split keeps _surfaces.py's documented containment (it stays the only module that creates, moves or destroys windows), and the static guard in test_recovery_invariants.py globs _surfaces*.py, so the new sibling is covered with no list to extend. widgets.py re-exports the fills helpers, which keeps gatelock.widgets the single public surface its tests import. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019kMvSMtsVMB3d2uoZ56pbp
68 lines
2.0 KiB
Python
68 lines
2.0 KiB
Python
# Copyright (c) 2026 Krzysztof Rudnicki
|
|
"""Every file this package owns, as one value that can be swapped wholesale.
|
|
|
|
Threading five separate ``*_path`` keyword arguments through the API was the
|
|
first shape of this, and it had a specific failure mode: a test suite has to
|
|
redirect *every* one of them, and a module that starts importing a sixth
|
|
silently keeps writing to real user state while the suite still looks green.
|
|
That has happened before in this fleet and cost a live log file.
|
|
|
|
One bundle means one seam. ``Paths.under(tmp_path)`` redirects everything at
|
|
once, and a new file added to this class is redirected by construction
|
|
rather than by remembering to update a list somewhere else.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from dataclasses import dataclass
|
|
from typing import TYPE_CHECKING
|
|
|
|
from freedays._constants import (
|
|
AUDIT_PATH,
|
|
DEVICE_ID_PATH,
|
|
HMAC_KEY_FILE,
|
|
LOG_PATH,
|
|
SYNC_STATE_PATH,
|
|
)
|
|
|
|
if TYPE_CHECKING:
|
|
from pathlib import Path
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class Paths:
|
|
"""Where the pool, the device id, the audit trail and sync state live."""
|
|
|
|
log: Path
|
|
device_id: Path
|
|
audit: Path
|
|
hmac_key: Path
|
|
sync_state: Path
|
|
|
|
@classmethod
|
|
def default(cls) -> Paths:
|
|
"""The real, per-user locations under ``~/.local/share/freedays``."""
|
|
return cls(
|
|
log=LOG_PATH,
|
|
device_id=DEVICE_ID_PATH,
|
|
audit=AUDIT_PATH,
|
|
hmac_key=HMAC_KEY_FILE,
|
|
sync_state=SYNC_STATE_PATH,
|
|
)
|
|
|
|
@classmethod
|
|
def under(cls, directory: Path) -> Paths:
|
|
"""Every file, relocated under ``directory``. The test seam."""
|
|
return cls(
|
|
log=directory / "free_days.json",
|
|
device_id=directory / "device_id",
|
|
audit=directory / "audit.jsonl",
|
|
hmac_key=directory / "hmac.key",
|
|
sync_state=directory / "sync_state.json",
|
|
)
|
|
|
|
|
|
def resolve_paths(paths: Paths | None) -> Paths:
|
|
"""Return ``paths``, or the real locations when it is ``None``."""
|
|
return paths if paths is not None else Paths.default()
|