Skip to content

chore(pdf): remove the pdfminer psparser patch that can no longer apply - #4838

Open
KRRT7 wants to merge 1 commit into
Unstructured-IO:mainfrom
KRRT7:chore/remove-dead-pdfminer-psparser-patch
Open

KRRT7 wants to merge 1 commit into
Unstructured-IO:mainfrom
KRRT7:chore/remove-dead-pdfminer-psparser-patch

Conversation

@KRRT7

@KRRT7 KRRT7 commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

unstructured/partition/pdf.py calls patch_psparser() at import time. It replaces PSBaseParser.seek, _parse_keyword and nexttoken, but only when:

if pdfminer.__version__ <= "20240706":

pyproject.toml now requires pdfminer.six>=20251230, <20270000. pdfminer.six versions are YYYYMMDD strings, so every allowed version compares greater than "20240706" and the condition is always false. The function runs on every import of pdf.py and does nothing, and the three replacement methods are never installed. Coverage over the full test suite confirms they never run.

This PR removes unstructured/patches/ (its only module was pdfminer.py) and the import and call in pdf.py.

Behavior

Unchanged for every supported pdfminer.six version: the code removed was never reached.

Validation

  • test_unstructured/partition/pdf_image and the PDF/image cases in test_unstructured/partition/test_auto.py pass (687 passed, 3 skipped).
  • ruff check / ruff format --check pass.

View guided diff

`patch_psparser()` replaced `PSBaseParser.seek`, `_parse_keyword` and
`nexttoken` only when `pdfminer.__version__ <= "20240706"`. The project now
requires `pdfminer.six>=20251230`, so the condition is always false: the
function runs at import time and does nothing, and the three replacement
methods are never installed.

Remove `unstructured/patches/` and the import-time call in `pdf.py`. Behavior
is unchanged for every supported pdfminer.six version.

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