Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

version 5.15.2.0 in pycharm didn't wok. #155

Open
jyc001 opened this issue May 15, 2021 · 6 comments
Open

version 5.15.2.0 in pycharm didn't wok. #155

jyc001 opened this issue May 15, 2021 · 6 comments

Comments

@jyc001
Copy link

jyc001 commented May 15, 2021

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.

@The-Compiler
Copy link
Collaborator

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

@altendky
Copy link
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")

@jyc001
Copy link
Author

jyc001 commented May 21, 2021

self.pushbutton.clicked.connect() 's clicked.connect()

@jyc001
Copy link
Author

jyc001 commented Jun 5, 2021

just like self.pushbutton.clicked.connect()

@altendky
Copy link
Collaborator

altendky commented Jun 15, 2021

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...

@altendky
Copy link
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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants