From b30977e6a13810a16d027bccded05336b9bd2ad5 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 12 May 2022 15:21:56 +0200 Subject: qt brain: Make slot argument optional for disconnect() (#1550) * qt brain: Make slot argument optional for disconnect() Discussed here: https://github.com/PyCQA/astroid/pull/1531#issuecomment-1111963792 PyQt supports calling .disconnect() without any arguments in order to disconnect all slots: https://www.riverbankcomputing.com/static/Docs/PyQt6/signals_slots.html#disconnect Strictly speaking, slot=None is a wrong call, as actually passing None does not work: https://github.com/python-qt-tools/PyQt5-stubs/pull/103 However, pylint/astroid does not support overloads needed to properly express this: https://github.com/PyCQA/pylint/issues/5264 So, while this is "wrong", it's less wrong than before - without this change, pylint expects a mandatory argument, thus raising a false-positive here: from PyQt5.QtCore import QTimer t = QTimer() t.timeout.connect(lambda: None) t.timeout.disconnect() despite running fine, pylint complains: test.py:4:0: E1120: No value for argument 'slot' in method call (no-value-for-parameter) while with this change, things work fine. --- ChangeLog | 2 ++ 1 file changed, 2 insertions(+) (limited to 'ChangeLog') diff --git a/ChangeLog b/ChangeLog index b322afd1..e1a27561 100644 --- a/ChangeLog +++ b/ChangeLog @@ -13,6 +13,8 @@ What's New in astroid 2.11.6? ============================= Release date: TBA +* The Qt brain now correctly treats calling ``.disconnect()`` (with no + arguments) on a slot as valid. What's New in astroid 2.11.5? -- cgit v1.2.1