[Stubgenc] Fails to generate stub for Tuple special cases when using pybind11
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
Bug Report
Using pybind11 v2.12.0 allows adding typing annotations for things. And it works great for most types but fails to properly parse the tuple special cases and so the stub is left without a type.
To Reproduce
I discovered while contributing to the pybind11 project.
I would recommend following there guide to building.
Once built move into the build/tests directory
And run the following command
stubgen -p pybind11_tests
Expected Behavior
Generate the following.
def annotate_tuple_empty(arg0: tuple[()]) -> None: ...
def annotate_tuple_variable_length(arg0: tuple[float, ...]) -> None: ...
Actual Behavior
Generated the following.
def annotate_tuple_empty(arg0) -> None: ...
def annotate_tuple_variable_length(arg0) -> None: ...
Your Environment
- Mypy version used:
mypy 1.10.0 (compiled: yes) - Mypy command-line flags:
Inside pybind11/build/tests
stubgen -p pybind11_tests
- Python version used:
Python3.10
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in the stubgen path that handles pybind11-generated annotations, reproducing the issue from the pybind11 build/tests directory with stubgen -p pybind11_tests. Compare the generated output for annotate_tuple_empty and annotate_tuple_variable_length with the expected tuple annotations; done means both signatures retain their tuple types.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100