From f262337eac8be6102617aa4faa7e5ad1a33adde9 Mon Sep 17 00:00:00 2001 From: Alex Maldonado Date: Wed, 21 Oct 2026 03:02:01 -0400 Subject: [PATCH] refactor: drop the private aliases kept for the siblings package._canonical_bytes, package._zip_entries, anchors._follow and traces._anchors are gone; paperdesk and paperforms use the public names. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01YCVvg4F3wpYQjq1NQUSmxN --- CHANGELOG.md | 1 + src/paperspec/anchors.py | 4 ---- src/paperspec/package.py | 10 ---------- src/paperspec/traces.py | 4 ---- tests/test_anchors.py | 4 ++-- tests/test_public_api.py | 4 ++-- 6 files changed, 5 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cf6d551..9996f08 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -172,3 +172,4 @@ It is a minor change in the sense of [spec/00](spec/00-introduction.md): new rul - Public names, with the old private names kept as aliases: `package.parse_canonical`, `parse_json`, `parse_jsonl`, `check_zip_entries` and `read_zip_files`; `tree.flatten` and `establish_with_side`, which keeps a producer's private keys; `hashing.strict_runs`; and `corrections.OPS` and `EMEND_KINDS` (`test_public_api.py`). Also `anchors.follow` and `resolve_address`, `claims.parse_ref`, `parse_pin`, `format_ref` and `format_pin`, `layers.annotation_id`, `anchors_of` and the lists of body kinds, categories, verdicts and statuses, and `db.load_layer`, `read_state`, `delete` and `upgrade` (`test_anchors.py`, `test_claims.py`, `test_layers.py`, `test_db.py`). - `text.collapse_ws`, `trim`, `remove_ws` and `digits` and `hashing.lossy_from_strict` are rewritten for speed, so a correction goes through the gate about three times faster, and are tested equal to the old code on every code point (`test_text.py`, `test_hashing.py`). +- The private aliases kept for the siblings are gone, now that paperdesk and paperforms use the public names: `package._canonical_bytes`, `package._zip_entries`, `anchors._follow` and `traces._anchors` (`tests/test_public_api.py::test_parse_canonical_reads_doubles_and_refuses_what_is_not_canonical`, `::test_check_zip_entries_returns_the_folder_without_reading`, `tests/test_anchors.py::TestFollow::test_follow_has_no_alias_under_its_old_private_name`). diff --git a/src/paperspec/anchors.py b/src/paperspec/anchors.py index 9e75391..b70e58e 100644 --- a/src/paperspec/anchors.py +++ b/src/paperspec/anchors.py @@ -245,10 +245,6 @@ def follow(state: State, nid: str) -> tuple[str | None, list[str], str | None]: return _walk({n["id"] for n in state.nodes}, state.ids, nid) -# paperdesk's cite.py uses the old private name until it moves to `follow`. -_follow = follow - - def resolve_address( nodes: Iterable[Record], ids: Iterable[Record], diff --git a/src/paperspec/package.py b/src/paperspec/package.py index b9cc5c6..496743d 100644 --- a/src/paperspec/package.py +++ b/src/paperspec/package.py @@ -169,11 +169,6 @@ def parse_canonical(data: bytes, where: str) -> Any: return rec -# paperdesk's reader (reading.py) calls the old private name; it goes once paperdesk uses -# parse_canonical, parse_json or parse_jsonl. -_canonical_bytes = parse_canonical - - def parse_jsonl(data: bytes, where: str) -> list[Record]: """Parse the bytes of a canonical JSONL file, one JSON value per line (spec/01 ยง1.9). @@ -1218,11 +1213,6 @@ def check_zip_entries(zf: zipfile.ZipFile, limit: int = ZIP_LIMIT) -> str: return folder -# paperdesk's reader (reading.py) calls the old private name; it goes once paperdesk uses -# check_zip_entries or read_zip_files. -_zip_entries = check_zip_entries - - def _open_zip(path: StrPath) -> zipfile.ZipFile: try: return zipfile.ZipFile(path) diff --git a/src/paperspec/traces.py b/src/paperspec/traces.py index 22f7cbf..5242b69 100644 --- a/src/paperspec/traces.py +++ b/src/paperspec/traces.py @@ -39,10 +39,6 @@ def doc_tag(store: str, key: str) -> str: return f"tag:scient.ing,2026:doc:{store}/{key}" -# paperdesk's tracing.py uses the private name until it moves to layers.anchors_of. -_anchors = layers.anchors_of - - def _bare(doc: str) -> str: """A document key without its store. diff --git a/tests/test_anchors.py b/tests/test_anchors.py index 7cc7efc..1180f06 100644 --- a/tests/test_anchors.py +++ b/tests/test_anchors.py @@ -836,8 +836,8 @@ def _jsonl(name): class TestFollow: - def test_follow_is_the_old_private_name(self): - assert anchors._follow is anchors.follow + def test_follow_has_no_alias_under_its_old_private_name(self): + assert not hasattr(anchors, "_follow") def test_a_live_node_is_followed_to_itself(self, tree): assert anchors.follow(tree["state"], tree["s1"]) == (tree["s1"], [], None) diff --git a/tests/test_public_api.py b/tests/test_public_api.py index 0ce8695..fa81837 100644 --- a/tests/test_public_api.py +++ b/tests/test_public_api.py @@ -19,7 +19,7 @@ from paperspec.tree import Refusal def test_parse_canonical_reads_doubles_and_refuses_what_is_not_canonical(): value = package.parse_canonical(b'{"a":100000000000000000000}', "x") assert value == {"a": 1e20} and isinstance(value["a"], float) - assert package._canonical_bytes is package.parse_canonical + assert not hasattr(package, "_canonical_bytes") # no alias for the old name with pytest.raises(Refusal) as e: package.parse_canonical(b'{ "a":1}', "x:1") assert e.value.rule == "package.file.canonical" @@ -68,7 +68,7 @@ def test_read_zip_files_refuses_what_is_not_a_zip(tmp_path): def test_check_zip_entries_returns_the_folder_without_reading(): with zipfile.ZipFile(TINY_ZIP) as zf: assert package.check_zip_entries(zf) == TINY.name - assert package._zip_entries is package.check_zip_entries + assert not hasattr(package, "_zip_entries") # no alias for the old name def test_flatten_keeps_private_keys_and_leaves_the_spec_alone():