mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2026-11-06 21:02:04 +00:00
style: satisfy the black gate that was failing the Tests workflow
The Tests workflow was red on every OS and Python version for one reason:
`black --check` found 28 unformatted files. Part predates this branch (the
tui_v3 screens, core/api.py, core/index0.py); part is mine from this session.
Formatting only — verified rather than assumed, because a formatter touching
363 files is exactly where an unnoticed behaviour change would hide:
- 1223 Python tests pass, unchanged
- regenerating the fixtures after reformatting the generator produces
byte-identical output, so no hashed value moved
- differential fuzz: no divergences
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Vtx94nXDmNgXEeThUZP4QN
This commit is contained in:
1 parent
71db3bc498
commit
3395aadd1c
32 files changed
+686
-249
No files matched your search
@@ -15,7 +15,9 @@ from seedpass.core.config_manager import ConfigManager
|
||||
|
||||
|
||||
class FakePasswordGenerator:
|
||||
def generate_password(self, length: int, index: int, gen_version: int = 1) -> str: # noqa: D401
|
||||
def generate_password(
|
||||
self, length: int, index: int, gen_version: int = 1
|
||||
) -> str: # noqa: D401
|
||||
return "pw"
|
||||
|
||||
|
||||
|
||||
@@ -7,7 +7,9 @@ sys.path.append(str(Path(__file__).resolve().parents[1]))
|
||||
|
||||
def test_retrieve_entry_shows_custom_fields(monkeypatch, capsys, password_manager):
|
||||
pm = password_manager
|
||||
pm.password_generator = SimpleNamespace(generate_password=lambda l, i, gen_version=1: "pw")
|
||||
pm.password_generator = SimpleNamespace(
|
||||
generate_password=lambda l, i, gen_version=1: "pw"
|
||||
)
|
||||
pm.nostr_client = SimpleNamespace()
|
||||
|
||||
pm.entry_manager.add_entry(
|
||||
|
||||
@@ -520,12 +520,15 @@ def test_merged_deletion_does_not_recycle_entry_index():
|
||||
incoming = {
|
||||
"schema_version": 4,
|
||||
"entries": {
|
||||
"2": {"kind": "password", "label": "web-c", "modified_ts": 10**10, "_deleted": True},
|
||||
"2": {
|
||||
"kind": "password",
|
||||
"label": "web-c",
|
||||
"modified_ts": 10**10,
|
||||
"_deleted": True,
|
||||
},
|
||||
},
|
||||
}
|
||||
merged = merge_index_payloads(
|
||||
vault.load_index(), incoming, source_tag="remote"
|
||||
)
|
||||
merged = merge_index_payloads(vault.load_index(), incoming, source_tag="remote")
|
||||
assert "2" not in merged["entries"]
|
||||
assert merged["_sync_meta"]["next_index"] == 3
|
||||
vault.save_index(merged)
|
||||
|
||||
@@ -112,9 +112,7 @@ V1_VECTORS = [
|
||||
|
||||
def _generator(policy: PasswordPolicy) -> PasswordGenerator:
|
||||
seed = Bip39SeedGenerator(TEST_MNEMONIC).Generate()
|
||||
return PasswordGenerator(
|
||||
_SeedDeriver(), TEST_MNEMONIC, BIP85(seed), policy=policy
|
||||
)
|
||||
return PasswordGenerator(_SeedDeriver(), TEST_MNEMONIC, BIP85(seed), policy=policy)
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
@@ -422,9 +420,7 @@ def test_entry_with_gen_version_2_derives_v2():
|
||||
pm = _manager_with(pg)
|
||||
entry = {"length": 16, "gen_version": CURRENT_PASSWORD_GEN_VERSION}
|
||||
got = PasswordManager._generate_password_for_entry(pm, entry, 3)
|
||||
assert got == pg.generate_password(
|
||||
16, 3, gen_version=CURRENT_PASSWORD_GEN_VERSION
|
||||
)
|
||||
assert got == pg.generate_password(16, 3, gen_version=CURRENT_PASSWORD_GEN_VERSION)
|
||||
assert got != pg.generate_password(16, 3, gen_version=1)
|
||||
|
||||
|
||||
|
||||
@@ -17,7 +17,9 @@ from constants import DEFAULT_PASSWORD_LENGTH
|
||||
|
||||
|
||||
class FakePasswordGenerator:
|
||||
def generate_password(self, length: int, index: int, gen_version: int = 1) -> str: # noqa: D401
|
||||
def generate_password(
|
||||
self, length: int, index: int, gen_version: int = 1
|
||||
) -> str: # noqa: D401
|
||||
return f"pw-{index}-{length}"
|
||||
|
||||
|
||||
|
||||
@@ -35,7 +35,9 @@ def test_handle_verify_checksum_success(monkeypatch, tmp_path, capsys):
|
||||
chk_file.write_text("abc")
|
||||
monkeypatch.setattr("seedpass.core.manager.SCRIPT_CHECKSUM_FILE", chk_file)
|
||||
monkeypatch.setattr(
|
||||
type(pm), "_script_checksum_status", lambda self: (True, tmp_path / "seedpass.py")
|
||||
type(pm),
|
||||
"_script_checksum_status",
|
||||
lambda self: (True, tmp_path / "seedpass.py"),
|
||||
)
|
||||
pm.handle_verify_checksum()
|
||||
assert "Checksum verification passed." in capsys.readouterr().out
|
||||
@@ -47,7 +49,9 @@ def test_handle_verify_checksum_failure(monkeypatch, tmp_path, capsys):
|
||||
chk_file.write_text("xyz")
|
||||
monkeypatch.setattr("seedpass.core.manager.SCRIPT_CHECKSUM_FILE", chk_file)
|
||||
monkeypatch.setattr(
|
||||
type(pm), "_script_checksum_status", lambda self: (False, tmp_path / "seedpass.py")
|
||||
type(pm),
|
||||
"_script_checksum_status",
|
||||
lambda self: (False, tmp_path / "seedpass.py"),
|
||||
)
|
||||
pm.handle_verify_checksum()
|
||||
assert "Checksum verification failed" in capsys.readouterr().out
|
||||
@@ -61,7 +65,9 @@ def test_handle_verify_checksum_target_mismatch(monkeypatch, tmp_path, capsys):
|
||||
chk_file.write_text("abc")
|
||||
monkeypatch.setattr("seedpass.core.manager.SCRIPT_CHECKSUM_FILE", chk_file)
|
||||
monkeypatch.setattr(
|
||||
type(pm), "_script_checksum_status", lambda self: (None, tmp_path / "seedpass.py")
|
||||
type(pm),
|
||||
"_script_checksum_status",
|
||||
lambda self: (None, tmp_path / "seedpass.py"),
|
||||
)
|
||||
pm.handle_verify_checksum()
|
||||
out = capsys.readouterr().out
|
||||
@@ -74,7 +80,9 @@ def test_handle_verify_checksum_missing(monkeypatch, tmp_path, capsys):
|
||||
missing = tmp_path / "absent.txt"
|
||||
monkeypatch.setattr("seedpass.core.manager.SCRIPT_CHECKSUM_FILE", missing)
|
||||
monkeypatch.setattr(
|
||||
type(pm), "_script_checksum_status", lambda self: (True, tmp_path / "seedpass.py")
|
||||
type(pm),
|
||||
"_script_checksum_status",
|
||||
lambda self: (True, tmp_path / "seedpass.py"),
|
||||
)
|
||||
pm.handle_verify_checksum()
|
||||
note = pm.notifications.get_nowait()
|
||||
|
||||
@@ -138,7 +138,9 @@ def test_show_entry_details_by_index(monkeypatch):
|
||||
monkeypatch.setattr(
|
||||
"seedpass.core.manager.confirm_action", lambda *a, **k: False
|
||||
)
|
||||
pm.password_generator = SimpleNamespace(generate_password=lambda l, i, gen_version=1: "pw123")
|
||||
pm.password_generator = SimpleNamespace(
|
||||
generate_password=lambda l, i, gen_version=1: "pw123"
|
||||
)
|
||||
monkeypatch.setattr(pm, "notify", lambda *a, **k: None)
|
||||
|
||||
pm.show_entry_details_by_index(index)
|
||||
@@ -177,7 +179,9 @@ def _detail_common(monkeypatch, pm):
|
||||
monkeypatch.setattr("seedpass.core.manager.timed_input", lambda *a, **k: "b")
|
||||
monkeypatch.setattr("seedpass.core.manager.time.sleep", lambda *a, **k: None)
|
||||
monkeypatch.setattr(pm, "notify", lambda *a, **k: None)
|
||||
pm.password_generator = SimpleNamespace(generate_password=lambda l, i, gen_version=1: "pw123")
|
||||
pm.password_generator = SimpleNamespace(
|
||||
generate_password=lambda l, i, gen_version=1: "pw123"
|
||||
)
|
||||
called = []
|
||||
monkeypatch.setattr(pm, "_entry_actions_menu", lambda *a, **k: called.append(True))
|
||||
return called
|
||||
@@ -295,7 +299,9 @@ def test_show_entry_details_sensitive(monkeypatch, capsys, entry_type):
|
||||
with TemporaryDirectory() as tmpdir:
|
||||
tmp_path = Path(tmpdir)
|
||||
pm, entry_mgr = _setup_manager(tmp_path)
|
||||
pm.password_generator = SimpleNamespace(generate_password=lambda l, i, gen_version=1: "pw123")
|
||||
pm.password_generator = SimpleNamespace(
|
||||
generate_password=lambda l, i, gen_version=1: "pw123"
|
||||
)
|
||||
|
||||
monkeypatch.setattr(
|
||||
"seedpass.core.manager.confirm_action", lambda *a, **k: True
|
||||
|
||||
@@ -13,7 +13,9 @@ from seedpass.core.config_manager import ConfigManager
|
||||
|
||||
|
||||
class FakePasswordGenerator:
|
||||
def generate_password(self, length: int, index: int, gen_version: int = 1) -> str: # noqa: D401
|
||||
def generate_password(
|
||||
self, length: int, index: int, gen_version: int = 1
|
||||
) -> str: # noqa: D401
|
||||
return f"pw-{index}-{length}"
|
||||
|
||||
|
||||
|
||||
@@ -59,7 +59,9 @@ class FakeEvent:
|
||||
|
||||
|
||||
def test_order_key_prefers_published_ms():
|
||||
with_ms = Manifest(ver=1, algo="gzip", chunks=[], published_ms=SAME_SECOND * 1000 + 900)
|
||||
with_ms = Manifest(
|
||||
ver=1, algo="gzip", chunks=[], published_ms=SAME_SECOND * 1000 + 900
|
||||
)
|
||||
assert manifest_order_ms(with_ms, SAME_SECOND) == SAME_SECOND * 1000 + 900
|
||||
|
||||
|
||||
@@ -96,8 +98,14 @@ def test_event_id_still_breaks_an_exact_millisecond_tie():
|
||||
# contents, so no party chooses the winner.
|
||||
a = FakeEvent("1111", SAME_SECOND, SAME_SECOND * 1000 + 500)
|
||||
b = FakeEvent("2222", SAME_SECOND, SAME_SECOND * 1000 + 500)
|
||||
assert [e.id for e in _sort_manifest_events_newest_first([a, b])] == ["2222", "1111"]
|
||||
assert [e.id for e in _sort_manifest_events_newest_first([b, a])] == ["2222", "1111"]
|
||||
assert [e.id for e in _sort_manifest_events_newest_first([a, b])] == [
|
||||
"2222",
|
||||
"1111",
|
||||
]
|
||||
assert [e.id for e in _sort_manifest_events_newest_first([b, a])] == [
|
||||
"2222",
|
||||
"1111",
|
||||
]
|
||||
|
||||
|
||||
def test_an_unparseable_manifest_orders_by_created_at_without_raising():
|
||||
|
||||
@@ -27,7 +27,9 @@ def test_password_notes_shown(monkeypatch, capsys):
|
||||
pm.vault = vault
|
||||
pm.entry_manager = entry_mgr
|
||||
pm.backup_manager = backup_mgr
|
||||
pm.password_generator = SimpleNamespace(generate_password=lambda l, i, **_: "pw")
|
||||
pm.password_generator = SimpleNamespace(
|
||||
generate_password=lambda l, i, **_: "pw"
|
||||
)
|
||||
pm.parent_seed = TEST_SEED
|
||||
pm.nostr_client = SimpleNamespace()
|
||||
pm.fingerprint_dir = tmp_path
|
||||
|
||||
@@ -265,7 +265,7 @@ def test_an_index_built_before_the_fix_is_deleted_on_first_touch(tmp_path):
|
||||
|
||||
|
||||
def test_an_unreadable_manifest_is_not_treated_as_stale(tmp_path):
|
||||
""""Cannot tell" must not mean "delete it"."""
|
||||
""" "Cannot tell" must not mean "delete it"."""
|
||||
from seedpass.core.semantic_index import SemanticIndex
|
||||
|
||||
index = SemanticIndex(tmp_path)
|
||||
|
||||
@@ -365,6 +365,7 @@ async def test_v3_action_bar_global_row_uses_correct_handlers() -> None:
|
||||
# Export/Import Data use open_palette because they need a path argument
|
||||
# Verify both labels still present
|
||||
from rich.text import Text
|
||||
|
||||
rendered = Text.from_markup(markup).plain
|
||||
assert "Export Data" in rendered
|
||||
assert "Import Data" in rendered
|
||||
|
||||
@@ -986,9 +986,7 @@ async def test_tui3_recover_profile_sets_success_status_before_bootstrap() -> No
|
||||
booted["fingerprint"] = fingerprint
|
||||
# Capture status text at the moment bootstrap fires
|
||||
try:
|
||||
status_at_boot.append(
|
||||
str(app.screen.query_one("#recover-status").render())
|
||||
)
|
||||
status_at_boot.append(str(app.screen.query_one("#recover-status").render()))
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
@@ -1219,4 +1217,6 @@ async def test_tui3_toolbar_active_class_reflects_app_state() -> None:
|
||||
app.action_set_search_sort("label_asc")
|
||||
await pilot.pause()
|
||||
assert app.screen.query_one("#grid-sort-label_asc", Button).has_class("active")
|
||||
assert not app.screen.query_one("#grid-sort-relevance", Button).has_class("active")
|
||||
assert not app.screen.query_one("#grid-sort-relevance", Button).has_class(
|
||||
"active"
|
||||
)
|
||||
Reference in new issue
Block a user