Repository navigation
PPF-2075: Reject ignored arguments and distinguish empty input from invalid input - #2092
Conversation
- Raise TypeError for removed or unknown PdfWrapper/fill keyword arguments, with per-keyword removal version and migration guidance. - Make the file adapter open str/PathLike paths directly and reject unsupported types instead of returning empty input. - Make PdfArray.merge() return a new wrapper for empty and one-item arrays; move PdfArray into wrapper.py to remove the circular import. - Update docs, migration guide, and the E2-05 action plan entry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Reviewed commit
Validation: |
- Replace the rebuild-and-replay copy path in PdfArray.merge() with PdfWrapper._copy(), which reuses the current stream without embedding registered fonts again and deep-copies widgets and pending key updates. - Restore PdfWrapper.__add__ to its original implementation. - Add regression coverage and record the review follow-up in the plan. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Re-reviewed commit One remaining issue: [P2] Preserve the cached PDF version when copying a wrapper — wrapper.py, lines 251–258. source = PdfWrapper("pdf_samples/sample_template.pdf").change_version("2.0")
source.widgets["test"].font_size = 18
result = PdfArray([source, PdfWrapper()]).merge()
assert result.version == source.version # fails: "1.3" != "2.0"
assert result.read().startswith(b"%PDF-2.0") # also fails
Please copy the cached version alongside the other wrapper state and add regression coverage for a pending style change followed by a one-item or empty-padded merge, asserting both the version property and serialized header. Validation: standard zlib; the two updated merge tests passed; |
- Copy the cached PDF version in PdfWrapper._copy() so copies restore the source header after hook rewrites emit a different version. - Add 1.7/2.0 regression coverage for one-item and empty-padded merges after a pending style change, and record the follow-up in the plan. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Resolves #2075 (action plan item E2-05, review finding R10).
Changes
PdfWrapper(...)andfill()raiseTypeErrorfor removed or unknown keywords before any mutation.preserve_metadataandflattenreport the release that removed them and their replacement (REMOVED_KWARGS); other keywords list the supported ones.strandPathLikepaths directly, so missing paths raiseFileNotFoundErrorfor templates, fonts, signature/image values, andRawImage. Unsupported types raiseTypeError.PdfWrapper(),b"", and empty streams still create an empty wrapper.PdfArray.merge(): an empty array returns a new emptyPdfWrapper, and the result is never one of the inputs. One-item and empty-padded arrays return an independent copy (PdfWrapper._copy()) that reuses the current stream and cached PDF version without embedding registered fonts again, and deep-copies widget settings and pending key updates.+and slicing identity are unchanged (E4-02).PdfArraymoved fromlib/types.pyintolib/wrapper.pyto remove the circular import;from PyPDFForm import PdfArrayis unchanged. PylintC0302(module line limit) is disabled.test_dropdown_tutorialregistered a nonexistent font that was silently skipped; the dead call is removed andPPF-1599_expected.pdfstays byte-identical.test_register_bad_fontsnow expectsFileNotFoundErrorfor a missing font path.basic.md, bulk-merge note inutils.md, docstrings, and the E2-05 action plan entry.Validation
make test-all(456 passed, 100% coverage),make linting, strict MkDocs build, andgit diff --check, using local./venvwith standardzlib. The development container, the cross-platform matrix, and viewer rendering were not run locally. No appearance generation changed.🤖 Generated with Claude Code