Skip to content

Improve error when optional subdoc dependency is missing - #665

Open
ahmetmusab42-stack wants to merge 1 commit into
elapouya:masterfrom
ahmetmusab42-stack:fix-subdoc-missing-dependency-error
Open

Improve error when optional subdoc dependency is missing#665
ahmetmusab42-stack wants to merge 1 commit into
elapouya:masterfrom
ahmetmusab42-stack:fix-subdoc-missing-dependency-error

Conversation

@ahmetmusab42-stack

Copy link
Copy Markdown

Summary

docxcompose is intentionally optional, but calling new_subdoc() without the subdoc extra currently exposes a raw import traceback. This adds a focused diagnostic at that API boundary:

new_subdoc() requires the optional docxcompose dependency. Install it with: pip install "docxtpl[subdoc]"

Only a missing top-level docxcompose module is translated. Any unrelated ModuleNotFoundError raised while importing the optional implementation is preserved unchanged, so broken or incompatible installations are not misreported.

This follows the small guard direction proposed by @janmarsino98 in #629 and addresses the confusing missing-extra diagnostic reported there. It does not make docxcompose mandatory or restore the pre-0.20.2 dependency behavior.

Verification

  • reproduced the failure in an isolated Python 3.13 environment containing only the mandatory dependencies
  • added regression coverage for the actionable missing-extra message and unrelated-error passthrough
  • verified the normal subdocument path with the extra installed
  • ran 37 standalone regression scripts successfully
  • targeted test passed on Python 3.9 and 3.14
  • Flake8 passed
  • sdist and wheel builds passed

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