Skip to content

typing: annotate repoobj module boundaries and enable strict mypy checks (refs #10021) - #10582

Open
Prateek99-s wants to merge 1 commit into
borgbackup:masterfrom
Prateek99-s:typing-repoobj
Open

Prateek99-s wants to merge 1 commit into
borgbackup:masterfrom
Prateek99-s:typing-repoobj

Conversation

@Prateek99-s

Copy link
Copy Markdown

Addresses part of #10021.

Summary of Changes

Following #10021 (gradual typing of core module boundaries for Borg 2.0), this PR:

  1. Annotates src/borg/repoobj.py and src/borg/legacy/repoobj.py:
    • Converted ObjHeader to a typed NamedTuple (magic, version, chunk_id, meta_size, data_size), keeping full unpack/tuple compatibility.
    • Added complete type hints to RepoObj, RepoObj1, object_validator, and whole_object_authenticator.
  2. Harmonizes src/borg/compress.pyi stubs:
    • Corrected LZ4_COMPRESSOR and NONE_COMPRESSOR from type[...] to compressor instances.
    • Updated CompressorBase compress/decompress signatures to accept bytes | memoryview as documented and implemented in compress.pyx.
  3. Enables strict mypy checking in pyproject.toml:
    • Enabled disallow_untyped_defs = true, disallow_incomplete_defs = true, and check_untyped_defs = true for borg.repoobj and borg.legacy.repoobj.

Verification

  • mypy src/borg/repoobj.py src/borg/legacy/repoobj.py: Passed (0 errors).
  • Global mypy: Passed (0 errors across 232 source files).
  • pytest src/borg/testsuite/repoobj_test.py src/borg/testsuite/compress_test.py: 143 passed.
  • Pre-commit (black + ruff): Passed.

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