Skip to content

refactor: sort import statements in docxtpl/ - #648

Open
waketzheng wants to merge 6 commits into
elapouya:masterfrom
waketzheng:sort-imports
Open

refactor: sort import statements in docxtpl/#648
waketzheng wants to merge 6 commits into
elapouya:masterfrom
waketzheng:sort-imports

Conversation

@waketzheng

@waketzheng waketzheng commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Description

  1. Relocate the try ... except ImportError block in docxtpl/template.py to below the other import statements.
  2. Reorder imports with isort (run uvx isort docxtpl).

This is based on PR #647.
Diff: waketzheng/python-docx-template@remove-noqa...sort-imports

@CAOShurong CAOShurong left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I independently reviewed and tested the exact head f583ed3428af05eab158960cb06f382c193ebec4.

  • All 37 test scripts passed when run directly with the review environment's Python interpreter.
  • flake8 and git diff --check passed, and both the sdist and wheel built successfully.
  • From clean wheel installs, from docxtpl import * excluded Subdoc when docxcompose was absent and included it when the optional dependency was installed.
  • A normal template rendered and reopened successfully from the installed wheel; the optional-dependency environment also rendered and reopened a document containing a generated subdocument.
  • The 14 upstream test/codestyle checks are green.

The import-only changes preserve the optional dependency behavior and look correct to me.

OpenAI Codex assisted with the exact-head test matrix and diff review. I personally checked the commands, outputs, installed-wheel behavior, and this approval.

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.

2 participants