pylint-dev / pylint

It's not just a linter that annoys you!
https://pylint.readthedocs.io/en/latest/
GNU General Public License v2.0
5.25k stars 1.12k forks source link

False positive for E1136 with PyQt4 overloaded signal #2543

Open alete89 opened 5 years ago

alete89 commented 5 years ago

Steps to reproduce

this code

from PyQt4 import QtGui
...
aComboBox = QtGui.QComboBox(self)
aList = [6,7,8,9,10,11,12,13,14,15,16,18,20,22,24,26,28]
for i in aList:
    aComboBox.addItem(str(i))

fontSizeCombo.activated[str].connect(self.slotOnActivated)

where brackets indicate the overloaded signal for strings

Current behavior

E1136:Value 'aComboBox.activated' is unsubscriptable

There are other false positives reported about this E1136, but neither from this syntax

Expected behavior

no warning or error.

pylint --version output

1.9.3

PCManticore commented 5 years ago

Thanks for reporting an issue! We'd probably need to add a fix in the corresponding astroid brain transforms: https://github.com/PyCQA/astroid/blob/master/astroid/brain/brain_qt.py#L76

Paciupa commented 11 months ago

I have the same issue. With next code:

from PyQt5.QtWidgets import QLineEdit
self.line_edit_variable = QLineEdit(self)
self.line_edit_variable.textChanged[str].connect(self.set_variable)

I get: E1136: Value 'self.line_edit_private_key.textChanged' is unsubscriptable (unsubscriptable-object).

Versions:

pylint 2.17.7
astroid 2.15.8
jaroslavpachola commented 7 months ago

It's still the same with PyQt6. May I ask what the problem is? Should we report to the Astroid repo? Is there a plan for fixing? Should someone from the outside take the initiative?

Pierre-Sassoulas commented 7 months ago

This require a tip to the astroid inference engine, we call that a "brain". As the astroid maintainers are spread very thin it's likely that creating a qt plugin (using the astroid brain's file here: https://github.com/pylint-dev/astroid/blob/main/astroid/brain/brain_qt.py as a basis) is the way to go. We can host it in the pylint-dev namespace so it gathers more attention (like we did for pylint-tensorflow here https://github.com/pylint-dev/pylint-tensorflow).