sizmailov / pybind11-stubgen

Generate stubs for python modules
Other
236 stars 47 forks source link

Ignore attribute value #222

Open ozobotnovako opened 5 months ago

ozobotnovako commented 5 months ago

For module-level attributes with constant values such as

 m.attr("changeset") = py::str(VC_CHANGESET);
 m.attr("built") = py::str(BUILD_DATE);

the corresponding generated lines in the stubfile look like the following

changeset: str = '1234567890123'
built: str = '2024-01-01 00:00'

I'd like to see a way to disable writing the values and using just the typing labels, similar to this

changeset: str
built: str

The problem I'm having is relevant for CI checks. I wanted to run the stub generation and check diff on the CI to verify the interface did not change. However, if one of these variables change with each build (e.g., the build time), the stub also changes on every build.

Is there any way how to implement this now? If there isn't, I suggest adding an option passed to the script, that would only generate the labels.