Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prepare for pybind11-stubgen #1804

Closed
wants to merge 9 commits into from

Conversation

snoyer
Copy link
Contributor

@snoyer snoyer commented Dec 18, 2024

It seems like https://github.com/sizmailov/pybind11-stubgen is now mature enough to generate the f3d bindings stubs automatically.

In order to properly generate the stubs we need to:

  • reorder some bindings declaration so that everything is known before it is referenced
  • use ----ignore-unresolved-names to ignore f3d::point3_t and f3d::vector3_t as we don't actually map them but let them auto-convert to and from tuple[float, float, float]
  • use --enum-class-locations SaveFormat:Image to allow proper identification of the default value for the format parameters of Image.save() and Image.save_buffer()
  • do some post-processing to clean up a few thing

With this PR's changes we can run the new generate_stubs.py script to generate the .pyi files

@snoyer
Copy link
Contributor Author

snoyer commented Dec 18, 2024

Adding the type aliases for point3_t and vector3_t in __init__.py does not work properly because the following gets generated in __init__.pyi

from builtins import tuple as point3_t
from builtins import tuple as vector3_t

this is technically correct but means that variables anotated as f3d.point3_t or f3d.vector3_t are seen as being of type tuple[Any, ...] that is tuples alright but of unknown length and with elements of any type.

the following more precise definition should be added after the imports in the generated pyf3d.pyi somehow

point3_t = tuple[float, float, float]
vector3_t = tuple[float, float, float]

Copy link

codecov bot commented Dec 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.68%. Comparing base (792c67b) to head (cbf1aa7).
Report is 49 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1804   +/-   ##
=======================================
  Coverage   95.67%   95.68%           
=======================================
  Files         123      123           
  Lines        9739     9754   +15     
=======================================
+ Hits         9318     9333   +15     
  Misses        421      421           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@snoyer snoyer mentioned this pull request Dec 31, 2024
@snoyer
Copy link
Contributor Author

snoyer commented Jan 3, 2025

taken over in #1818

@snoyer snoyer closed this Jan 3, 2025
@snoyer snoyer deleted the fix-pybind11-stubgen-warnings branch January 4, 2025 03:33
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.

1 participant