You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The issue here is that mypy isn't able to type check this stub because of the redundant overload, i.e., trying to use the stub with mypy errors with:
out/my_native_module.pyi:47: error: Overloaded function signature 2 will never be matched: signature 1's parameter type(s) are the same or broader [misc]
Found 1 error in 1 file (checked 1 source file)
This issue seems to be related to pybind/pybind11#4585 because there is also something funny happening related to name (which should be a property, but somehow adding a custom __str__ switches it to a method instead -- it is actually an instancemethod not a staticmethod though). Inspecting the underlying annotation produced by pybind11 at runtime:
So in a sense the root cause is the broken annotation produced by pybind11 here, but perhaps it is an easy fix on the stub generator side to omit such redundant overloads as a robustification? (The mypy stubgen just seems to ignore them, and therefore still produces type-checkable output in this case.)
The text was updated successfully, but these errors were encountered:
The following is a minimal example involving an enum with a custom
__str__
implementation:Running the stub generator on this module produces:
The issue here is that
mypy
isn't able to type check this stub because of the redundant overload, i.e., trying to use the stub with mypy errors with:This issue seems to be related to pybind/pybind11#4585 because there is also something funny happening related to
name
(which should be a property, but somehow adding a custom__str__
switches it to a method instead -- it is actually aninstancemethod
not astaticmethod
though). Inspecting the underlying annotation produced by pybind11 at runtime:So in a sense the root cause is the broken annotation produced by pybind11 here, but perhaps it is an easy fix on the stub generator side to omit such redundant overloads as a robustification? (The mypy stubgen just seems to ignore them, and therefore still produces type-checkable output in this case.)
The text was updated successfully, but these errors were encountered: