mypy icon indicating copy to clipboard operation
mypy copied to clipboard

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

Open InvincibleRMC opened this issue 1 year ago • 0 comments

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

InvincibleRMC avatar Jun 17 '24 12:06 InvincibleRMC