Skip to content

Commit ef3c369

Browse files
Fix flake8-warnings in signals tests
Pick-to: 6.7 Task-number: PYSIDE-2646 Change-Id: I4f6b5d642f540fb3f5f2e219057c862fe5998a21 Reviewed-by: Qt CI Bot <[email protected]> Reviewed-by: Cristian Maureira-Fredes <[email protected]>
1 parent 8b479a0 commit ef3c369

28 files changed

+25
-56
lines changed

.flake8

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,7 @@ per-file-ignores =
66
# for init_test_paths() hack
77
*_test_*.py:E402
88
*_test.py:E402
9+
*bug_*.py:E402
910
test_*.py:E402
11+
signal_across_threads.py:E402
1012
__init__.py:F401,E402

sources/pyside6/tests/signals/bug_311.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,3 @@ def testBug(self):
5252

5353
if __name__ == '__main__':
5454
unittest.main()
55-

sources/pyside6/tests/signals/bug_312.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,3 @@ def testDisconnectCleanup(self):
5858

5959
if __name__ == '__main__':
6060
unittest.main()
61-
62-

sources/pyside6/tests/signals/bug_319.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,3 @@ def testBug(self):
4545

4646
if __name__ == '__main__':
4747
unittest.main()
48-

sources/pyside6/tests/signals/bug_79.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def callback(self, o):
3030

3131
def testNoLeaks_ConnectAndDisconnect(self):
3232
self._called = None
33-
app = QApplication([])
33+
app = QApplication([]) # noqa: F841
3434
o = QTreeView()
3535
o.setModel(QStandardItemModel())
3636
o.selectionModel().destroyed.connect(self.callback)

sources/pyside6/tests/signals/invalid_callback_test.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,3 @@ def testIntegerCb(self):
4040

4141
if __name__ == '__main__':
4242
unittest.main()
43-

sources/pyside6/tests/signals/lambda_gui_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def testButton(self):
3333
# Connecting a lambda to a QPushButton.clicked()
3434
obj = QPushButton('label')
3535
ctr = Control()
36-
func = lambda: setattr(ctr, 'arg', True)
36+
func = lambda: setattr(ctr, 'arg', True) # noqa: E731
3737
obj.clicked.connect(func)
3838
obj.click()
3939
self.assertTrue(ctr.arg)
@@ -44,7 +44,7 @@ def testSpinButton(self):
4444
obj = QSpinBox()
4545
ctr = Control()
4646
arg = 444
47-
func = lambda x: setattr(ctr, 'arg', 444)
47+
func = lambda x: setattr(ctr, 'arg', 444) # noqa: E731
4848
obj.valueChanged.connect(func)
4949
obj.setValue(444)
5050
self.assertEqual(ctr.arg, arg)

sources/pyside6/tests/signals/leaking_signal_test.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import os
55
import sys
66
import unittest
7-
import weakref
87

98
from pathlib import Path
109
sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
@@ -21,7 +20,7 @@ def testLeakingSignal(self):
2120
class Emitter(QObject):
2221
my_signal = Signal(object)
2322

24-
emitter = Emitter()
23+
emitter = Emitter() # noqa: F841
2524

2625

2726
if __name__ == '__main__':

sources/pyside6/tests/signals/multiple_connections_gui_test.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
# Copyright (C) 2022 The Qt Company Ltd.
22
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
33

4-
from functools import partial
54
import os
6-
import random
75
import sys
86
import unittest
97

sources/pyside6/tests/signals/pysignal_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from PySide6.QtCore import QObject, SIGNAL, SLOT, Qt
1515

1616
try:
17-
from PySide6.QtWidgets import QSpinBox, QApplication, QWidget
17+
from PySide6.QtWidgets import QSpinBox, QApplication, QWidget # noqa: F401
1818
hasQtGui = True
1919
except ImportError:
2020
hasQtGui = False
@@ -97,7 +97,7 @@ def setUp(self):
9797
def tearDown(self):
9898
try:
9999
del self.args
100-
except:
100+
except: # noqa: E722
101101
pass
102102
# PYSIDE-535: Need to collect garbage in PyPy to trigger deletion
103103
gc.collect()

sources/pyside6/tests/signals/qobject_destroyed_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from init_paths import init_test_paths
1212
init_test_paths(False)
1313

14-
from PySide6.QtCore import QObject, SIGNAL
14+
from PySide6.QtCore import QObject
1515

1616

1717
class QObjectDestroyed(unittest.TestCase):

sources/pyside6/tests/signals/ref01_test.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,3 @@ def testBoundSignal(self):
3737

3838
if __name__ == '__main__':
3939
unittest.main()
40-
41-

sources/pyside6/tests/signals/ref02_test.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from init_paths import init_test_paths
1313
init_test_paths(False)
1414

15-
from PySide6.QtCore import QCoreApplication, QTimeLine
15+
from PySide6.QtCore import QTimeLine
1616
from helper.usesqapplication import UsesQApplication
1717

1818

@@ -58,4 +58,3 @@ def finishedSlot():
5858

5959
if __name__ == '__main__':
6060
unittest.main()
61-

sources/pyside6/tests/signals/ref03_test.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,3 @@ def destroyedSlot():
4040

4141
if __name__ == '__main__':
4242
unittest.main()
43-

sources/pyside6/tests/signals/ref04_test.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,6 @@ def slot():
5353
self.emitter.mySignal.emit()
5454
self.assertEqual(self.counter, 2)
5555

56-
# def testConnectWithConfigureMethod(self):
57-
#
58-
# def slot():
59-
# self.counter += 1
60-
#
61-
# self.emitter.pyqtConfigure(mySignal=slot)
62-
# self.assertEqual(self.counter, 0)
63-
# self.emitter.mySignal.emit()
64-
# self.assertEqual(self.counter, 1)
65-
6656

6757
if __name__ == '__main__':
6858
unittest.main()
69-

sources/pyside6/tests/signals/ref05_test.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from init_paths import init_test_paths
1313
init_test_paths(False)
1414

15-
from PySide6.QtCore import QObject, QCoreApplication, QTimeLine, Slot
15+
from PySide6.QtCore import QObject, QTimeLine, Slot
1616
from helper.usesqapplication import UsesQApplication
1717

1818

@@ -56,4 +56,3 @@ def testUserSlot(self):
5656

5757
if __name__ == '__main__':
5858
unittest.main()
59-

sources/pyside6/tests/signals/ref06_test.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from init_paths import init_test_paths
1313
init_test_paths(False)
1414

15-
from PySide6.QtCore import QObject, QCoreApplication, QTimeLine, Signal, Slot
15+
from PySide6.QtCore import QObject, QTimeLine, Signal, Slot
1616
from helper.usesqapplication import UsesQApplication
1717

1818

@@ -59,4 +59,3 @@ def testSignaltoSignal(self):
5959

6060
if __name__ == '__main__':
6161
unittest.main()
62-

sources/pyside6/tests/signals/segfault_proxyparent_test.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def setUp(self):
4444
def tearDown(self):
4545
try:
4646
del self.args
47-
except:
47+
except: # noqa: E722
4848
pass
4949
# PYSIDE-535: Need to collect garbage in PyPy to trigger deletion
5050
gc.collect()
@@ -73,4 +73,3 @@ def testSegfault(self):
7373

7474
if __name__ == '__main__':
7575
unittest.main()
76-

sources/pyside6/tests/signals/self_connect_test.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@
1313
from init_paths import init_test_paths
1414
init_test_paths(False)
1515

16-
from PySide6.QtCore import QObject, SIGNAL, SLOT
16+
from PySide6.QtCore import QObject, Slot, SIGNAL, SLOT
1717
from PySide6.QtWidgets import QPushButton, QWidget
18-
from PySide6.QtCore import QObject, Slot
1918

2019
from helper.usesqapplication import UsesQApplication
2120

@@ -25,7 +24,7 @@ def __init__(self, p=None):
2524
super().__init__(p)
2625
self.triggered = False
2726

28-
@Slot(bool,int)
27+
@Slot(bool, int)
2928
def default_parameter_slot(self, bool_value, int_value=0):
3029
self.triggered = True
3130

sources/pyside6/tests/signals/short_circuit_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from init_paths import init_test_paths
1212
init_test_paths(False)
1313

14-
from PySide6.QtCore import QObject, SIGNAL, SLOT
14+
from PySide6.QtCore import QObject, SIGNAL
1515

1616

1717
class Dummy(QObject):
@@ -27,7 +27,7 @@ def setUp(self):
2727
def tearDown(self):
2828
try:
2929
del self.args
30-
except:
30+
except: # noqa: E722
3131
pass
3232
# PYSIDE-535: Need to collect garbage in PyPy to trigger deletion
3333
gc.collect()

sources/pyside6/tests/signals/signal2signal_connect_test.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ def tearDown(self):
3434
# Delete used resources
3535
try:
3636
del self.sender
37-
except:
37+
except: # noqa: E722
3838
pass
3939
try:
4040
del self.forwarder
41-
except:
41+
except: # noqa: E722
4242
pass
4343
del self.args
4444
# PYSIDE-535: Need to collect garbage in PyPy to trigger deletion
@@ -116,5 +116,3 @@ def testSignalWithOneQObjectArgument(self):
116116

117117
if __name__ == '__main__':
118118
unittest.main()
119-
120-

sources/pyside6/tests/signals/signal_autoconnect_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def on_button_clicked(self):
2727
class AutoConnectionTest(unittest.TestCase):
2828

2929
def testConnection(self):
30-
app = QApplication([])
30+
app = QApplication([]) # noqa: F841
3131

3232
win = MyObject()
3333
btn = QPushButton("click", win)

sources/pyside6/tests/signals/signal_emission_gui_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from init_paths import init_test_paths
1515
init_test_paths(False)
1616

17-
from PySide6.QtCore import QObject, SIGNAL, SLOT
17+
from PySide6.QtCore import SIGNAL
1818

1919
try:
2020
from PySide6.QtWidgets import QSpinBox, QPushButton

sources/pyside6/tests/signals/signal_emission_test.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
from PySide6.QtCore import QObject, SIGNAL, SLOT, QProcess, QTimeLine
1818

19-
from helper.basicpyslotcase import BasicPySlotCase
2019
from helper.usesqapplication import UsesQApplication
2120

2221

sources/pyside6/tests/signals/signal_manager_refcount_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616

1717

1818
class SignalManagerRefCount(unittest.TestCase):
19-
"""Simple test case to check if the signal_manager is erroneously incrementing the object refcounter"""
19+
"""Simple test case to check if the signal_manager is erroneously incrementing the
20+
object refcounter."""
2021

2122
@unittest.skipUnless(hasattr(sys, "getrefcount"), f"{sys.implementation.name} has no refcount")
2223
def testObjectRefcount(self):
@@ -33,4 +34,3 @@ def callback():
3334

3435
if __name__ == '__main__':
3536
unittest.main()
36-

sources/pyside6/tests/signals/signal_signature_test.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,3 @@ def testLambdaSlot(self):
9999

100100
if __name__ == '__main__':
101101
unittest.main()
102-

sources/pyside6/tests/signals/signal_with_primitive_type_test.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from init_paths import init_test_paths
1111
init_test_paths(False)
1212

13-
from PySide6.QtCore import QCoreApplication, QObject, QTimeLine, SIGNAL
13+
from PySide6.QtCore import QCoreApplication, QTimeLine
1414

1515

1616
class SignalPrimitiveTypeTest(unittest.TestCase):
@@ -36,5 +36,3 @@ def testTimeLine(self):
3636

3737
if __name__ == '__main__':
3838
unittest.main()
39-
40-

sources/pyside6/tests/signals/slot_reference_count_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from init_paths import init_test_paths
1313
init_test_paths(False)
1414

15-
from PySide6.QtCore import QObject, SIGNAL, SLOT
15+
from PySide6.QtCore import QObject, SIGNAL
1616

1717

1818
class Dummy(QObject):

0 commit comments

Comments
 (0)