pybind / pybind/pybind11-stubgen

Ignore attribute value

Open
#222 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
361
Forks
75
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files or tests are named. Start by tracing the stub-generation path for module-level constant attributes and the command-line option handling; done means an option can emit type annotations without constant values, while preserving the existing output by default and making generated stubs stable for CI checks.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.