Skip to content

Enforce from __future__ import annotations everywhere (bring coverage 84% → 100%) #175

@loadfix

Description

@loadfix

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions