← 返回首页
[codex] support path-like image paths by Sean-Kenneth-Doherty · Pull Request #1555 · python-openxml/python-docx · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus

[codex] support path-like image paths#1555

Open
Sean-Kenneth-Doherty wants to merge 1 commit into
python-openxml:masterfrom
Sean-Kenneth-Doherty:codex/support-pathlike-images
Open

[codex] support path-like image paths#1555
Sean-Kenneth-Doherty wants to merge 1 commit into
python-openxml:masterfrom
Sean-Kenneth-Doherty:codex/support-pathlike-images

Conversation

Copy link
Copy Markdown

Summary

  • accept os.PathLike image paths in the image loader used by Document.add_picture() and Run.add_picture()
  • update public image-path annotations and docs to mention path-like objects
  • add regression coverage for Image.from_file(Path(...))

Fixes #1544

Validation

  • uv run --with pytest --with ruff --with-editable . python -m pytest tests/image/test_image.py tests/test_document.py tests/text/test_run.py -q
  • uv run --with pytest --with ruff --with-editable . python -m ruff check src/docx/image/image.py src/docx/document.py src/docx/text/run.py src/docx/parts/story.py src/docx/package.py tests/image/test_image.py
  • uv run --with-editable . python - <<'PY' ... Document().add_picture(Path('tests/test_files/python-icon.png')) ... PY
  • git diff --check

Note: a targeted pyright run is not included as validation because the current project reports pre-existing strict-type errors in these files/tests before this change.

AI assistance: prepared with OpenAI Codex.

Sean-Kenneth-Doherty marked this pull request as ready for review May 16, 2026 23:22
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

Support for pathlib.Path

1 participant

Footer

© 2026 GitHub, Inc.