Skip to content

version 5.15.2.0 in pycharm didn't wok. #155

Open

Description

after I upgrade to pyqt5-stubs version 5.15.2.0, the XXX.clickked.XXX 's autocompletion in pycharm(2021.1) didn"t work.But in Vscode(with pylance) it works well.Then i downgrade to pyqt5-stubds version 5.14.2.2 ,the XXX.clickked.XXX 's autocompletion in pycharm(2021.1) starts working.

Activity

  1. The-Compiler commented on May 18, 2021

    @The-Compiler
    Collaborator

    What do you mean with "XXX.clickked.XXX 's autocompletion"? Can you maybe show a screenshot or code sample?

  2. altendky commented on May 19, 2021

    @altendky
    Collaborator

    Here's the diff for reference. 5.14.2.2...5.15.2.0 It certainly became more complex, but also more accurate to the real stuff. Anyways, yeah, it would be helpful to see a minimal example of code showing the issue and a screenshot of the issue.

    old...

    # Support for new-style signals and slots.
    class pyqtSignal:  # add methods
        def __init__(self, *types: typing.Any, name: str = ...) -> None: ...
        def emit(self, *args: typing.Any) -> None: ...
        def connect(self, slot: "PYQT_SLOT") -> None: ...
        def disconnect(self, slot: "PYQT_SLOT"=None) -> None: ...
    
    
    class pyqtBoundSignal:
        def emit(self, *args: typing.Any) -> None: ...
    
    # Convenient type aliases.
    PYQT_SIGNAL = typing.Union[pyqtSignal, pyqtBoundSignal]
    PYQT_SLOT = typing.Union[typing.Callable[..., None], pyqtBoundSignal]

    and new.

    class pyqtBoundSignal:
        signal = ... # type: str
    
        def __getitem__(self, key: object) -> "pyqtBoundSignal": ...
    
        def emit(self, *args: typing.Any) -> None: ...
        def connect(self, slot: "PYQT_SLOT") -> "QMetaObject.Connection": ...
        @typing.overload
        def disconnect(self) -> None: ...
        @typing.overload
        def disconnect(self, slot: typing.Union["PYQT_SLOT", "QMetaObject.Connection"]) -> None: ...
    
    
    class pyqtSignal:
    
        signatures = ...  # type: typing.Tuple[str, ...]
    
        def __init__(self, *types: typing.Any, name: str = ...) -> None: ...
    
        @typing.overload
        def __get__(self, instance: None, owner: typing.Type["QObject"]) -> "pyqtSignal": ...
        @typing.overload
        def __get__(self, instance: "QObject", owner: typing.Type["QObject"]) -> pyqtBoundSignal: ...
    
    
    # Convenient type aliases.
    PYQT_SLOT = typing.Union[typing.Callable[..., object], pyqtBoundSignal]
    
    
    QObjectT = typing.TypeVar("QObjectT", bound="QObject")
  3. altendky commented on Jun 15, 2021

    @altendky
    Collaborator

    Trying with 5.15.3.0.

    image

    But...

    image

    When I ctrl+left mouse PyCharm takes me to _their_ stubs. Though, the same goes for 5.14.2.2 for me here, so maybe I just have something wrong. I'll see if I can figure out how to disable the builtins, or...

  4. altendky commented on Jun 15, 2021

    @altendky
    Collaborator

    If I rename PyCharm's builtin stubs to avoid their usage (is there a better way?) then I see the issue in pyqt5-stubs==5.15.2 while it works in pyqt5-stubs==5.14.2.2. In all cases it is offering the popup to complete .pushbutton and .clicked, but doesn't manage to understand how to work with .clicked. But, it does understand how to handle .s and .s.connect...

    image

    Ok, I added a few more things and still have no theories. Everything I code gets completion hints for connect. The button doesn't.

    import typing
    
    from PyQt5 import QtCore
    from PyQt5 import QtWidgets
    
    
    class C(QtCore.QObject):
        b: QtCore.pyqtSignal = QtCore.pyqtSignal()
        c: typing.ClassVar[QtCore.pyqtSignal] = QtCore.pyqtSignal()
        pushbutton: QtWidgets.QPushButton
    
        def __init__(self, parent=None):
            super().__init__(parent)
            self.pushbutton = QtWidgets.QPushButton()
    
        def m(self):
            self.b.connect()
            self.c.connect()
            self.pushbutton.clicked.con
    
    
    class I(C):
        pass
    
    class D(QtCore.QObject):
        c: C
        i: I
    
        def __init__(self, parent=None):
            super().__init__(parent)
            self.c = C()
            self.i = I()
    
        def m(self):
            self.c.b.connect()
            self.c.c.connect()
            self.i.b.connect()
            self.i.c.connect()
            self.c.pushbutton.clicked.conn
            self.i.pushbutton.clicked.conn
    
    # what ctrl+left-click goes to for `.clicked
    #
    # class QAbstractButton(QWidget):
    # <snip>
    #     clicked: typing.ClassVar[QtCore.pyqtSignal]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions