Skip to content

Improve auto-generated documentation and type stubs#1413

Open
KurtBoehm wants to merge 3 commits into
libvips:masterfrom
KurtBoehm:master
Open

Improve auto-generated documentation and type stubs#1413
KurtBoehm wants to merge 3 commits into
libvips:masterfrom
KurtBoehm:master

Conversation

@KurtBoehm
Copy link
Copy Markdown

This PR introduces several improvements to the typing in the documentation and the type stubs:

  • Use bytes as the type of buffers (which is actually what functions such as pngsave_buffer return) and str | Path for file names (which were typed as just str until now, but the helper function converting strings to bytes already handles pathlib.Path).
  • Extend the type stub generation to generate the full enum definitions automatically and define Operation and Introspect.
  • Extend the type stub with more operations (all apart from nifti-based ones).

The only remaining limitation of the Image type stubs is the lack of nifti operations, as I was not able to install libniftiio on Arch Linux in a way that libvips recognized during compilation (and I did not really want to spend more time on installing it).

-  Use `bytes` and `str | Path` where appropriate.
- Extend the type stub generation to generate the full enum definitions and define `Operation` and `Introspect`.
- Extend the type stub with more operations (all apart from nifti-based ones).
@jcupitt
Copy link
Copy Markdown
Member

jcupitt commented May 31, 2026

This is very cool @KurtBoehm! I'll try to review this week.

Yes, nifti is surprisingly difficult to build :( I leave it out of the flatpak and win builds as well, it's just too annoying.

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