pybind11 icon indicating copy to clipboard operation
pybind11 copied to clipboard

Fix issue #3912 : invalid docstring generation of std::array <-> list caster

Open Skylion007 opened this issue 3 years ago • 3 comments

Description

  • Fixes #3912, by removing size information from list, while this information is helpful, it generates invalid type signatures for mypy and other type checkers.

Suggested changelog entry:

* Fixes doc generation for std::array-list caster. Previously, signatures included the size of the list in a non-standard, non-spec compliant way.

Skylion007 avatar Apr 29 '22 15:04 Skylion007

This PR achieves MyPy compliance in exchange for potentially very confusing situations where a pybind11-bound function does not accept an input array, and the error message provides zero context why that is (input has the wrong size)

wjakob avatar Apr 29 '22 18:04 wjakob

These signatures in pybind11 precede the time where MyPy was even a thing, so "non-standard non-spec compliant" seems a bit strong of a qualifier.

wjakob avatar Apr 29 '22 18:04 wjakob

@Wjacob, in >=3.9 we can use the Annotated typing extension to specify the length of the list. Hmm, not sure if there is a standard compliant way to specify the type for anything besides Tuples though.

Skylion007 avatar Apr 29 '22 19:04 Skylion007

@Skylion007 @rwgk can we close this one?

cielavenir avatar May 25 '23 05:05 cielavenir

Closing after #4679 was merged.

rwgk avatar May 25 '23 16:05 rwgk