Details
-
Bug
-
Resolution: Fixed
-
Not Evaluated
-
None
-
6.9.0
-
None
-
c907725a5 (dev)
Description
Type hints generated by pyside6-genpyi (or shiboken6-genpyi) include references to `collections.abc.Sequence`. Example from QtWidgets.pyi:
class QApplication(PySide6.QtGui.QGuiApplication):
[...]
@staticmethod
def setFont(arg__1: PySide6.QtGui.QFont | str | collections.abc.Sequence[str], /, className: bytes | bytearray | memoryview | None = ...) -> None: ...
However, the import for collections.abc is missing. Only collections is imported:
# Copyright (C) 2022 The Qt Company Ltd. # SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only from __future__ import annotations """ This file contains the exact signatures for all functions in module PySide6.QtWidgets, except for defaults which are replaced by "...". # mypy: disable-error-code="override, overload-overlap" """ # Module `PySide6.QtWidgets` import PySide6.QtWidgets import PySide6.QtCore import PySide6.QtGui import os import enum import typing import collections from PySide6.QtCore import Signal, SignalInstance from shiboken6 import Shiboken
This means that type checkers such as basedpyright might be unable to resolve the Sequence type.
See:
The first argument is recognized as "Unknown" by basedpyright and "Any" by Pylance.
Replacing the import with the proper collections.abc fixes all errors.
I guess the proper place to fix this would be here: https://github.com/pyside/pyside-setup/blob/e55bad3c11de793828fb1bdb503d1631c153a488/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/lib/pyi_generator.py#L244
Attachments
Issue Links
- relates to
-
PYSIDE-3012 QtCore.pyi: Improving type annotations
-
- Closed
-
For Gerrit Dashboard: PYSIDE-3092 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
643975,8 | type hints: Correct the collections import in the pyi files | dev | pyside/pyside-setup | Status: MERGED | +2 | 0 |
644909,2 | type hints: Correct the collections import in the pyi files | 6.9 | pyside/pyside-setup | Status: MERGED | +2 | 0 |