sizmailov / pybind11-stubgen

Generate stubs for python modules
Other
228 stars 45 forks source link

Non-determinstic output #160

Closed forrestsmithfb closed 10 months ago

forrestsmithfb commented 10 months ago

Hi, I'm using pybind11-stubgen and everything seems to be working. Except the output is non-deterministic.

The issue appears to be classes which have multiple init functions. Here's an example of my generated output:

class Foo:
    @overload
    def __init__(self, arg0: str, arg1: str) -> None: ...
    @overload
    def __init__(self) -> None: ...

Those two init functions can appear in different orders. :(

I'm probably on an old version. So maybe this was fixed at some point? I'm not sure. Thanks!

sizmailov commented 10 months ago

Hi!

It would help if you share a minimal reproducible example. The output should be reproducible. The tests check for the exact match of the generated files. Constructor handling is no different from regular functions, so overloads should appear in the same order as they are defined in docstrings.

forrestsmithfb commented 10 months ago

Closing issue. We're on a much older version so this likely does not apply to latest.

FWIW the repro was as simple as:

  py::class_<Foo>(m, "Foo")
    .def(py::init<>()) 
    .def(py::init<float, float>());