Skip to content

item.pyi: sync with item.pyx, add a test that they agree, refs #10021 - #10533

Open
Vinay-Kaushal wants to merge 1 commit into
borgbackup:masterfrom
Vinay-Kaushal:test-item-pyi-stub
Open

Vinay-Kaushal wants to merge 1 commit into
borgbackup:masterfrom
Vinay-Kaushal:test-item-pyi-stub

Conversation

@Vinay-Kaushal

Copy link
Copy Markdown

Description

Addresses point 3 of #10021 ("Keep item.pyi honest"): add a test asserting that the hand-maintained stub and the PropDictProperty table in item.pyx agree.

The stub had already drifted, so this also syncs it:

  • add missing properties: Item.target, ArchiveItem.command_line, ArchiveItem.recreate_command_line, ArchiveItem.cwd, Key.crypt_key, EncryptedKey.argon2_time_cost / argon2_memory_cost / argon2_parallelism / argon2_type
  • remove properties that do not exist: ArchiveItem.csize, Key.enc_key, Key.enc_hmac_key
  • use precise types instead of Any for ArchiveItem.recreate_args, recreate_partial_chunks and recreate_source_id
  • ManifestItem.archives is a dict with str keys, not Mapping[bytes, dict]
  • declare PropDictProperty (imported by the test)

The new test (item_test.py::test_stub_matches_propdict_properties) parses item.pyi with ast and checks, for every PropDict subclass, that the stub declares exactly the PropDictProperty attributes of the class, that getter and setter annotations agree and that the annotated base type matches the property's value_type. With the old stub it fails for all 5 classes.

Checklist

  • PR is against master (or maintenance branch if only applicable there)
  • New code has tests and docs where appropriate
  • Tests pass (run tox or the relevant test subset)
  • Commit messages are clean and reference related issues

item_test.py passes, mypy --ignore-missing-imports, ruff check . and black --check are clean. Full suite: 3670 passed; the only failure (prune_cmd_test.py::test_prune[rule4-3-expected_indices4]) fails the same way on unmodified master in my environment, so it is unrelated.

…ckup#10021

The hand-maintained stub had drifted from the PropDictProperty table:

- add missing properties: Item.target, ArchiveItem.command_line,
  ArchiveItem.recreate_command_line, ArchiveItem.cwd, Key.crypt_key,
  EncryptedKey.argon2_time_cost/argon2_memory_cost/argon2_parallelism/argon2_type
- remove properties that do not exist: ArchiveItem.csize, Key.enc_key,
  Key.enc_hmac_key
- use precise types instead of Any for ArchiveItem.recreate_args,
  recreate_partial_chunks and recreate_source_id
- ManifestItem.archives is a dict with str keys, not Mapping[bytes, dict]
- declare PropDictProperty

The new test parses item.pyi and checks, for every PropDict subclass, that the
stub declares exactly the PropDictProperty attributes of item.pyx and that the
annotated types match their value_type, so they cannot drift apart again.
@codecov

codecov Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.35%. Comparing base (3c95ce7) to head (72e0a19).
⚠️ Report is 9 commits behind head on master.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #10533      +/-   ##
==========================================
+ Coverage   89.32%   89.35%   +0.02%     
==========================================
  Files         104      104              
  Lines       20079    20079              
  Branches     3152     3152              
==========================================
+ Hits        17936    17941       +5     
+ Misses       1484     1481       -3     
+ Partials      659      657       -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant