Skip to content

refactor: remove noqa comment from the __init__ file - #647

Open
waketzheng wants to merge 3 commits into
elapouya:masterfrom
waketzheng:remove-noqa
Open

refactor: remove noqa comment from the __init__ file#647
waketzheng wants to merge 3 commits into
elapouya:masterfrom
waketzheng:remove-noqa

Conversation

@waketzheng

@waketzheng waketzheng commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Description

  1. Add __all__ to docxtpl/__init__.py so that the # noqa comment is no longer needed.
  2. Sort the import statement from .richtext import ....

Validation results:

  • flake8 check:
$ flake8 docxtpl/__init__.py --count --max-line-length=127 --show-source --statistics
0
  • Expose modules:
$ python -c 'from docxtpl import *; print(dir())'
['DocxTemplate', 'InlineImage', 'Listing', 'R', 'RP', 'RichText', 'RichTextParagraph', 'Subdoc', '__annotations__', '__builtins__', '__doc__', '__loader__', '__name__', '__package__', '__spec__']
  • When docxcompose is not installed:
$ pip uninstall docxcompose
$ python -c 'from docxtpl import *; print(dir())'
['DocxTemplate', 'InlineImage', 'Listing', 'R', 'RP', 'RichText', 'RichTextParagraph', '__annotations__', '__builtins__', '__doc__', '__loader__', '__name__', '__package__', '__spec__']

@arturict

Copy link
Copy Markdown

Nice cleanup. Removing noqa can affect lint behavior; include before/after lint result in PR description?

@waketzheng

Copy link
Copy Markdown
Contributor Author

Nice cleanup. Removing noqa can affect lint behavior; include before/after lint result in PR description?

@arturict Updated.

@JackSpiece JackSpiece 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.

Checked 32a2dba in separate environments with and without docxcompose. In both cases, from docxtpl import * exports exactly the names declared by docxtpl.__all__. The environment with docxcompose includes Subdoc; the environment without it imports cleanly and excludes only Subdoc.

The exact flake8 command and git diff --check pass locally, and the upstream test and codestyle matrix is green from Python 3.7 through 3.14. This preserves the optional dependency behavior while removing the blanket noqa. Looks good.

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.

3 participants