Problem
python-docx has from __future__ import annotations in 145 of 172 source files (~84%). The sibling python-pptx has it in 119 of 128 (~93%). The gap is unexplained and contributes to subtle type-annotation inconsistency — some files use PEP 604 str | None freely, others stick to Optional[str].
Expected fix
Enable ruff rule I002 (required-from-future-import) or the equivalent isort setting in [tool.ruff.lint.isort]:
required-imports = ["from __future__ import annotations"]
Run ruff check --fix to insert the directive into the 27 files currently lacking it.
Benefit
- Contributors stop wondering "should I use
str | None here or Optional[str]?"
- Consistency with python-pptx (which should receive the same treatment as a follow-up)
- Tiny forward-compat benefit for Python 3.14+ stringified annotation changes
Surfaced by: 2026-05-05 consistency audit (item 8).
Problem
python-docx has
from __future__ import annotationsin 145 of 172 source files (~84%). The sibling python-pptx has it in 119 of 128 (~93%). The gap is unexplained and contributes to subtle type-annotation inconsistency — some files use PEP 604str | Nonefreely, others stick toOptional[str].Expected fix
Enable ruff rule
I002(required-from-future-import) or the equivalentisortsetting in[tool.ruff.lint.isort]:Run
ruff check --fixto insert the directive into the 27 files currently lacking it.Benefit
str | Nonehere orOptional[str]?"Surfaced by: 2026-05-05 consistency audit (item 8).