Skip to content

[Stubgenc] Fails to generate stub for Tuple special cases when using pybind11 #17394

Open
@InvincibleRMC

Description

@InvincibleRMC

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions