Closed cielavenir closed 1 year ago
I don't see the motivation behind this change. What problem you are trying to solve?
https://github.com/cielavenir/pybind11_playground/blob/master/src/pybind11_playground.cpp
with this patch:
class toyclass():
@typing.overload
def test_overload(self, arg0: str) -> None: ...
@typing.overload
def test_overload(self, arg0: object) -> None: ...
pass
without this patch:
class toyclass():
@typing.overload
def test_overload(self, arg0: object) -> None: ...
@typing.overload
def test_overload(self, arg0: str) -> None: ...
pass
$ mypy stubs/pybind11_playground-stubs/pybind11_playground/__init__.pyi
stubs/pybind11_playground-stubs/pybind11_playground/__init__.pyi:18: error: Overloaded function signature 2 will never be matched: signature 1's parameter type(s) are the same or broader
so actually tests/stubs/expected/cpp_library_bindings/_core/opaque_types/__init__.pyi
is weird
It appears to me that a PEP does not dictate the specific order of overloads, but rather mypy's interpretation of the stubs, which still makes a valid use case.
Originally the sorting of overloads was introduced to circumvent non-deterministic output in python<3.7 (#21). I think there are no drawbacks to merging this PR.
@cielavenir Could you please update the stubs to pass CI?
@sizmailov fixed
pybind11 users write overloaded functions order carefully, there are no need to sort them.
/cc @felixvd