Details
-
Bug
-
Resolution: Fixed
-
P3: Somewhat important
-
6.10.0
-
None
-
-
a33f25772 (dev), 1dc631efe (6.9)
Description
When adding a function with a PySequence and a numpy overload (specified by PyArrayObject, see https://codereview.qt-project.org/c/pyside/pyside-setup/+/642868 ), the PyArrayObject is mapped to
"PyArrayObject": ArrayLikeVariable(typing.Any), # numpy
by sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/mapping.py:234, leading to
@typing.overload def __init__(self, list: collections.abc.Iterable, /, parent: PySide6.QtCore.QObject | None = ...) -> None: ... @typing.overload def __init__(self, data: collections.abc.Sequence[typing.Any], /, parent: PySide6.QtCore.QObject | None = ...) -> None: ...
This causes an error in sources/pyside6/tests/pysidetest/mypy_correctness_test.py :
/QtCore.pyi:3457: error: Overloaded function signature 2 will never be matched: signature 1's parameter type(s) are the same or broader [overload-cannot-match] def __init__(self, data: collections.abc.Sequence[typing.Any], /, ... Found 1 error in 1 file (checked 10 source files)
For this, the type hint for numpy needs to be more specific (see also https://numpy.org/devdocs/reference/typing.html ).
Note though it is possible to build PySide without numpy (--disable-numpy-support), and importing numpy directly can be costly.
Attachments
Issue Links
- relates to
-
PYSIDE-3011 Adapt to 6.10
-
- Reported
-